| 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 | #ifndef _WIN32_WINNT
 | 
|---|
| 13 | #  define _WIN32_WINNT 0x0400     /* needed for TryEnterCriticalSection() etc. */
 | 
|---|
| 14 | #endif
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #if defined(PERL_IMPLICIT_SYS)
 | 
|---|
| 17 | #  define DYNAMIC_ENV_FETCH
 | 
|---|
| 18 | #  define HAS_GETENV_LEN
 | 
|---|
| 19 | #  define prime_env_iter()
 | 
|---|
| 20 | #  define WIN32IO_IS_STDIO              /* don't pull in custom stdio layer */
 | 
|---|
| 21 | #  define WIN32SCK_IS_STDSCK            /* don't pull in custom wsock layer */
 | 
|---|
| 22 | #  ifdef PERL_GLOBAL_STRUCT
 | 
|---|
| 23 | #    error PERL_GLOBAL_STRUCT cannot be defined with PERL_IMPLICIT_SYS
 | 
|---|
| 24 | #  endif
 | 
|---|
| 25 | #  define win32_get_privlib PerlEnv_lib_path
 | 
|---|
| 26 | #  define win32_get_sitelib PerlEnv_sitelib_path
 | 
|---|
| 27 | #  define win32_get_vendorlib PerlEnv_vendorlib_path
 | 
|---|
| 28 | #endif
 | 
|---|
| 29 | 
 | 
|---|
| 30 | #ifdef __GNUC__
 | 
|---|
| 31 | #  ifndef __int64               /* some versions seem to #define it already */
 | 
|---|
| 32 | #    define __int64 long long
 | 
|---|
| 33 | #  endif
 | 
|---|
| 34 | #  define Win32_Winsock
 | 
|---|
| 35 | #ifdef __cplusplus
 | 
|---|
| 36 | /* Mingw32 gcc -xc++ objects to __attribute((unused)) at least */
 | 
|---|
| 37 | #undef  PERL_UNUSED_DECL
 | 
|---|
| 38 | #define PERL_UNUSED_DECL
 | 
|---|
| 39 | #endif
 | 
|---|
| 40 | #endif
 | 
|---|
| 41 | 
 | 
|---|
| 42 | 
 | 
|---|
| 43 | /* Define DllExport akin to perl's EXT,
 | 
|---|
| 44 |  * If we are in the DLL or mimicing the DLL for Win95 work round
 | 
|---|
| 45 |  * then Export the symbol,
 | 
|---|
| 46 |  * otherwise import it.
 | 
|---|
| 47 |  */
 | 
|---|
| 48 | 
 | 
|---|
| 49 | /* now even GCC supports __declspec() */
 | 
|---|
| 50 | 
 | 
|---|
| 51 | #if defined(PERLDLL) || defined(WIN95FIX)
 | 
|---|
| 52 | #define DllExport
 | 
|---|
| 53 | /*#define DllExport __declspec(dllexport)*/     /* noises with VC5+sp3 */
 | 
|---|
| 54 | #else
 | 
|---|
| 55 | #define DllExport __declspec(dllimport)
 | 
|---|
| 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 | #include <stddef.h>
 | 
|---|
| 76 | #include <fcntl.h>
 | 
|---|
| 77 | #ifndef EXT
 | 
|---|
| 78 | #include "EXTERN.h"
 | 
|---|
| 79 | #endif
 | 
|---|
| 80 | 
 | 
|---|
| 81 | struct tms {
 | 
|---|
| 82 |         long    tms_utime;
 | 
|---|
| 83 |         long    tms_stime;
 | 
|---|
| 84 |         long    tms_cutime;
 | 
|---|
| 85 |         long    tms_cstime;
 | 
|---|
| 86 | };
 | 
|---|
| 87 | 
 | 
|---|
| 88 | #ifndef SYS_NMLN
 | 
|---|
| 89 | #define SYS_NMLN        257
 | 
|---|
| 90 | #endif
 | 
|---|
| 91 | 
 | 
|---|
| 92 | struct utsname {
 | 
|---|
| 93 |     char sysname[SYS_NMLN];
 | 
|---|
| 94 |     char nodename[SYS_NMLN];
 | 
|---|
| 95 |     char release[SYS_NMLN];
 | 
|---|
| 96 |     char version[SYS_NMLN];
 | 
|---|
| 97 |     char machine[SYS_NMLN];
 | 
|---|
| 98 | };
 | 
|---|
| 99 | 
 | 
|---|
| 100 | #ifndef START_EXTERN_C
 | 
|---|
| 101 | #undef EXTERN_C
 | 
|---|
| 102 | #ifdef __cplusplus
 | 
|---|
| 103 | #  define START_EXTERN_C extern "C" {
 | 
|---|
| 104 | #  define END_EXTERN_C }
 | 
|---|
| 105 | #  define EXTERN_C extern "C"
 | 
|---|
| 106 | #else
 | 
|---|
| 107 | #  define START_EXTERN_C
 | 
|---|
| 108 | #  define END_EXTERN_C
 | 
|---|
| 109 | #  define EXTERN_C
 | 
|---|
| 110 | #endif
 | 
|---|
| 111 | #endif
 | 
|---|
| 112 | 
 | 
|---|
| 113 | #define  STANDARD_C     1
 | 
|---|
| 114 | #define  DOSISH         1               /* no escaping our roots */
 | 
|---|
| 115 | #define  OP_BINARY      O_BINARY        /* mistake in in pp_sys.c? */
 | 
|---|
| 116 | 
 | 
|---|
| 117 | /* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as
 | 
|---|
| 118 |  * real filehandles. XXX Should always be defined (the other version is untested) */
 | 
|---|
| 119 | #define USE_SOCKETS_AS_HANDLES
 | 
|---|
| 120 | 
 | 
|---|
| 121 | /* read() and write() aren't transparent for socket handles */
 | 
|---|
| 122 | #define PERL_SOCK_SYSREAD_IS_RECV
 | 
|---|
| 123 | #define PERL_SOCK_SYSWRITE_IS_SEND
 | 
|---|
| 124 | 
 | 
|---|
| 125 | #define PERL_NO_FORCE_LINK              /* no need for PL_force_link_funcs */
 | 
|---|
| 126 | 
 | 
|---|
| 127 | /* Define USE_FIXED_OSFHANDLE to fix MSVCRT's _open_osfhandle() on W95.
 | 
|---|
| 128 |    It now uses some black magic to work seamlessly with the DLL CRT and
 | 
|---|
| 129 |    works with MSVC++ 4.0+ or GCC/Mingw32
 | 
|---|
| 130 |         -- BKS 1-24-2000 */
 | 
|---|
| 131 | #if (defined(_M_IX86) && _MSC_VER >= 1000) || defined(__MINGW32__)
 | 
|---|
| 132 | #define USE_FIXED_OSFHANDLE
 | 
|---|
| 133 | #endif
 | 
|---|
| 134 | 
 | 
|---|
| 135 | /* Define PERL_WIN32_SOCK_DLOAD to have Perl dynamically load the winsock
 | 
|---|
| 136 |    DLL when needed. Don't use if your compiler supports delayloading (ie, VC++ 6.0)
 | 
|---|
| 137 |         -- BKS 5-29-2000 */
 | 
|---|
| 138 | #if !(defined(_M_IX86) && _MSC_VER >= 1200)
 | 
|---|
| 139 | #define PERL_WIN32_SOCK_DLOAD
 | 
|---|
| 140 | #endif
 | 
|---|
| 141 | #define ENV_IS_CASELESS
 | 
|---|
| 142 | 
 | 
|---|
| 143 | #define PIPESOCK_MODE   "b"             /* pipes, sockets default to binmode */
 | 
|---|
| 144 | 
 | 
|---|
| 145 | #ifndef VER_PLATFORM_WIN32_WINDOWS      /* VC-2.0 headers don't have this */
 | 
|---|
| 146 | #define VER_PLATFORM_WIN32_WINDOWS      1
 | 
|---|
| 147 | #endif
 | 
|---|
| 148 | 
 | 
|---|
| 149 | #ifndef FILE_SHARE_DELETE               /* VC-4.0 headers don't have this */
 | 
|---|
| 150 | #define FILE_SHARE_DELETE               0x00000004
 | 
|---|
| 151 | #endif
 | 
|---|
| 152 | 
 | 
|---|
| 153 | /* access() mode bits */
 | 
|---|
| 154 | #ifndef R_OK
 | 
|---|
| 155 | #  define       R_OK    4
 | 
|---|
| 156 | #  define       W_OK    2
 | 
|---|
| 157 | #  define       X_OK    1
 | 
|---|
| 158 | #  define       F_OK    0
 | 
|---|
| 159 | #endif
 | 
|---|
| 160 | 
 | 
|---|
| 161 | /* for waitpid() */
 | 
|---|
| 162 | #ifndef WNOHANG
 | 
|---|
| 163 | #  define WNOHANG       1
 | 
|---|
| 164 | #endif
 | 
|---|
| 165 | 
 | 
|---|
| 166 | #define PERL_GET_CONTEXT_DEFINED
 | 
|---|
| 167 | 
 | 
|---|
| 168 | /* Compiler-specific stuff. */
 | 
|---|
| 169 | 
 | 
|---|
| 170 | #ifdef __BORLANDC__             /* Borland C++ */
 | 
|---|
| 171 | 
 | 
|---|
| 172 | #if (__BORLANDC__ <= 0x520)
 | 
|---|
| 173 | #define _access access
 | 
|---|
| 174 | #define _chdir chdir
 | 
|---|
| 175 | #endif
 | 
|---|
| 176 | 
 | 
|---|
| 177 | #define _getpid getpid
 | 
|---|
| 178 | #define wcsicmp _wcsicmp
 | 
|---|
| 179 | #include <sys/types.h>
 | 
|---|
| 180 | 
 | 
|---|
| 181 | #ifndef DllMain
 | 
|---|
| 182 | #define DllMain DllEntryPoint
 | 
|---|
| 183 | #endif
 | 
|---|
| 184 | 
 | 
|---|
| 185 | #pragma warn -ccc       /* "condition is always true/false" */
 | 
|---|
| 186 | #pragma warn -rch       /* "unreachable code" */
 | 
|---|
| 187 | #pragma warn -sig       /* "conversion may lose significant digits" */
 | 
|---|
| 188 | #pragma warn -pia       /* "possibly incorrect assignment" */
 | 
|---|
| 189 | #pragma warn -par       /* "parameter 'foo' is never used" */
 | 
|---|
| 190 | #pragma warn -aus       /* "'foo' is assigned a value that is never used" */
 | 
|---|
| 191 | #pragma warn -use       /* "'foo' is declared but never used" */
 | 
|---|
| 192 | #pragma warn -csu       /* "comparing signed and unsigned values" */
 | 
|---|
| 193 | 
 | 
|---|
| 194 | /* Borland C thinks that a pointer to a member variable is 12 bytes in size. */
 | 
|---|
| 195 | #define PERL_MEMBER_PTR_SIZE    12
 | 
|---|
| 196 | 
 | 
|---|
| 197 | #define isnan           _isnan
 | 
|---|
| 198 | 
 | 
|---|
| 199 | #endif
 | 
|---|
| 200 | 
 | 
|---|
| 201 | #ifdef _MSC_VER                 /* Microsoft Visual C++ */
 | 
|---|
| 202 | 
 | 
|---|
| 203 | typedef long            uid_t;
 | 
|---|
| 204 | typedef long            gid_t;
 | 
|---|
| 205 | typedef unsigned short  mode_t;
 | 
|---|
| 206 | #pragma  warning(disable: 4102) /* "unreferenced label" */
 | 
|---|
| 207 | 
 | 
|---|
| 208 | /* Visual C thinks that a pointer to a member variable is 16 bytes in size. */
 | 
|---|
| 209 | #define PERL_MEMBER_PTR_SIZE    16
 | 
|---|
| 210 | 
 | 
|---|
| 211 | #define isnan           _isnan
 | 
|---|
| 212 | 
 | 
|---|
| 213 | #endif /* _MSC_VER */
 | 
|---|
| 214 | 
 | 
|---|
| 215 | #ifdef __MINGW32__              /* Minimal Gnu-Win32 */
 | 
|---|
| 216 | 
 | 
|---|
| 217 | typedef long            uid_t;
 | 
|---|
| 218 | typedef long            gid_t;
 | 
|---|
| 219 | #ifndef _environ
 | 
|---|
| 220 | #define _environ        environ
 | 
|---|
| 221 | #endif
 | 
|---|
| 222 | #define flushall        _flushall
 | 
|---|
| 223 | #define fcloseall       _fcloseall
 | 
|---|
| 224 | #define isnan           _isnan  /* ...same libraries as MSVC */
 | 
|---|
| 225 | 
 | 
|---|
| 226 | #ifndef _O_NOINHERIT
 | 
|---|
| 227 | #  define _O_NOINHERIT  0x0080
 | 
|---|
| 228 | #  ifndef _NO_OLDNAMES
 | 
|---|
| 229 | #    define O_NOINHERIT _O_NOINHERIT
 | 
|---|
| 230 | #  endif
 | 
|---|
| 231 | #endif
 | 
|---|
| 232 | 
 | 
|---|
| 233 | /* <stdint.h>, pulled in by <io.h> as of mingw-runtime-3.3, typedef's
 | 
|---|
| 234 |  * (u)intptr_t but doesn't set the _(U)INTPTR_T_DEFINED defines */
 | 
|---|
| 235 | #ifdef _STDINT_H
 | 
|---|
| 236 | #  ifndef _INTPTR_T_DEFINED
 | 
|---|
| 237 | #    define _INTPTR_T_DEFINED
 | 
|---|
| 238 | #  endif
 | 
|---|
| 239 | #  ifndef _UINTPTR_T_DEFINED
 | 
|---|
| 240 | #    define _UINTPTR_T_DEFINED
 | 
|---|
| 241 | #  endif
 | 
|---|
| 242 | #endif
 | 
|---|
| 243 | 
 | 
|---|
| 244 | #endif /* __MINGW32__ */
 | 
|---|
| 245 | 
 | 
|---|
| 246 | /* both GCC/Mingw32 and MSVC++ 4.0 are missing this, so we put it here */
 | 
|---|
| 247 | #ifndef CP_UTF8
 | 
|---|
| 248 | #  define CP_UTF8       65001
 | 
|---|
| 249 | #endif
 | 
|---|
| 250 | 
 | 
|---|
| 251 | /* compatibility stuff for other compilers goes here */
 | 
|---|
| 252 | 
 | 
|---|
| 253 | #ifndef _INTPTR_T_DEFINED
 | 
|---|
| 254 | typedef int             intptr_t;
 | 
|---|
| 255 | #  define _INTPTR_T_DEFINED
 | 
|---|
| 256 | #endif
 | 
|---|
| 257 | 
 | 
|---|
| 258 | #ifndef _UINTPTR_T_DEFINED
 | 
|---|
| 259 | typedef unsigned int    uintptr_t;
 | 
|---|
| 260 | #  define _UINTPTR_T_DEFINED
 | 
|---|
| 261 | #endif
 | 
|---|
| 262 | 
 | 
|---|
| 263 | START_EXTERN_C
 | 
|---|
| 264 | 
 | 
|---|
| 265 | /* For UNIX compatibility. */
 | 
|---|
| 266 | 
 | 
|---|
| 267 | extern  uid_t   getuid(void);
 | 
|---|
| 268 | extern  gid_t   getgid(void);
 | 
|---|
| 269 | extern  uid_t   geteuid(void);
 | 
|---|
| 270 | extern  gid_t   getegid(void);
 | 
|---|
| 271 | extern  int     setuid(uid_t uid);
 | 
|---|
| 272 | extern  int     setgid(gid_t gid);
 | 
|---|
| 273 | extern  int     kill(int pid, int sig);
 | 
|---|
| 274 | #ifndef USE_PERL_SBRK
 | 
|---|
| 275 | extern  void    *sbrk(ptrdiff_t need);
 | 
|---|
| 276 | #  define HAS_SBRK_PROTO
 | 
|---|
| 277 | #endif
 | 
|---|
| 278 | extern  char *  getlogin(void);
 | 
|---|
| 279 | extern  int     chown(const char *p, uid_t o, gid_t g);
 | 
|---|
| 280 | extern  int     mkstemp(const char *path);
 | 
|---|
| 281 | 
 | 
|---|
| 282 | #undef   Stat
 | 
|---|
| 283 | #define  Stat           win32_stat
 | 
|---|
| 284 | 
 | 
|---|
| 285 | #undef   init_os_extras
 | 
|---|
| 286 | #define  init_os_extras Perl_init_os_extras
 | 
|---|
| 287 | 
 | 
|---|
| 288 | DllExport void          Perl_win32_init(int *argcp, char ***argvp);
 | 
|---|
| 289 | DllExport void          Perl_win32_term(void);
 | 
|---|
| 290 | DllExport void          Perl_init_os_extras(void);
 | 
|---|
| 291 | DllExport void          win32_str_os_error(void *sv, DWORD err);
 | 
|---|
| 292 | DllExport int           RunPerl(int argc, char **argv, char **env);
 | 
|---|
| 293 | 
 | 
|---|
| 294 | typedef struct {
 | 
|---|
| 295 |     HANDLE      childStdIn;
 | 
|---|
| 296 |     HANDLE      childStdOut;
 | 
|---|
| 297 |     HANDLE      childStdErr;
 | 
|---|
| 298 |     /*
 | 
|---|
| 299 |      * the following correspond to the fields of the same name
 | 
|---|
| 300 |      * in the STARTUPINFO structure. Embedders can use these to
 | 
|---|
| 301 |      * control the spawning process' look.
 | 
|---|
| 302 |      * Example - to hide the window of the spawned process:
 | 
|---|
| 303 |      *    dwFlags = STARTF_USESHOWWINDOW;
 | 
|---|
| 304 |      *    wShowWindow = SW_HIDE;
 | 
|---|
| 305 |      */
 | 
|---|
| 306 |     DWORD       dwFlags;
 | 
|---|
| 307 |     DWORD       dwX;
 | 
|---|
| 308 |     DWORD       dwY;
 | 
|---|
| 309 |     DWORD       dwXSize;
 | 
|---|
| 310 |     DWORD       dwYSize;
 | 
|---|
| 311 |     DWORD       dwXCountChars;
 | 
|---|
| 312 |     DWORD       dwYCountChars;
 | 
|---|
| 313 |     DWORD       dwFillAttribute;
 | 
|---|
| 314 |     WORD        wShowWindow;
 | 
|---|
| 315 | } child_IO_table;
 | 
|---|
| 316 | 
 | 
|---|
| 317 | DllExport void          win32_get_child_IO(child_IO_table* ptr);
 | 
|---|
| 318 | 
 | 
|---|
| 319 | #ifndef USE_SOCKETS_AS_HANDLES
 | 
|---|
| 320 | extern FILE *           my_fdopen(int, char *);
 | 
|---|
| 321 | #endif
 | 
|---|
| 322 | extern int              my_fclose(FILE *);
 | 
|---|
| 323 | extern int              my_fstat(int fd, Stat_t *sbufptr);
 | 
|---|
| 324 | extern char *           win32_get_privlib(const char *pl);
 | 
|---|
| 325 | extern char *           win32_get_sitelib(const char *pl);
 | 
|---|
| 326 | extern char *           win32_get_vendorlib(const char *pl);
 | 
|---|
| 327 | extern int              IsWin95(void);
 | 
|---|
| 328 | extern int              IsWinNT(void);
 | 
|---|
| 329 | extern void             win32_argv2utf8(int argc, char** argv);
 | 
|---|
| 330 | 
 | 
|---|
| 331 | #ifdef PERL_IMPLICIT_SYS
 | 
|---|
| 332 | extern void             win32_delete_internal_host(void *h);
 | 
|---|
| 333 | #endif
 | 
|---|
| 334 | 
 | 
|---|
| 335 | extern char *           staticlinkmodules[];
 | 
|---|
| 336 | 
 | 
|---|
| 337 | END_EXTERN_C
 | 
|---|
| 338 | 
 | 
|---|
| 339 | typedef  char *         caddr_t;        /* In malloc.c (core address). */
 | 
|---|
| 340 | 
 | 
|---|
| 341 | /*
 | 
|---|
| 342 |  * handle socket stuff, assuming socket is always available
 | 
|---|
| 343 |  */
 | 
|---|
| 344 | #include <sys/socket.h>
 | 
|---|
| 345 | #include <netdb.h>
 | 
|---|
| 346 | 
 | 
|---|
| 347 | #ifdef MYMALLOC
 | 
|---|
| 348 | #define EMBEDMYMALLOC   /**/
 | 
|---|
| 349 | /* #define USE_PERL_SBRK        /**/
 | 
|---|
| 350 | /* #define PERL_SBRK_VIA_MALLOC /**/
 | 
|---|
| 351 | #endif
 | 
|---|
| 352 | 
 | 
|---|
| 353 | #if defined(PERLDLL) && !defined(PERL_CORE)
 | 
|---|
| 354 | #define PERL_CORE
 | 
|---|
| 355 | #endif
 | 
|---|
| 356 | 
 | 
|---|
| 357 | #ifdef PERL_TEXTMODE_SCRIPTS
 | 
|---|
| 358 | #  define PERL_SCRIPT_MODE              "r"
 | 
|---|
| 359 | #else
 | 
|---|
| 360 | #  define PERL_SCRIPT_MODE              "rb"
 | 
|---|
| 361 | #endif
 | 
|---|
| 362 | 
 | 
|---|
| 363 | /*
 | 
|---|
| 364 |  * Now Win32 specific per-thread data stuff
 | 
|---|
| 365 |  */
 | 
|---|
| 366 | 
 | 
|---|
| 367 | struct thread_intern {
 | 
|---|
| 368 |     /* XXX can probably use one buffer instead of several */
 | 
|---|
| 369 |     char                Wstrerror_buffer[512];
 | 
|---|
| 370 |     struct servent      Wservent;
 | 
|---|
| 371 |     char                Wgetlogin_buffer[128];
 | 
|---|
| 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 |     BOOL               Wuse_showwindow;
 | 
|---|
| 382 |     WORD               Wshowwindow;
 | 
|---|
| 383 | };
 | 
|---|
| 384 | 
 | 
|---|
| 385 | #ifdef USE_5005THREADS
 | 
|---|
| 386 | #  ifndef USE_DECLSPEC_THREAD
 | 
|---|
| 387 | #    define HAVE_THREAD_INTERN
 | 
|---|
| 388 | #  endif /* !USE_DECLSPEC_THREAD */
 | 
|---|
| 389 | #endif /* USE_5005THREADS */
 | 
|---|
| 390 | 
 | 
|---|
| 391 | #define HAVE_INTERP_INTERN
 | 
|---|
| 392 | typedef struct {
 | 
|---|
| 393 |     long        num;
 | 
|---|
| 394 |     DWORD       pids[MAXIMUM_WAIT_OBJECTS];
 | 
|---|
| 395 |     HANDLE      handles[MAXIMUM_WAIT_OBJECTS];
 | 
|---|
| 396 | } child_tab;
 | 
|---|
| 397 | 
 | 
|---|
| 398 | #ifndef Sighandler_t
 | 
|---|
| 399 | typedef Signal_t (*Sighandler_t) (int);
 | 
|---|
| 400 | #define Sighandler_t    Sighandler_t
 | 
|---|
| 401 | #endif
 | 
|---|
| 402 | 
 | 
|---|
| 403 | struct interp_intern {
 | 
|---|
| 404 |     char *      perlshell_tokens;
 | 
|---|
| 405 |     char **     perlshell_vec;
 | 
|---|
| 406 |     long        perlshell_items;
 | 
|---|
| 407 |     struct av * fdpid;
 | 
|---|
| 408 |     child_tab * children;
 | 
|---|
| 409 | #ifdef USE_ITHREADS
 | 
|---|
| 410 |     DWORD       pseudo_id;
 | 
|---|
| 411 |     child_tab * pseudo_children;
 | 
|---|
| 412 | #endif
 | 
|---|
| 413 |     void *      internal_host;
 | 
|---|
| 414 | #ifndef USE_5005THREADS
 | 
|---|
| 415 |     struct thread_intern        thr_intern;
 | 
|---|
| 416 | #endif
 | 
|---|
| 417 |     UINT        timerid;
 | 
|---|
| 418 |     unsigned    poll_count;
 | 
|---|
| 419 |     Sighandler_t sigtable[SIG_SIZE];
 | 
|---|
| 420 | };
 | 
|---|
| 421 | 
 | 
|---|
| 422 | DllExport int win32_async_check(pTHX);
 | 
|---|
| 423 | 
 | 
|---|
| 424 | #define WIN32_POLL_INTERVAL 32768
 | 
|---|
| 425 | #define PERL_ASYNC_CHECK() if (w32_do_async || PL_sig_pending) win32_async_check(aTHX)
 | 
|---|
| 426 | 
 | 
|---|
| 427 | #define w32_perlshell_tokens    (PL_sys_intern.perlshell_tokens)
 | 
|---|
| 428 | #define w32_perlshell_vec       (PL_sys_intern.perlshell_vec)
 | 
|---|
| 429 | #define w32_perlshell_items     (PL_sys_intern.perlshell_items)
 | 
|---|
| 430 | #define w32_fdpid               (PL_sys_intern.fdpid)
 | 
|---|
| 431 | #define w32_children            (PL_sys_intern.children)
 | 
|---|
| 432 | #define w32_num_children        (w32_children->num)
 | 
|---|
| 433 | #define w32_child_pids          (w32_children->pids)
 | 
|---|
| 434 | #define w32_child_handles       (w32_children->handles)
 | 
|---|
| 435 | #define w32_pseudo_id           (PL_sys_intern.pseudo_id)
 | 
|---|
| 436 | #define w32_pseudo_children     (PL_sys_intern.pseudo_children)
 | 
|---|
| 437 | #define w32_num_pseudo_children         (w32_pseudo_children->num)
 | 
|---|
| 438 | #define w32_pseudo_child_pids           (w32_pseudo_children->pids)
 | 
|---|
| 439 | #define w32_pseudo_child_handles        (w32_pseudo_children->handles)
 | 
|---|
| 440 | #define w32_internal_host               (PL_sys_intern.internal_host)
 | 
|---|
| 441 | #define w32_timerid                     (PL_sys_intern.timerid)
 | 
|---|
| 442 | #define w32_sighandler                  (PL_sys_intern.sigtable)
 | 
|---|
| 443 | #define w32_poll_count                  (PL_sys_intern.poll_count)
 | 
|---|
| 444 | #define w32_do_async                    (w32_poll_count++ > WIN32_POLL_INTERVAL)
 | 
|---|
| 445 | #ifdef USE_5005THREADS
 | 
|---|
| 446 | #  define w32_strerror_buffer   (thr->i.Wstrerror_buffer)
 | 
|---|
| 447 | #  define w32_getlogin_buffer   (thr->i.Wgetlogin_buffer)
 | 
|---|
| 448 | #  define w32_crypt_buffer      (thr->i.Wcrypt_buffer)
 | 
|---|
| 449 | #  define w32_servent           (thr->i.Wservent)
 | 
|---|
| 450 | #  define w32_init_socktype     (thr->i.Winit_socktype)
 | 
|---|
| 451 | #  define w32_use_showwindow    (thr->i.Wuse_showwindow)
 | 
|---|
| 452 | #  define w32_showwindow        (thr->i.Wshowwindow)
 | 
|---|
| 453 | #else
 | 
|---|
| 454 | #  define w32_strerror_buffer   (PL_sys_intern.thr_intern.Wstrerror_buffer)
 | 
|---|
| 455 | #  define w32_getlogin_buffer   (PL_sys_intern.thr_intern.Wgetlogin_buffer)
 | 
|---|
| 456 | #  define w32_crypt_buffer      (PL_sys_intern.thr_intern.Wcrypt_buffer)
 | 
|---|
| 457 | #  define w32_servent           (PL_sys_intern.thr_intern.Wservent)
 | 
|---|
| 458 | #  define w32_init_socktype     (PL_sys_intern.thr_intern.Winit_socktype)
 | 
|---|
| 459 | #  define w32_use_showwindow    (PL_sys_intern.thr_intern.Wuse_showwindow)
 | 
|---|
| 460 | #  define w32_showwindow        (PL_sys_intern.thr_intern.Wshowwindow)
 | 
|---|
| 461 | #endif /* USE_5005THREADS */
 | 
|---|
| 462 | 
 | 
|---|
| 463 | /* UNICODE<>ANSI translation helpers */
 | 
|---|
| 464 | /* Use CP_ACP when mode is ANSI */
 | 
|---|
| 465 | /* Use CP_UTF8 when mode is UTF8 */
 | 
|---|
| 466 | 
 | 
|---|
| 467 | #define A2WHELPER_LEN(lpa, alen, lpw, nBytes)\
 | 
|---|
| 468 |     (lpw[0] = 0, MultiByteToWideChar((IN_BYTES) ? CP_ACP : CP_UTF8, 0, \
 | 
|---|
| 469 |                                     lpa, alen, lpw, (nBytes/sizeof(WCHAR))))
 | 
|---|
| 470 | #define A2WHELPER(lpa, lpw, nBytes)     A2WHELPER_LEN(lpa, -1, lpw, nBytes)
 | 
|---|
| 471 | 
 | 
|---|
| 472 | #define W2AHELPER_LEN(lpw, wlen, lpa, nChars)\
 | 
|---|
| 473 |     (lpa[0] = '\0', WideCharToMultiByte((IN_BYTES) ? CP_ACP : CP_UTF8, 0, \
 | 
|---|
| 474 |                                        lpw, wlen, (LPSTR)lpa, nChars,NULL,NULL))
 | 
|---|
| 475 | #define W2AHELPER(lpw, lpa, nChars)     W2AHELPER_LEN(lpw, -1, lpa, nChars)
 | 
|---|
| 476 | 
 | 
|---|
| 477 | #define USING_WIDE() (0)
 | 
|---|
| 478 | 
 | 
|---|
| 479 | #ifdef USE_ITHREADS
 | 
|---|
| 480 | #  define PERL_WAIT_FOR_CHILDREN \
 | 
|---|
| 481 |     STMT_START {                                                        \
 | 
|---|
| 482 |         if (w32_pseudo_children && w32_num_pseudo_children) {           \
 | 
|---|
| 483 |             long children = w32_num_pseudo_children;                    \
 | 
|---|
| 484 |             WaitForMultipleObjects(children,                            \
 | 
|---|
| 485 |                                    w32_pseudo_child_handles,            \
 | 
|---|
| 486 |                                    TRUE, INFINITE);                     \
 | 
|---|
| 487 |             while (children)                                            \
 | 
|---|
| 488 |                 CloseHandle(w32_pseudo_child_handles[--children]);      \
 | 
|---|
| 489 |         }                                                               \
 | 
|---|
| 490 |     } STMT_END
 | 
|---|
| 491 | #endif
 | 
|---|
| 492 | 
 | 
|---|
| 493 | #if defined(USE_FIXED_OSFHANDLE) || defined(PERL_MSVCRT_READFIX)
 | 
|---|
| 494 | #ifdef PERL_CORE
 | 
|---|
| 495 | 
 | 
|---|
| 496 | /* C doesn't like repeat struct definitions */
 | 
|---|
| 497 | #if defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION>=3)
 | 
|---|
| 498 | #undef _CRTIMP
 | 
|---|
| 499 | #endif
 | 
|---|
| 500 | #ifndef _CRTIMP
 | 
|---|
| 501 | #define _CRTIMP __declspec(dllimport)
 | 
|---|
| 502 | #endif
 | 
|---|
| 503 | 
 | 
|---|
| 504 | /*
 | 
|---|
| 505 |  * Control structure for lowio file handles
 | 
|---|
| 506 |  */
 | 
|---|
| 507 | typedef struct {
 | 
|---|
| 508 |     intptr_t osfhnd;/* underlying OS file HANDLE */
 | 
|---|
| 509 |     char osfile;    /* attributes of file (e.g., open in text mode?) */
 | 
|---|
| 510 |     char pipech;    /* one char buffer for handles opened on pipes */
 | 
|---|
| 511 |     int lockinitflag;
 | 
|---|
| 512 |     CRITICAL_SECTION lock;
 | 
|---|
| 513 | } ioinfo;
 | 
|---|
| 514 | 
 | 
|---|
| 515 | 
 | 
|---|
| 516 | /*
 | 
|---|
| 517 |  * Array of arrays of control structures for lowio files.
 | 
|---|
| 518 |  */
 | 
|---|
| 519 | EXTERN_C _CRTIMP ioinfo* __pioinfo[];
 | 
|---|
| 520 | 
 | 
|---|
| 521 | /*
 | 
|---|
| 522 |  * Definition of IOINFO_L2E, the log base 2 of the number of elements in each
 | 
|---|
| 523 |  * array of ioinfo structs.
 | 
|---|
| 524 |  */
 | 
|---|
| 525 | #define IOINFO_L2E          5
 | 
|---|
| 526 | 
 | 
|---|
| 527 | /*
 | 
|---|
| 528 |  * Definition of IOINFO_ARRAY_ELTS, the number of elements in ioinfo array
 | 
|---|
| 529 |  */
 | 
|---|
| 530 | #define IOINFO_ARRAY_ELTS   (1 << IOINFO_L2E)
 | 
|---|
| 531 | 
 | 
|---|
| 532 | /*
 | 
|---|
| 533 |  * Access macros for getting at an ioinfo struct and its fields from a
 | 
|---|
| 534 |  * file handle
 | 
|---|
| 535 |  */
 | 
|---|
| 536 | #define _pioinfo(i) (__pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
 | 
|---|
| 537 | #define _osfhnd(i)  (_pioinfo(i)->osfhnd)
 | 
|---|
| 538 | #define _osfile(i)  (_pioinfo(i)->osfile)
 | 
|---|
| 539 | #define _pipech(i)  (_pioinfo(i)->pipech)
 | 
|---|
| 540 | 
 | 
|---|
| 541 | /* since we are not doing a dup2(), this works fine */
 | 
|---|
| 542 | #define _set_osfhnd(fh, osfh) (void)(_osfhnd(fh) = (intptr_t)osfh)
 | 
|---|
| 543 | #endif
 | 
|---|
| 544 | #endif
 | 
|---|
| 545 | 
 | 
|---|
| 546 | /* IO.xs and POSIX.xs define PERLIO_NOT_STDIO to 1 */
 | 
|---|
| 547 | #if defined(PERL_EXT_IO) || defined(PERL_EXT_POSIX)
 | 
|---|
| 548 | #undef  PERLIO_NOT_STDIO
 | 
|---|
| 549 | #endif
 | 
|---|
| 550 | #define PERLIO_NOT_STDIO 0
 | 
|---|
| 551 | 
 | 
|---|
| 552 | #include "perlio.h"
 | 
|---|
| 553 | 
 | 
|---|
| 554 | /*
 | 
|---|
| 555 |  * This provides a layer of functions and macros to ensure extensions will
 | 
|---|
| 556 |  * get to use the same RTL functions as the core.
 | 
|---|
| 557 |  */
 | 
|---|
| 558 | #include "win32iop.h"
 | 
|---|
| 559 | 
 | 
|---|
| 560 | #define EXEC_ARGV_CAST(x) ((const char *const *) x)
 | 
|---|
| 561 | 
 | 
|---|
| 562 | #if !defined(ECONNABORTED) && defined(WSAECONNABORTED)
 | 
|---|
| 563 | #define ECONNABORTED WSAECONNABORTED
 | 
|---|
| 564 | #endif
 | 
|---|
| 565 | #if !defined(ECONNRESET) && defined(WSAECONNRESET)
 | 
|---|
| 566 | #define ECONNRESET WSAECONNRESET
 | 
|---|
| 567 | #endif
 | 
|---|
| 568 | #if !defined(EAFNOSUPPORT) && defined(WSAEAFNOSUPPORT)
 | 
|---|
| 569 | #define EAFNOSUPPORT WSAEAFNOSUPPORT
 | 
|---|
| 570 | #endif
 | 
|---|
| 571 | /* Why not needed for ECONNREFUSED? --abe */
 | 
|---|
| 572 | 
 | 
|---|
| 573 | DllExport void *win32_signal_context(void);
 | 
|---|
| 574 | #define PERL_GET_SIG_CONTEXT win32_signal_context()
 | 
|---|
| 575 | 
 | 
|---|
| 576 | #endif /* _INC_WIN32_PERL5 */
 | 
|---|
| 577 | 
 | 
|---|