home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Database Designers / Rational Rose 2000 / Rational Setup.EXE / common / lib / MSWin32-x86 / CORE / win32.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  9.4 KB  |  361 lines

  1. /* WIN32.H
  2.  *
  3.  * (c) 1995 Microsoft Corporation. All rights reserved. 
  4.  *         Developed by hip communications inc., http://info.hip.com/info/
  5.  *
  6.  *    You may distribute under the terms of either the GNU General Public
  7.  *    License or the Artistic License, as specified in the README file.
  8.  */
  9. #ifndef  _INC_WIN32_PERL5
  10. #define  _INC_WIN32_PERL5
  11.  
  12. #ifdef PERL_OBJECT
  13. #  define DYNAMIC_ENV_FETCH
  14. #  define ENV_HV_NAME "___ENV_HV_NAME___"
  15. #  define prime_env_iter()
  16. #  define WIN32IO_IS_STDIO        /* don't pull in custom stdio layer */
  17. #  ifdef PERL_GLOBAL_STRUCT
  18. #    error PERL_GLOBAL_STRUCT cannot be defined with PERL_OBJECT
  19. #  endif
  20. #  define win32_get_privlib PerlEnv_lib_path
  21. #  define win32_get_sitelib PerlEnv_sitelib_path
  22. #endif
  23.  
  24. #ifdef __GNUC__
  25. typedef long long __int64;
  26. #  define Win32_Winsock
  27. /* GCC does not do __declspec() - render it a nop 
  28.  * and turn on options to avoid importing data 
  29.  */
  30. #  define __declspec(x)
  31. #  ifndef PERL_OBJECT
  32. #    define PERL_GLOBAL_STRUCT
  33. #    define MULTIPLICITY
  34. #  endif
  35. #endif
  36.  
  37. /* Define DllExport akin to perl's EXT, 
  38.  * If we are in the DLL or mimicing the DLL for Win95 work round
  39.  * then Export the symbol, 
  40.  * otherwise import it.
  41.  */
  42.  
  43. #if defined(PERL_OBJECT)
  44. #define DllExport
  45. #else
  46. #if defined(PERLDLL) || defined(WIN95FIX)
  47. #define DllExport
  48. /*#define DllExport __declspec(dllexport)*/    /* noises with VC5+sp3 */
  49. #else 
  50. #define DllExport __declspec(dllimport)
  51. #endif
  52. #endif
  53.  
  54. #define  WIN32_LEAN_AND_MEAN
  55. #include <windows.h>
  56.  
  57. #ifdef   WIN32_LEAN_AND_MEAN        /* C file is NOT a Perl5 original. */
  58. #define  CONTEXT    PERL_CONTEXT    /* Avoid conflict of CONTEXT defs. */
  59. #endif /*WIN32_LEAN_AND_MEAN */
  60.  
  61. #ifndef TLS_OUT_OF_INDEXES
  62. #define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
  63. #endif
  64.  
  65. #include <dirent.h>
  66. #include <io.h>
  67. #include <process.h>
  68. #include <stdio.h>
  69. #include <direct.h>
  70. #include <stdlib.h>
  71. #ifndef EXT
  72. #include "EXTERN.h"
  73. #endif
  74.  
  75. struct tms {
  76.     long    tms_utime;
  77.     long    tms_stime;
  78.     long    tms_cutime;
  79.     long    tms_cstime;
  80. };
  81.  
  82. #ifndef START_EXTERN_C
  83. #undef EXTERN_C
  84. #ifdef __cplusplus
  85. #  define START_EXTERN_C extern "C" {
  86. #  define END_EXTERN_C }
  87. #  define EXTERN_C extern "C"
  88. #else
  89. #  define START_EXTERN_C 
  90. #  define END_EXTERN_C 
  91. #  define EXTERN_C
  92. #endif
  93. #endif
  94.  
  95. #define  STANDARD_C    1
  96. #define  DOSISH        1        /* no escaping our roots */
  97. #define  OP_BINARY    O_BINARY    /* mistake in in pp_sys.c? */
  98.  
  99. /* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as
  100.  * real filehandles. XXX Should always be defined (the other version is untested) */
  101. #define USE_SOCKETS_AS_HANDLES
  102.  
  103. /* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls
  104.  * to read the environment, bypassing the runtime's (usually broken)
  105.  * facilities for accessing the same.  See note in util.c/my_setenv(). */
  106. /*#define USE_WIN32_RTL_ENV */
  107.  
  108. /* Define USE_FIXED_OSFHANDLE to fix VC's _open_osfhandle() on W95.
  109.  * Can only enable it if not using the DLL CRT (it doesn't expose internals) */
  110. #if defined(_MSC_VER) && !defined(_DLL) && defined(_M_IX86)
  111. #define USE_FIXED_OSFHANDLE
  112. #endif
  113.  
  114. #define ENV_IS_CASELESS
  115.  
  116. #ifndef VER_PLATFORM_WIN32_WINDOWS    /* VC-2.0 headers don't have this */
  117. #define VER_PLATFORM_WIN32_WINDOWS    1
  118. #endif
  119.  
  120. #ifndef FILE_SHARE_DELETE        /* VC-4.0 headers don't have this */
  121. #define FILE_SHARE_DELETE        0x00000004
  122. #endif
  123.  
  124. /* Compiler-specific stuff. */
  125.  
  126. #ifdef __BORLANDC__        /* Borland C++ */
  127.  
  128. #define _access access
  129. #define _chdir chdir
  130. #include <sys/types.h>
  131.  
  132. #ifndef DllMain
  133. #define DllMain DllEntryPoint
  134. #endif
  135.  
  136. #pragma warn -ccc    /* "condition is always true/false" */
  137. #pragma warn -rch    /* "unreachable code" */
  138. #pragma warn -sig    /* "conversion may lose significant digits" */
  139. #pragma warn -pia    /* "possibly incorrect assignment" */
  140. #pragma warn -par    /* "parameter 'foo' is never used" */
  141. #pragma warn -aus    /* "'foo' is assigned a value that is never used" */
  142. #pragma warn -use    /* "'foo' is declared but never used" */
  143. #pragma warn -csu    /* "comparing signed and unsigned values" */
  144. #pragma warn -pro    /* "call to function with no prototype" */
  145.  
  146. #define USE_RTL_WAIT    /* Borland has a working wait() */
  147.  
  148. /* Borland is picky about a bare member function name used as its ptr */
  149. #ifdef PERL_OBJECT
  150. #define FUNC_NAME_TO_PTR(name)    &(name)
  151. #endif
  152.  
  153. #endif
  154.  
  155. #ifdef _MSC_VER            /* Microsoft Visual C++ */
  156.  
  157. typedef long        uid_t;
  158. typedef long        gid_t;
  159. #pragma  warning(disable: 4018 4035 4101 4102 4244 4245 4761)
  160.  
  161. #ifndef PERL_OBJECT
  162.  
  163. /* Visual C thinks that a pointer to a member variable is 16 bytes in size. */
  164. #define STRUCT_MGVTBL_DEFINITION                    \
  165. struct mgvtbl {                                \
  166.     union {                                \
  167.     int        (CPERLscope(*svt_get))    _((SV *sv, MAGIC* mg));    \
  168.     char        handle_VC_problem1[16];                \
  169.     };                                    \
  170.     union {                                \
  171.     int        (CPERLscope(*svt_set))    _((SV *sv, MAGIC* mg));    \
  172.     char        handle_VC_problem2[16];                \
  173.     };                                    \
  174.     union {                                \
  175.     U32        (CPERLscope(*svt_len))    _((SV *sv, MAGIC* mg));    \
  176.     char        handle_VC_problem3[16];                \
  177.     };                                    \
  178.     union {                                \
  179.     int        (CPERLscope(*svt_clear))    _((SV *sv, MAGIC* mg));    \
  180.     char        handle_VC_problem4[16];                \
  181.     };                                    \
  182.     union {                                \
  183.     int        (CPERLscope(*svt_free))    _((SV *sv, MAGIC* mg));    \
  184.     char        handle_VC_problem5[16];                \
  185.     };                                    \
  186. }
  187.  
  188. #define BASEOP_DEFINITION        \
  189.     OP*        op_next;        \
  190.     OP*        op_sibling;        \
  191.     OP*        (CPERLscope(*op_ppaddr))_((ARGSproto));        \
  192.     char    handle_VC_problem[12];    \
  193.     PADOFFSET    op_targ;        \
  194.     OPCODE    op_type;        \
  195.     U16        op_seq;            \
  196.     U8        op_flags;        \
  197.     U8        op_private;
  198.  
  199. #define UNION_ANY_DEFINITION union any {        \
  200.     void*    any_ptr;                \
  201.     I32        any_i32;                \
  202.     IV        any_iv;                    \
  203.     long    any_long;                \
  204.     void    (CPERLscope(*any_dptr)) _((void*));    \
  205.     char    handle_VC_problem[16];            \
  206. }
  207.  
  208. #endif /* PERL_OBJECT */
  209.  
  210. #endif /* _MSC_VER */
  211.  
  212. #ifdef __MINGW32__        /* Minimal Gnu-Win32 */
  213.  
  214. typedef long        uid_t;
  215. typedef long        gid_t;
  216. #define _environ    environ
  217. #define flushall    _flushall
  218. #define fcloseall    _fcloseall
  219.  
  220. #ifdef PERL_OBJECT
  221. #define FUNC_NAME_TO_PTR(name)    &(name)
  222. #endif
  223.  
  224. #ifndef _O_NOINHERIT
  225. #  define _O_NOINHERIT    0x0080
  226. #  ifndef _NO_OLDNAMES
  227. #    define O_NOINHERIT    _O_NOINHERIT
  228. #  endif
  229. #endif
  230.  
  231. #ifndef _O_NOINHERIT
  232. #  define _O_NOINHERIT    0x0080
  233. #  ifndef _NO_OLDNAMES
  234. #    define O_NOINHERIT    _O_NOINHERIT
  235. #  endif
  236. #endif
  237.  
  238. #endif /* __MINGW32__ */
  239.  
  240. /* compatibility stuff for other compilers goes here */
  241.  
  242.  
  243. START_EXTERN_C
  244.  
  245. /* For UNIX compatibility. */
  246.  
  247. extern  uid_t    getuid(void);
  248. extern  gid_t    getgid(void);
  249. extern  uid_t    geteuid(void);
  250. extern  gid_t    getegid(void);
  251. extern  int    setuid(uid_t uid);
  252. extern  int    setgid(gid_t gid);
  253. extern  int    kill(int pid, int sig);
  254. extern  void    *sbrk(int need);
  255. extern    char *    getlogin(void);
  256. extern    int    chown(const char *p, uid_t o, gid_t g);
  257.  
  258. #undef     Stat
  259. #define  Stat        win32_stat
  260.  
  261. #undef   init_os_extras
  262. #define  init_os_extras Perl_init_os_extras
  263.  
  264. DllExport void        Perl_win32_init(int *argcp, char ***argvp);
  265. DllExport void        Perl_init_os_extras(void);
  266. DllExport void        win32_str_os_error(void *sv, DWORD err);
  267.  
  268. #ifndef USE_SOCKETS_AS_HANDLES
  269. extern FILE *        my_fdopen(int, char *);
  270. #endif
  271. extern int        my_fclose(FILE *);
  272. extern int        do_aspawn(void *really, void **mark, void **sp);
  273. extern int        do_spawn(char *cmd);
  274. extern int        do_spawn_nowait(char *cmd);
  275. extern char        do_exec(char *cmd);
  276. extern char *        win32_get_privlib(char *pl);
  277. extern char *        win32_get_sitelib(char *pl);
  278. extern int        IsWin95(void);
  279. extern int        IsWinNT(void);
  280.  
  281. extern char *        staticlinkmodules[];
  282.  
  283. END_EXTERN_C
  284.  
  285. typedef  char *        caddr_t;    /* In malloc.c (core address). */
  286.  
  287. /*
  288.  * handle socket stuff, assuming socket is always available
  289.  */
  290. #include <sys/socket.h>
  291. #include <netdb.h>
  292.  
  293. #ifdef MYMALLOC
  294. #define EMBEDMYMALLOC    /**/
  295. /* #define USE_PERL_SBRK    /**/
  296. /* #define PERL_SBRK_VIA_MALLOC    /**/
  297. #endif
  298.  
  299. #if defined(PERLDLL) && !defined(PERL_CORE)
  300. #define PERL_CORE
  301. #endif
  302.  
  303. #ifdef USE_BINMODE_SCRIPTS
  304. #define PERL_SCRIPT_MODE "rb"
  305. EXT void win32_strip_return(struct sv *sv);
  306. #else
  307. #define PERL_SCRIPT_MODE "r"
  308. #define win32_strip_return(sv) NOOP
  309. #endif
  310.  
  311. #define HAVE_INTERP_INTERN
  312. struct interp_intern {
  313.     char *    w32_perlshell_tokens;
  314.     char **    w32_perlshell_vec;
  315.     long    w32_perlshell_items;
  316.     struct av *    w32_fdpid;
  317. #ifndef USE_RTL_WAIT
  318.     long    w32_num_children;
  319.     HANDLE    w32_child_pids[MAXIMUM_WAIT_OBJECTS];
  320. #endif
  321. };
  322.  
  323. #define w32_perlshell_tokens    (PL_sys_intern.w32_perlshell_tokens)
  324. #define w32_perlshell_vec    (PL_sys_intern.w32_perlshell_vec)
  325. #define w32_perlshell_items    (PL_sys_intern.w32_perlshell_items)
  326. #define w32_fdpid        (PL_sys_intern.w32_fdpid)
  327.  
  328. #ifndef USE_RTL_WAIT
  329. #  define w32_num_children    (PL_sys_intern.w32_num_children)
  330. #  define w32_child_pids    (PL_sys_intern.w32_child_pids)
  331. #endif
  332.  
  333. /* 
  334.  * Now Win32 specific per-thread data stuff 
  335.  */
  336.  
  337. #ifdef USE_THREADS
  338. #  ifndef USE_DECLSPEC_THREAD
  339. #    define HAVE_THREAD_INTERN
  340.  
  341. struct thread_intern {
  342.     /* XXX can probably use one buffer instead of several */
  343.     char        Wstrerror_buffer[512];
  344.     struct servent    Wservent;
  345.     char        Wgetlogin_buffer[128];
  346.     char        Ww32_perllib_root[MAX_PATH+1];
  347. #    ifdef USE_SOCKETS_AS_HANDLES
  348.     int            Winit_socktype;
  349. #    endif
  350. #    ifdef HAVE_DES_FCRYPT
  351.     char        Wcrypt_buffer[30];
  352. #    endif
  353. #    ifdef USE_RTL_THREAD_API
  354.     void *        retv;    /* slot for thread return value */
  355. #    endif
  356. };
  357. #  endif /* !USE_DECLSPEC_THREAD */
  358. #endif /* USE_THREADS */
  359.  
  360. #endif /* _INC_WIN32_PERL5 */
  361.