This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Explicitly use and check for FD_CLOEXEC.
[perl5.git] / win32 / win32.h
1 /* WIN32.H
2  *
3  * (c) 1995 Microsoft Corporation. All rights reserved.
4  *              Developed by hip communications inc.
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 0x0500     /* needed for CreateHardlink() etc. */
14 #endif
15
16 /* Win32 only optimizations for faster building */
17 #ifdef PERL_IS_MINIPERL
18 /* this macro will remove Winsock only on miniperl, PERL_IMPLICIT_SYS and
19  * makedef.pl create dependencies that will keep Winsock linked in even with
20  * this macro defined, even though sockets will be umimplemented from a script
21  * level in full perl
22  */
23 #  define WIN32_NO_SOCKETS
24 /* less I/O calls during each require */
25 #  define PERL_DISABLE_PMC
26
27 /* allow minitest to work */
28 #  define PERL_TEXTMODE_SCRIPTS
29 #endif
30
31 #ifdef WIN32_NO_SOCKETS
32 #  undef HAS_SOCKET
33 #  undef HAS_GETPROTOBYNAME
34 #  undef HAS_GETPROTOBYNUMBER
35 #  undef HAS_GETPROTOENT
36 #  undef HAS_GETNETBYNAME
37 #  undef HAS_GETNETBYADDR
38 #  undef HAS_GETNETENT
39 #  undef HAS_GETSERVBYNAME
40 #  undef HAS_GETSERVBYPORT
41 #  undef HAS_GETSERVENT
42 #  undef HAS_GETHOSTBYNAME
43 #  undef HAS_GETHOSTBYADDR
44 #  undef HAS_GETHOSTENT
45 #  undef HAS_SELECT
46 #  undef HAS_IOCTL
47 #  undef HAS_NTOHL
48 #  undef HAS_HTONL
49 #  undef HAS_HTONS
50 #  undef HAS_NTOHS
51 #  define WIN32SCK_IS_STDSCK
52 #endif
53
54 #if defined(PERL_IMPLICIT_SYS)
55 #  define DYNAMIC_ENV_FETCH
56 #  define HAS_GETENV_LEN
57 #  define prime_env_iter()
58 #  define WIN32IO_IS_STDIO              /* don't pull in custom stdio layer */
59 #  define WIN32SCK_IS_STDSCK            /* don't pull in custom wsock layer */
60 #  ifdef PERL_GLOBAL_STRUCT
61 #    error PERL_GLOBAL_STRUCT cannot be defined with PERL_IMPLICIT_SYS
62 #  endif
63 #endif
64
65 #ifdef __GNUC__
66 #  ifndef __int64               /* some versions seem to #define it already */
67 #    define __int64 long long
68 #  endif
69 #  define Win32_Winsock
70 #ifdef __cplusplus
71 /* Mingw32 gcc -xc++ objects to __attribute((unused)) at least */
72 #undef  PERL_UNUSED_DECL
73 #define PERL_UNUSED_DECL
74 #endif
75 #endif
76
77
78 /* Define DllExport akin to perl's EXT,
79  * If we are in the DLL then Export the symbol,
80  * otherwise import it.
81  */
82
83 /* now even GCC supports __declspec() */
84 /* miniperl has no reason to export anything */
85 #if defined(PERL_IS_MINIPERL) && !defined(UNDER_CE) && defined(_MSC_VER)
86 #  define DllExport
87 #else
88 #  if defined(PERLDLL)
89 #    define DllExport __declspec(dllexport)
90 #  else
91 #    define DllExport __declspec(dllimport)
92 #  endif
93 #endif
94
95 /* The Perl APIs can only be called directly inside the perl5xx.dll.
96  * All other code has to import them.  By declaring them as "dllimport"
97  * we tell the compiler to generate an indirect call instruction and
98  * avoid redirection through a call thunk.
99  *
100  * The XS code in the re extension is special, in that it redefines
101  * core APIs locally, so don't mark them as "dllimport" because GCC
102  * cannot handle this situation.
103  */
104 #if !defined(PERLDLL) && !defined(PERL_EXT_RE_BUILD)
105 #  ifdef __cplusplus
106 #    define PERL_CALLCONV extern "C" __declspec(dllimport)
107 #    ifdef _MSC_VER
108 #      define PERL_CALLCONV_NO_RET extern "C" __declspec(dllimport) __declspec(noreturn)
109 #    endif
110 #  else
111 #    define PERL_CALLCONV __declspec(dllimport)
112 #    ifdef _MSC_VER
113 #      define PERL_CALLCONV_NO_RET __declspec(dllimport) __declspec(noreturn)
114 #    endif
115 #  endif
116 #else /* MSVC noreturn support inside the interp */
117 #  ifdef _MSC_VER
118 #    define PERL_CALLCONV_NO_RET __declspec(noreturn)
119 #  endif
120 #endif
121
122 #ifdef _MSC_VER
123 #  define PERL_STATIC_NO_RET __declspec(noreturn) static
124 #  define PERL_STATIC_INLINE_NO_RET __declspec(noreturn) PERL_STATIC_INLINE
125 #endif
126
127 #define  WIN32_LEAN_AND_MEAN
128 #include <windows.h>
129
130 /*
131  * Bug in winbase.h in mingw-w64 4.4.0-1 at least... they
132  * do #define GetEnvironmentStringsA GetEnvironmentStrings and fail
133  * to declare GetEnvironmentStringsA.
134  */
135 #if defined(__MINGW64__) && defined(GetEnvironmentStringsA) && !defined(UNICODE)
136 #ifdef __cplusplus
137 extern "C" {
138 #endif
139 #undef GetEnvironmentStringsA
140 WINBASEAPI LPCH WINAPI GetEnvironmentStringsA(VOID);
141 #define GetEnvironmentStrings GetEnvironmentStringsA
142 #ifdef __cplusplus
143 }
144 #endif
145 #endif
146
147 #ifdef   WIN32_LEAN_AND_MEAN            /* C file is NOT a Perl5 original. */
148 #define  CONTEXT        PERL_CONTEXT    /* Avoid conflict of CONTEXT defs. */
149 #endif /*WIN32_LEAN_AND_MEAN */
150
151 #ifndef TLS_OUT_OF_INDEXES
152 #define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
153 #endif
154
155 #include <dirent.h>
156 #include <io.h>
157 #include <process.h>
158 #include <stdio.h>
159 #include <direct.h>
160 #include <stdlib.h>
161 #include <stddef.h>
162 #include <fcntl.h>
163 #ifndef EXT
164 #include "EXTERN.h"
165 #endif
166
167 struct tms {
168         long    tms_utime;
169         long    tms_stime;
170         long    tms_cutime;
171         long    tms_cstime;
172 };
173
174 #ifndef SYS_NMLN
175 #define SYS_NMLN        257
176 #endif
177
178 struct utsname {
179     char sysname[SYS_NMLN];
180     char nodename[SYS_NMLN];
181     char release[SYS_NMLN];
182     char version[SYS_NMLN];
183     char machine[SYS_NMLN];
184 };
185
186 #ifndef START_EXTERN_C
187 #undef EXTERN_C
188 #ifdef __cplusplus
189 #  define START_EXTERN_C extern "C" {
190 #  define END_EXTERN_C }
191 #  define EXTERN_C extern "C"
192 #else
193 #  define START_EXTERN_C
194 #  define END_EXTERN_C
195 #  define EXTERN_C
196 #endif
197 #endif
198
199 #define  STANDARD_C     1
200 #define  DOSISH         1               /* no escaping our roots */
201 #define  OP_BINARY      O_BINARY        /* mistake in in pp_sys.c? */
202
203 /* read() and write() aren't transparent for socket handles */
204 #ifndef WIN32_NO_SOCKETS
205 #  define PERL_SOCK_SYSREAD_IS_RECV
206 #  define PERL_SOCK_SYSWRITE_IS_SEND
207 #endif
208
209 #define PERL_NO_FORCE_LINK              /* no need for PL_force_link_funcs */
210
211 #define ENV_IS_CASELESS
212
213 #define PIPESOCK_MODE   "b"             /* pipes, sockets default to binmode */
214
215 /* access() mode bits */
216 #ifndef R_OK
217 #  define       R_OK    4
218 #  define       W_OK    2
219 #  define       X_OK    1
220 #  define       F_OK    0
221 #endif
222
223 /* for waitpid() */
224 #ifndef WNOHANG
225 #  define WNOHANG       1
226 #endif
227
228 #define PERL_GET_CONTEXT_DEFINED
229
230 /* Compiler-specific stuff. */
231
232 /* VC uses non-standard way to determine the size and alignment if bit-fields */
233 /* MinGW will compile with -mms-bitfields, so should use the same types */
234 #define PERL_BITFIELD8  unsigned char
235 #define PERL_BITFIELD16 unsigned short
236 #define PERL_BITFIELD32 unsigned int
237
238 #ifdef _MSC_VER                 /* Microsoft Visual C++ */
239
240 #ifndef UNDER_CE
241 typedef long            uid_t;
242 typedef long            gid_t;
243 typedef unsigned short  mode_t;
244 #endif
245
246 #if _MSC_VER < 1800
247 #define isnan           _isnan  /* Defined already in VC++ 12.0 */
248 #endif
249 #ifdef UNDER_CE /* revisit what function this becomes celib vs corelibc, prv warning here*/
250 #  undef snprintf
251 #endif
252 #define snprintf        _snprintf
253 #define vsnprintf       _vsnprintf
254
255 /* on VC2003, msvcrt.lib is missing these symbols */
256 #if _MSC_VER >= 1300 && _MSC_VER < 1400
257 #  pragma intrinsic(_rotl64,_rotr64)
258 #endif
259
260 #  pragma warning(push)
261 #  pragma warning(disable:4756;disable:4056)
262 PERL_STATIC_INLINE
263 double S_Infinity() {
264     /* this is a real C literal which can get further constant folded
265        unlike using HUGE_VAL/_HUGE which are data symbol imports from the CRT
266        and therefore can not by folded by VC, an example of constant
267        folding INF is creating -INF */
268     return (DBL_MAX+DBL_MAX);
269 }
270 #  pragma warning(pop)
271 #  define NV_INF S_Infinity()
272
273 /* selectany allows duplicate and unused data symbols to be removed by
274    VC linker, if this were static, each translation unit will have its own,
275    usually unused __PL_nan_u, if this were plain extern it will cause link
276    to fail due to multiple definitions, since we dont know if we are being
277    compiled as static or DLL XS, selectany simply always works, the cost of
278    importing __PL_nan_u across DLL boundaries in size in the importing DLL
279    will be more than the 8 bytes it will take up being in each XS DLL if
280    that DLL actually uses __PL_nan_u */
281 extern const __declspec(selectany) union { unsigned __int64 __q; double __d; }
282 __PL_nan_u = { 0x7FF8000000000000UI64 };
283 #  define NV_NAN ((NV)__PL_nan_u.__d)
284
285 #endif /* _MSC_VER */
286
287 #ifdef __MINGW32__              /* Minimal Gnu-Win32 */
288
289 typedef long            uid_t;
290 typedef long            gid_t;
291 #ifndef _environ
292 #define _environ        environ
293 #endif
294 #define flushall        _flushall
295 #define fcloseall       _fcloseall
296 #ifndef isnan
297 #define isnan           _isnan  /* ...same libraries as MSVC */
298 #endif
299
300 #ifndef _O_NOINHERIT
301 #  define _O_NOINHERIT  0x0080
302 #  ifndef _NO_OLDNAMES
303 #    define O_NOINHERIT _O_NOINHERIT
304 #  endif
305 #endif
306
307 /* <stdint.h>, pulled in by <io.h> as of mingw-runtime-3.3, typedef's
308  * (u)intptr_t but doesn't set the _(U)INTPTR_T_DEFINED defines */
309 #ifdef _STDINT_H
310 #  ifndef _INTPTR_T_DEFINED
311 #    define _INTPTR_T_DEFINED
312 #  endif
313 #  ifndef _UINTPTR_T_DEFINED
314 #    define _UINTPTR_T_DEFINED
315 #  endif
316 #endif
317
318 #ifndef CP_UTF8
319 #  define CP_UTF8       65001
320 #endif
321
322 #endif /* __MINGW32__ */
323
324 #ifndef _INTPTR_T_DEFINED
325 typedef int             intptr_t;
326 #  define _INTPTR_T_DEFINED
327 #endif
328
329 #ifndef _UINTPTR_T_DEFINED
330 typedef unsigned int    uintptr_t;
331 #  define _UINTPTR_T_DEFINED
332 #endif
333
334 START_EXTERN_C
335
336 /* For UNIX compatibility. */
337
338 #ifdef PERL_CORE
339 extern  uid_t   getuid(void);
340 extern  gid_t   getgid(void);
341 extern  uid_t   geteuid(void);
342 extern  gid_t   getegid(void);
343 extern  int     setuid(uid_t uid);
344 extern  int     setgid(gid_t gid);
345 extern  int     kill(int pid, int sig);
346 #ifndef USE_PERL_SBRK
347 extern  void    *sbrk(ptrdiff_t need);
348 #  define HAS_SBRK_PROTO
349 #endif
350 extern  char *  getlogin(void);
351 extern  int     chown(const char *p, uid_t o, gid_t g);
352 #if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 4
353 extern  int     mkstemp(const char *path);
354 #endif
355 #endif
356
357 #undef   Stat
358 #define  Stat           win32_stat
359
360 #undef   init_os_extras
361 #define  init_os_extras Perl_init_os_extras
362
363 DllExport void          Perl_win32_init(int *argcp, char ***argvp);
364 DllExport void          Perl_win32_term(void);
365 DllExport void          Perl_init_os_extras(void);
366 DllExport void          win32_str_os_error(void *sv, DWORD err);
367 DllExport int           RunPerl(int argc, char **argv, char **env);
368
369 typedef struct {
370     HANDLE      childStdIn;
371     HANDLE      childStdOut;
372     HANDLE      childStdErr;
373     /*
374      * the following correspond to the fields of the same name
375      * in the STARTUPINFO structure. Embedders can use these to
376      * control the spawning process' look.
377      * Example - to hide the window of the spawned process:
378      *    dwFlags = STARTF_USESHOWWINDOW;
379      *    wShowWindow = SW_HIDE;
380      */
381     DWORD       dwFlags;
382     DWORD       dwX;
383     DWORD       dwY;
384     DWORD       dwXSize;
385     DWORD       dwYSize;
386     DWORD       dwXCountChars;
387     DWORD       dwYCountChars;
388     DWORD       dwFillAttribute;
389     WORD        wShowWindow;
390 } child_IO_table;
391
392 DllExport void          win32_get_child_IO(child_IO_table* ptr);
393 DllExport HWND          win32_create_message_window(void);
394 DllExport int           win32_async_check(pTHX);
395
396 extern int              my_fclose(FILE *);
397 extern char *           win32_get_privlib(const char *pl, STRLEN *const len);
398 extern char *           win32_get_sitelib(const char *pl, STRLEN *const len);
399 extern char *           win32_get_vendorlib(const char *pl, STRLEN *const len);
400
401 #ifdef PERL_IMPLICIT_SYS
402 extern void             win32_delete_internal_host(void *h);
403 #endif
404
405 extern int              win32_get_errno(int err);
406
407 extern const char * const               staticlinkmodules[];
408
409 END_EXTERN_C
410
411 typedef  char *         caddr_t;        /* In malloc.c (core address). */
412
413 /*
414  * handle socket stuff, assuming socket is always available
415  */
416 #include <sys/socket.h>
417 #include <netdb.h>
418
419 #ifdef MYMALLOC
420 #define EMBEDMYMALLOC   /**/
421 /* #define USE_PERL_SBRK        / **/
422 /* #define PERL_SBRK_VIA_MALLOC / **/
423 #endif
424
425 #ifdef PERL_TEXTMODE_SCRIPTS
426 #  define PERL_SCRIPT_MODE              "r"
427 #else
428 #  define PERL_SCRIPT_MODE              "rb"
429 #endif
430
431 /*
432  * Now Win32 specific per-thread data stuff
433  */
434
435 /* Leave the first couple ids after WM_USER unused because they
436  * might be used by an embedding application, and on Windows
437  * version before 2000 we might end up eating those messages
438  * if they were not meant for us.
439  */
440 #define WM_USER_MIN     (WM_USER+30)
441 #define WM_USER_MESSAGE (WM_USER_MIN)
442 #define WM_USER_KILL    (WM_USER_MIN+1)
443 #define WM_USER_MAX     (WM_USER_MIN+1)
444
445 struct thread_intern {
446     /* XXX can probably use one buffer instead of several */
447     char                Wstrerror_buffer[512];
448     struct servent      Wservent;
449     char                Wgetlogin_buffer[128];
450     int                 Winit_socktype;
451     char                Wcrypt_buffer[30];
452 #    ifdef USE_RTL_THREAD_API
453     void *              retv;   /* slot for thread return value */
454 #    endif
455     BOOL               Wuse_showwindow;
456     WORD               Wshowwindow;
457 };
458
459 #define HAVE_INTERP_INTERN
460 typedef struct {
461     long        num;
462     DWORD       pids[MAXIMUM_WAIT_OBJECTS];
463     HANDLE      handles[MAXIMUM_WAIT_OBJECTS];
464 } child_tab;
465
466 #ifdef USE_ITHREADS
467 typedef struct {
468     long        num;
469     DWORD       pids[MAXIMUM_WAIT_OBJECTS];
470     HANDLE      handles[MAXIMUM_WAIT_OBJECTS];
471     HWND        message_hwnds[MAXIMUM_WAIT_OBJECTS];
472     char        sigterm[MAXIMUM_WAIT_OBJECTS];
473 } pseudo_child_tab;
474 #endif
475
476 #ifndef Sighandler_t
477 typedef Signal_t (*Sighandler_t) (int);
478 #define Sighandler_t    Sighandler_t
479 #endif
480
481 struct interp_intern {
482     char *      perlshell_tokens;
483     char **     perlshell_vec;
484     long        perlshell_items;
485     struct av * fdpid;
486     child_tab * children;
487 #ifdef USE_ITHREADS
488     DWORD       pseudo_id;
489     pseudo_child_tab * pseudo_children;
490 #endif
491     void *      internal_host;
492     struct thread_intern        thr_intern;
493     HWND        message_hwnd;
494     UINT        timerid;
495     unsigned    poll_count;
496     Sighandler_t sigtable[SIG_SIZE];
497 };
498
499 #define WIN32_POLL_INTERVAL 32768
500 #define PERL_ASYNC_CHECK() if (w32_do_async || PL_sig_pending) win32_async_check(aTHX)
501
502 #define w32_perlshell_tokens    (PL_sys_intern.perlshell_tokens)
503 #define w32_perlshell_vec       (PL_sys_intern.perlshell_vec)
504 #define w32_perlshell_items     (PL_sys_intern.perlshell_items)
505 #define w32_fdpid               (PL_sys_intern.fdpid)
506 #define w32_children            (PL_sys_intern.children)
507 #define w32_num_children        (w32_children->num)
508 #define w32_child_pids          (w32_children->pids)
509 #define w32_child_handles       (w32_children->handles)
510 #define w32_pseudo_id           (PL_sys_intern.pseudo_id)
511 #define w32_pseudo_children     (PL_sys_intern.pseudo_children)
512 #define w32_num_pseudo_children         (w32_pseudo_children->num)
513 #define w32_pseudo_child_pids           (w32_pseudo_children->pids)
514 #define w32_pseudo_child_handles        (w32_pseudo_children->handles)
515 #define w32_pseudo_child_message_hwnds  (w32_pseudo_children->message_hwnds)
516 #define w32_pseudo_child_sigterm        (w32_pseudo_children->sigterm)
517 #define w32_internal_host               (PL_sys_intern.internal_host)
518 #define w32_timerid                     (PL_sys_intern.timerid)
519 #define w32_message_hwnd                (PL_sys_intern.message_hwnd)
520 #define w32_sighandler                  (PL_sys_intern.sigtable)
521 #define w32_poll_count                  (PL_sys_intern.poll_count)
522 #define w32_do_async                    (w32_poll_count++ > WIN32_POLL_INTERVAL)
523 #define w32_strerror_buffer     (PL_sys_intern.thr_intern.Wstrerror_buffer)
524 #define w32_getlogin_buffer     (PL_sys_intern.thr_intern.Wgetlogin_buffer)
525 #define w32_crypt_buffer        (PL_sys_intern.thr_intern.Wcrypt_buffer)
526 #define w32_servent             (PL_sys_intern.thr_intern.Wservent)
527 #define w32_init_socktype       (PL_sys_intern.thr_intern.Winit_socktype)
528 #define w32_use_showwindow      (PL_sys_intern.thr_intern.Wuse_showwindow)
529 #define w32_showwindow  (PL_sys_intern.thr_intern.Wshowwindow)
530
531 #ifdef USE_ITHREADS
532 void win32_wait_for_children(pTHX);
533 #  define PERL_WAIT_FOR_CHILDREN win32_wait_for_children(aTHX)
534 #endif
535
536 #ifdef PERL_CORE
537 /* C doesn't like repeat struct definitions */
538 #if defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION>=3)
539 #undef _CRTIMP
540 #endif
541 #ifndef _CRTIMP
542 #define _CRTIMP __declspec(dllimport)
543 #endif
544
545
546 /* VV 2005 has multiple ioinfo struct definitions through VC 2005's release life
547  * VC 2008-2012 have been stable but do not assume future VCs will have the
548  * same ioinfo struct, just because past struct stability. If research is done
549  * on the CRTs of future VS, the version check can be bumped up so the newer
550  * VC uses a fixed ioinfo size.
551  */
552 #if ! (_MSC_VER < 1400 || (_MSC_VER >= 1500 && _MSC_VER <= 1700) \
553   || defined(__MINGW32__))
554 /* size of ioinfo struct is determined at runtime */
555 #  define WIN32_DYN_IOINFO_SIZE
556 #endif
557
558 #ifndef WIN32_DYN_IOINFO_SIZE
559 /*
560  * Control structure for lowio file handles
561  */
562 typedef struct {
563     intptr_t osfhnd;/* underlying OS file HANDLE */
564     char osfile;    /* attributes of file (e.g., open in text mode?) */
565     char pipech;    /* one char buffer for handles opened on pipes */
566     int lockinitflag;
567     CRITICAL_SECTION lock;
568 /* this struct definition breaks ABI compatibility with
569  * not using, cl.exe's native VS version specitfic CRT. */
570 #  if _MSC_VER >= 1400 && _MSC_VER < 1500
571 #    error "This ioinfo struct is incomplete for Visual C 2005"
572 #  endif
573 /* VC 2005 CRT has at least 3 different definitions of this struct based on the
574  * CRT DLL's build number. */
575 #  if _MSC_VER >= 1500
576 #    ifndef _SAFECRT_IMPL
577     /* Not used in the safecrt downlevel. We do not define them, so we cannot
578      * use them accidentally */
579     char textmode : 7;/* __IOINFO_TM_ANSI or __IOINFO_TM_UTF8 or __IOINFO_TM_UTF16LE */
580     char unicode : 1; /* Was the file opened as unicode? */
581     char pipech2[2];  /* 2 more peak ahead chars for UNICODE mode */
582     __int64 startpos;      /* File position that matches buffer start */
583     BOOL utf8translations; /* Buffer contains translations other than CRLF*/
584     char dbcsBuffer;       /* Buffer for the lead byte of dbcs when converting from dbcs to unicode */
585     BOOL dbcsBufferUsed;   /* Bool for the lead byte buffer is used or not */
586 #    endif
587 #  endif
588 } ioinfo;
589 #else
590 typedef intptr_t ioinfo;
591 #endif
592
593 /*
594  * Array of arrays of control structures for lowio files.
595  */
596 EXTERN_C _CRTIMP ioinfo* __pioinfo[];
597
598 /*
599  * Definition of IOINFO_L2E, the log base 2 of the number of elements in each
600  * array of ioinfo structs.
601  */
602 #define IOINFO_L2E          5
603
604 /*
605  * Definition of IOINFO_ARRAY_ELTS, the number of elements in ioinfo array
606  */
607 #define IOINFO_ARRAY_ELTS   (1 << IOINFO_L2E)
608
609 /*
610  * Access macros for getting at an ioinfo struct and its fields from a
611  * file handle
612  */
613 #ifdef WIN32_DYN_IOINFO_SIZE
614 #  define _pioinfo(i) ((intptr_t *) \
615      (((Size_t)__pioinfo[(i) >> IOINFO_L2E])/* * to head of array ioinfo [] */\
616       /* offset to the head of a particular ioinfo struct */ \
617       + (((i) & (IOINFO_ARRAY_ELTS - 1)) * w32_ioinfo_size)) \
618    )
619 /* first slice of ioinfo is always the OS handle */
620 #  define _osfhnd(i)  (*(_pioinfo(i)))
621 #else
622 #  define _pioinfo(i) (__pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
623 #  define _osfhnd(i)  (_pioinfo(i)->osfhnd)
624 #endif
625
626 /* since we are not doing a dup2(), this works fine */
627 #  define _set_osfhnd(fh, osfh) (void)(_osfhnd(fh) = (intptr_t)osfh)
628 #endif /* PERL_CORE */
629
630 /* IO.xs and POSIX.xs define PERLIO_NOT_STDIO to 1 */
631 #if defined(PERL_EXT_IO) || defined(PERL_EXT_POSIX)
632 #undef  PERLIO_NOT_STDIO
633 #endif
634 #define PERLIO_NOT_STDIO 0
635
636 #define EXEC_ARGV_CAST(x) ((const char *const *) x)
637
638 DllExport void *win32_signal_context(void);
639 #define PERL_GET_SIG_CONTEXT win32_signal_context()
640
641 #ifdef UNDER_CE
642 #define Win_GetModuleHandle   XCEGetModuleHandleA
643 #define Win_GetProcAddress    XCEGetProcAddressA
644 #define Win_GetModuleFileName XCEGetModuleFileNameA
645 #define Win_CreateSemaphore   CreateSemaphoreW
646 #else
647 #define Win_GetModuleHandle   GetModuleHandle
648 #define Win_GetProcAddress    GetProcAddress
649 #define Win_GetModuleFileName GetModuleFileName
650 #define Win_CreateSemaphore   CreateSemaphore
651 #endif
652
653 #endif /* _INC_WIN32_PERL5 */
654