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