This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #78334] keys(@x) should be in perl5120delta.pod
[perl5.git] / win32 / win32.h
CommitLineData
68dc0745
PP
1/* WIN32.H
2 *
3fadfdf1 3 * (c) 1995 Microsoft Corporation. All rights reserved.
0d130a44 4 * Developed by hip communications inc.
68dc0745
PP
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 */
0a753a76
PP
9#ifndef _INC_WIN32_PERL5
10#define _INC_WIN32_PERL5
11
5db10396
GS
12#ifndef _WIN32_WINNT
13# define _WIN32_WINNT 0x0400 /* needed for TryEnterCriticalSection() etc. */
14#endif
638eceb6 15
acfe0abc 16#if defined(PERL_IMPLICIT_SYS)
e9ee4811 17# define DYNAMIC_ENV_FETCH
a6c40364 18# define HAS_GETENV_LEN
e9ee4811 19# define prime_env_iter()
ab39fa9d 20# define WIN32IO_IS_STDIO /* don't pull in custom stdio layer */
c5be433b 21# define WIN32SCK_IS_STDSCK /* don't pull in custom wsock layer */
ab39fa9d 22# ifdef PERL_GLOBAL_STRUCT
32e30700 23# error PERL_GLOBAL_STRUCT cannot be defined with PERL_IMPLICIT_SYS
ab39fa9d 24# endif
e5a95ffb 25# define win32_get_privlib PerlEnv_lib_path
ab39fa9d 26# define win32_get_sitelib PerlEnv_sitelib_path
4ea817c6 27# define win32_get_vendorlib PerlEnv_vendorlib_path
9d8a25dc
DL
28#endif
29
a835ef8a 30#ifdef __GNUC__
b7c82df9
GS
31# ifndef __int64 /* some versions seem to #define it already */
32# define __int64 long long
33# endif
db15561c 34# define Win32_Winsock
1c85e96a
NIS
35#ifdef __cplusplus
36/* Mingw32 gcc -xc++ objects to __attribute((unused)) at least */
3fadfdf1
NIS
37#undef PERL_UNUSED_DECL
38#define PERL_UNUSED_DECL
a835ef8a 39#endif
1c85e96a
NIS
40#endif
41
a835ef8a 42
3fadfdf1 43/* Define DllExport akin to perl's EXT,
22239a37 44 * If we are in the DLL or mimicing the DLL for Win95 work round
3fadfdf1 45 * then Export the symbol,
22239a37
NIS
46 * otherwise import it.
47 */
48
5db10396
GS
49/* now even GCC supports __declspec() */
50
22239a37 51#if defined(PERLDLL) || defined(WIN95FIX)
852c2e52
GS
52#define DllExport
53/*#define DllExport __declspec(dllexport)*/ /* noises with VC5+sp3 */
3fadfdf1 54#else
22239a37
NIS
55#define DllExport __declspec(dllimport)
56#endif
c69f112c 57
ad6ab6c5
JD
58#ifndef PERL_CORE
59# ifdef __cplusplus
60# define PERL_CALLCONV extern "C" __declspec(dllimport)
61# else
62# define PERL_CALLCONV __declspec(dllimport)
63# endif
64#endif
65
0a753a76
PP
66#define WIN32_LEAN_AND_MEAN
67#include <windows.h>
68
fa58a56f
S
69/*
70 * Bug in winbase.h in mingw-w64 4.4.0-1 at least... they
71 * do #define GetEnvironmentStringsA GetEnvironmentStrings and fail
72 * to declare GetEnvironmentStringsA.
73 */
74#if defined(__MINGW64__) && defined(GetEnvironmentStringsA) && !defined(UNICODE)
75#ifdef __cplusplus
76extern "C" {
77#endif
78#undef GetEnvironmentStringsA
79WINBASEAPI LPCH WINAPI GetEnvironmentStringsA(VOID);
80#define GetEnvironmentStrings GetEnvironmentStringsA
81#ifdef __cplusplus
82}
83#endif
84#endif
85
68dc0745
PP
86#ifdef WIN32_LEAN_AND_MEAN /* C file is NOT a Perl5 original. */
87#define CONTEXT PERL_CONTEXT /* Avoid conflict of CONTEXT defs. */
68dc0745 88#endif /*WIN32_LEAN_AND_MEAN */
0a753a76 89
eda5ff31
GS
90#ifndef TLS_OUT_OF_INDEXES
91#define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
92#endif
93
0a753a76
PP
94#include <dirent.h>
95#include <io.h>
96#include <process.h>
97#include <stdio.h>
98#include <direct.h>
390b85e7 99#include <stdlib.h>
c623ac67 100#include <stddef.h>
7a1f88ac 101#include <fcntl.h>
390b85e7
GS
102#ifndef EXT
103#include "EXTERN.h"
104#endif
105
c69f112c
NIS
106struct tms {
107 long tms_utime;
108 long tms_stime;
109 long tms_cutime;
110 long tms_cstime;
111};
112
b2af26b1
GS
113#ifndef SYS_NMLN
114#define SYS_NMLN 257
115#endif
116
117struct utsname {
118 char sysname[SYS_NMLN];
119 char nodename[SYS_NMLN];
120 char release[SYS_NMLN];
121 char version[SYS_NMLN];
122 char machine[SYS_NMLN];
123};
124
390b85e7 125#ifndef START_EXTERN_C
b3e5c95e 126#undef EXTERN_C
390b85e7
GS
127#ifdef __cplusplus
128# define START_EXTERN_C extern "C" {
129# define END_EXTERN_C }
130# define EXTERN_C extern "C"
131#else
3fadfdf1
NIS
132# define START_EXTERN_C
133# define END_EXTERN_C
390b85e7
GS
134# define EXTERN_C
135#endif
136#endif
137
138#define STANDARD_C 1
139#define DOSISH 1 /* no escaping our roots */
140#define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */
0a753a76 141
f3986ebb
GS
142/* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as
143 * real filehandles. XXX Should always be defined (the other version is untested) */
144#define USE_SOCKETS_AS_HANDLES
145
a7092146
GS
146/* read() and write() aren't transparent for socket handles */
147#define PERL_SOCK_SYSREAD_IS_RECV
148#define PERL_SOCK_SYSWRITE_IS_SEND
149
682fc664 150#define PERL_NO_FORCE_LINK /* no need for PL_force_link_funcs */
a7092146 151
9e5f57de
GS
152/* Define USE_FIXED_OSFHANDLE to fix MSVCRT's _open_osfhandle() on W95.
153 It now uses some black magic to work seamlessly with the DLL CRT and
154 works with MSVC++ 4.0+ or GCC/Mingw32
d67249f4
SH
155 -- BKS 1-24-2000
156 Only use this fix for VC++ 6.x or earlier (and for GCC, which we assume
157 uses MSVCRT.DLL). Later versions use MSVCR70.dll, MSVCR71.dll, etc, which
158 do not require the fix. */
159#if (defined(_M_IX86) && _MSC_VER >= 1000 && _MSC_VER <= 1200) || defined(__MINGW32__)
f3986ebb
GS
160#define USE_FIXED_OSFHANDLE
161#endif
162
6940069f
GS
163/* Define PERL_WIN32_SOCK_DLOAD to have Perl dynamically load the winsock
164 DLL when needed. Don't use if your compiler supports delayloading (ie, VC++ 6.0)
165 -- BKS 5-29-2000 */
166#if !(defined(_M_IX86) && _MSC_VER >= 1200)
167#define PERL_WIN32_SOCK_DLOAD
168#endif
902173a3
GS
169#define ENV_IS_CASELESS
170
479b2847
GS
171#define PIPESOCK_MODE "b" /* pipes, sockets default to binmode */
172
d41de25a 173#ifndef VER_PLATFORM_WIN32_WINDOWS /* VC-2.0 headers don't have this */
f3986ebb
GS
174#define VER_PLATFORM_WIN32_WINDOWS 1
175#endif
176
d41de25a
GS
177#ifndef FILE_SHARE_DELETE /* VC-4.0 headers don't have this */
178#define FILE_SHARE_DELETE 0x00000004
179#endif
180
327c3667
GS
181/* access() mode bits */
182#ifndef R_OK
183# define R_OK 4
184# define W_OK 2
185# define X_OK 1
186# define F_OK 0
187#endif
188
cc236deb
GS
189/* for waitpid() */
190#ifndef WNOHANG
191# define WNOHANG 1
192#endif
193
c44d3fdb
GS
194#define PERL_GET_CONTEXT_DEFINED
195
f3986ebb
GS
196/* Compiler-specific stuff. */
197
654eccd5
JD
198#if defined(_MSC_VER) || defined(__MINGW32__)
199/* VC uses non-standard way to determine the size and alignment if bit-fields */
200/* MinGW will compiler with -mms-bitfields, so should use the same types */
201# define PERL_BITFIELD8 unsigned char
202# define PERL_BITFIELD16 unsigned short
203# define PERL_BITFIELD32 unsigned int
204#endif
205
910dfcc8 206#ifdef __BORLANDC__ /* Borland C++ */
3e3baf6d 207
cb359b41 208#if (__BORLANDC__ <= 0x520)
3e3baf6d
TB
209#define _access access
210#define _chdir chdir
cb359b41
JH
211#endif
212
4ce4f76e 213#define _getpid getpid
26871e0a 214#define wcsicmp _wcsicmp
3e3baf6d
TB
215#include <sys/types.h>
216
84902520
TB
217#ifndef DllMain
218#define DllMain DllEntryPoint
219#endif
220
dd01f956
SH
221#pragma warn -8004 /* "'foo' is assigned a value that is never used" */
222#pragma warn -8008 /* "condition is always true/false" */
223#pragma warn -8012 /* "comparing signed and unsigned values" */
224#pragma warn -8027 /* "functions containing %s are not expanded inline" */
225#pragma warn -8057 /* "parameter 'foo' is never used" */
226#pragma warn -8060 /* "possibly incorrect assignment" */
227#pragma warn -8066 /* "unreachable code" */
228#pragma warn -8071 /* "conversion may lose significant digits" */
229#pragma warn -8080 /* "'foo' is declared but never used" */
3e3baf6d 230
cd183fd9
GS
231/* Borland C thinks that a pointer to a member variable is 12 bytes in size. */
232#define PERL_MEMBER_PTR_SIZE 12
233
1307044d
VK
234#define isnan _isnan
235
910dfcc8 236#endif
3e3baf6d 237
f3986ebb
GS
238#ifdef _MSC_VER /* Microsoft Visual C++ */
239
f4257e4d 240#ifndef UNDER_CE
0a753a76
PP
241typedef long uid_t;
242typedef long gid_t;
a6c40364 243typedef unsigned short mode_t;
f4257e4d
YO
244#endif
245
c623ac67 246#pragma warning(disable: 4102) /* "unreferenced label" */
f3986ebb 247
0f4eea8f 248/* Visual C thinks that a pointer to a member variable is 16 bytes in size. */
cd183fd9 249#define PERL_MEMBER_PTR_SIZE 16
0f4eea8f 250
5fb4d820 251#define isnan _isnan
80e18237
SH
252#define snprintf _snprintf
253#define vsnprintf _vsnprintf
5fb4d820 254
cab190d4
JD
255#if _MSC_VER < 1300
256/* VC6 has broken NaN semantics: NaN == NaN returns true instead of false */
257#define NAN_COMPARE_BROKEN 1
258#endif
259
f3986ebb
GS
260#endif /* _MSC_VER */
261
910dfcc8
GS
262#ifdef __MINGW32__ /* Minimal Gnu-Win32 */
263
264typedef long uid_t;
265typedef long gid_t;
b1d1613b 266#ifndef _environ
3730b96e 267#define _environ environ
b1d1613b 268#endif
3730b96e
GS
269#define flushall _flushall
270#define fcloseall _fcloseall
44604af1 271#ifndef isnan
6940069f 272#define isnan _isnan /* ...same libraries as MSVC */
44604af1 273#endif
910dfcc8 274
ac4c12e7
GS
275#ifndef _O_NOINHERIT
276# define _O_NOINHERIT 0x0080
277# ifndef _NO_OLDNAMES
278# define O_NOINHERIT _O_NOINHERIT
279# endif
280#endif
281
8659febc
S
282/* <stdint.h>, pulled in by <io.h> as of mingw-runtime-3.3, typedef's
283 * (u)intptr_t but doesn't set the _(U)INTPTR_T_DEFINED defines */
284#ifdef _STDINT_H
285# ifndef _INTPTR_T_DEFINED
286# define _INTPTR_T_DEFINED
287# endif
288# ifndef _UINTPTR_T_DEFINED
289# define _UINTPTR_T_DEFINED
290# endif
291#endif
292
910dfcc8
GS
293#endif /* __MINGW32__ */
294
f8fb7c90
GS
295/* both GCC/Mingw32 and MSVC++ 4.0 are missing this, so we put it here */
296#ifndef CP_UTF8
297# define CP_UTF8 65001
298#endif
299
f3986ebb 300/* compatibility stuff for other compilers goes here */
0a753a76 301
c623ac67
GS
302#ifndef _INTPTR_T_DEFINED
303typedef int intptr_t;
304# define _INTPTR_T_DEFINED
305#endif
306
307#ifndef _UINTPTR_T_DEFINED
308typedef unsigned int uintptr_t;
309# define _UINTPTR_T_DEFINED
310#endif
311
390b85e7 312START_EXTERN_C
f3986ebb
GS
313
314/* For UNIX compatibility. */
315
0a753a76
PP
316extern uid_t getuid(void);
317extern gid_t getgid(void);
318extern uid_t geteuid(void);
319extern gid_t getegid(void);
0a753a76
PP
320extern int setuid(uid_t uid);
321extern int setgid(gid_t gid);
322extern int kill(int pid, int sig);
542cb85f 323extern int killpg(int pid, int sig);
c623ac67
GS
324#ifndef USE_PERL_SBRK
325extern void *sbrk(ptrdiff_t need);
326# define HAS_SBRK_PROTO
327#endif
e34ffe5a 328extern char * getlogin(void);
b990f8c8 329extern int chown(const char *p, uid_t o, gid_t g);
00b02797 330extern int mkstemp(const char *path);
d55594ae 331
f3986ebb
GS
332#undef Stat
333#define Stat win32_stat
3e3baf6d 334
f3986ebb
GS
335#undef init_os_extras
336#define init_os_extras Perl_init_os_extras
390b85e7 337
22239a37 338DllExport void Perl_win32_init(int *argcp, char ***argvp);
23f519f0 339DllExport void Perl_win32_term(void);
cb359b41 340DllExport void Perl_init_os_extras(void);
c5be433b
GS
341DllExport void win32_str_os_error(void *sv, DWORD err);
342DllExport int RunPerl(int argc, char **argv, char **env);
0551aaa8 343
635bbe87
GS
344typedef struct {
345 HANDLE childStdIn;
346 HANDLE childStdOut;
347 HANDLE childStdErr;
f83751a7
GS
348 /*
349 * the following correspond to the fields of the same name
350 * in the STARTUPINFO structure. Embedders can use these to
351 * control the spawning process' look.
352 * Example - to hide the window of the spawned process:
353 * dwFlags = STARTF_USESHOWWINDOW;
354 * wShowWindow = SW_HIDE;
355 */
356 DWORD dwFlags;
3fadfdf1
NIS
357 DWORD dwX;
358 DWORD dwY;
359 DWORD dwXSize;
360 DWORD dwYSize;
361 DWORD dwXCountChars;
362 DWORD dwYCountChars;
f83751a7 363 DWORD dwFillAttribute;
3fadfdf1 364 WORD wShowWindow;
635bbe87
GS
365} child_IO_table;
366
367DllExport void win32_get_child_IO(child_IO_table* ptr);
b69b0499 368DllExport HWND win32_create_message_window(void);
635bbe87 369
f3986ebb
GS
370#ifndef USE_SOCKETS_AS_HANDLES
371extern FILE * my_fdopen(int, char *);
d55594ae 372#endif
f3986ebb 373extern int my_fclose(FILE *);
c623ac67 374extern int my_fstat(int fd, Stat_t *sbufptr);
e6a0bbf8
NC
375extern char * win32_get_privlib(const char *pl, STRLEN *const len);
376extern char * win32_get_sitelib(const char *pl, STRLEN *const len);
377extern char * win32_get_vendorlib(const char *pl, STRLEN *const len);
f3986ebb
GS
378extern int IsWin95(void);
379extern int IsWinNT(void);
d55594ae 380
1c0ca838
GS
381#ifdef PERL_IMPLICIT_SYS
382extern void win32_delete_internal_host(void *h);
383#endif
384
f3986ebb 385extern char * staticlinkmodules[];
390b85e7
GS
386
387END_EXTERN_C
d55594ae 388
68dc0745 389typedef char * caddr_t; /* In malloc.c (core address). */
0a753a76 390
68dc0745 391/*
68dc0745
PP
392 * handle socket stuff, assuming socket is always available
393 */
0a753a76
PP
394#include <sys/socket.h>
395#include <netdb.h>
396
bbc8f9de
NIS
397#ifdef MYMALLOC
398#define EMBEDMYMALLOC /**/
399/* #define USE_PERL_SBRK /**/
400/* #define PERL_SBRK_VIA_MALLOC /**/
401#endif
402
e68cb057 403#ifdef PERL_TEXTMODE_SCRIPTS
c39cd008 404# define PERL_SCRIPT_MODE "r"
a868473f 405#else
c39cd008 406# define PERL_SCRIPT_MODE "rb"
a868473f
NIS
407#endif
408
3fadfdf1
NIS
409/*
410 * Now Win32 specific per-thread data stuff
3352bfcb
GS
411 */
412
aeecf691
JD
413/* Leave the first couple ids after WM_USER unused because they
414 * might be used by an embedding application, and on Windows
415 * version before 2000 we might end up eating those messages
416 * if they were not meant for us.
417 */
418#define WM_USER_MIN (WM_USER+30)
419#define WM_USER_MESSAGE (WM_USER_MIN)
420#define WM_USER_KILL (WM_USER_MIN+1)
421#define WM_USER_MAX (WM_USER_MIN+1)
422
3352bfcb
GS
423struct thread_intern {
424 /* XXX can probably use one buffer instead of several */
425 char Wstrerror_buffer[512];
426 struct servent Wservent;
427 char Wgetlogin_buffer[128];
f4257e4d
YO
428# ifdef USE_SOCKETS_AS_HANDLES
429 int Winit_socktype;
430# endif
3352bfcb
GS
431# ifdef HAVE_DES_FCRYPT
432 char Wcrypt_buffer[30];
433# endif
434# ifdef USE_RTL_THREAD_API
435 void * retv; /* slot for thread return value */
436# endif
02637f4c
JD
437 BOOL Wuse_showwindow;
438 WORD Wshowwindow;
3352bfcb
GS
439};
440
4b556e6c 441#define HAVE_INTERP_INTERN
0aaad0ff
GS
442typedef struct {
443 long num;
444 DWORD pids[MAXIMUM_WAIT_OBJECTS];
7766f137 445 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
0aaad0ff
GS
446} child_tab;
447
aeecf691
JD
448#ifdef USE_ITHREADS
449typedef struct {
450 long num;
451 DWORD pids[MAXIMUM_WAIT_OBJECTS];
452 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
453 HWND message_hwnds[MAXIMUM_WAIT_OBJECTS];
454} pseudo_child_tab;
455#endif
456
3fadfdf1
NIS
457#ifndef Sighandler_t
458typedef Signal_t (*Sighandler_t) (int);
459#define Sighandler_t Sighandler_t
460#endif
461
4b556e6c 462struct interp_intern {
0aaad0ff
GS
463 char * perlshell_tokens;
464 char ** perlshell_vec;
465 long perlshell_items;
466 struct av * fdpid;
467 child_tab * children;
7766f137
GS
468#ifdef USE_ITHREADS
469 DWORD pseudo_id;
aeecf691 470 pseudo_child_tab * pseudo_children;
7766f137
GS
471#endif
472 void * internal_host;
3352bfcb 473 struct thread_intern thr_intern;
aeecf691 474 HWND message_hwnd;
8fb3fcfb 475 UINT timerid;
05ec9bb3 476 unsigned poll_count;
3fadfdf1 477 Sighandler_t sigtable[SIG_SIZE];
4b556e6c
JD
478};
479
8fb3fcfb
NIS
480DllExport int win32_async_check(pTHX);
481
05ec9bb3 482#define WIN32_POLL_INTERVAL 32768
8fb3fcfb 483#define PERL_ASYNC_CHECK() if (w32_do_async || PL_sig_pending) win32_async_check(aTHX)
4b556e6c 484
0aaad0ff
GS
485#define w32_perlshell_tokens (PL_sys_intern.perlshell_tokens)
486#define w32_perlshell_vec (PL_sys_intern.perlshell_vec)
487#define w32_perlshell_items (PL_sys_intern.perlshell_items)
488#define w32_fdpid (PL_sys_intern.fdpid)
489#define w32_children (PL_sys_intern.children)
490#define w32_num_children (w32_children->num)
491#define w32_child_pids (w32_children->pids)
7766f137
GS
492#define w32_child_handles (w32_children->handles)
493#define w32_pseudo_id (PL_sys_intern.pseudo_id)
494#define w32_pseudo_children (PL_sys_intern.pseudo_children)
495#define w32_num_pseudo_children (w32_pseudo_children->num)
496#define w32_pseudo_child_pids (w32_pseudo_children->pids)
497#define w32_pseudo_child_handles (w32_pseudo_children->handles)
aeecf691 498#define w32_pseudo_child_message_hwnds (w32_pseudo_children->message_hwnds)
7766f137 499#define w32_internal_host (PL_sys_intern.internal_host)
8fb3fcfb 500#define w32_timerid (PL_sys_intern.timerid)
aeecf691 501#define w32_message_hwnd (PL_sys_intern.message_hwnd)
3fadfdf1 502#define w32_sighandler (PL_sys_intern.sigtable)
05ec9bb3
NIS
503#define w32_poll_count (PL_sys_intern.poll_count)
504#define w32_do_async (w32_poll_count++ > WIN32_POLL_INTERVAL)
3db8f154
MB
505#define w32_strerror_buffer (PL_sys_intern.thr_intern.Wstrerror_buffer)
506#define w32_getlogin_buffer (PL_sys_intern.thr_intern.Wgetlogin_buffer)
507#define w32_crypt_buffer (PL_sys_intern.thr_intern.Wcrypt_buffer)
508#define w32_servent (PL_sys_intern.thr_intern.Wservent)
f4257e4d 509#define w32_init_socktype (PL_sys_intern.thr_intern.Winit_socktype)
3db8f154
MB
510#define w32_use_showwindow (PL_sys_intern.thr_intern.Wuse_showwindow)
511#define w32_showwindow (PL_sys_intern.thr_intern.Wshowwindow)
c53bd28a 512
7766f137
GS
513#ifdef USE_ITHREADS
514# define PERL_WAIT_FOR_CHILDREN \
515 STMT_START { \
516 if (w32_pseudo_children && w32_num_pseudo_children) { \
517 long children = w32_num_pseudo_children; \
518 WaitForMultipleObjects(children, \
519 w32_pseudo_child_handles, \
520 TRUE, INFINITE); \
521 while (children) \
522 CloseHandle(w32_pseudo_child_handles[--children]); \
523 } \
524 } STMT_END
525#endif
526
a10b7b7e
GS
527#if defined(USE_FIXED_OSFHANDLE) || defined(PERL_MSVCRT_READFIX)
528#ifdef PERL_CORE
529
530/* C doesn't like repeat struct definitions */
df500c58 531#if defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION>=3)
15689010
GM
532#undef _CRTIMP
533#endif
a10b7b7e
GS
534#ifndef _CRTIMP
535#define _CRTIMP __declspec(dllimport)
536#endif
537
538/*
539 * Control structure for lowio file handles
540 */
541typedef struct {
c623ac67 542 intptr_t osfhnd;/* underlying OS file HANDLE */
a10b7b7e
GS
543 char osfile; /* attributes of file (e.g., open in text mode?) */
544 char pipech; /* one char buffer for handles opened on pipes */
545 int lockinitflag;
546 CRITICAL_SECTION lock;
547} ioinfo;
548
549
550/*
551 * Array of arrays of control structures for lowio files.
552 */
553EXTERN_C _CRTIMP ioinfo* __pioinfo[];
554
555/*
556 * Definition of IOINFO_L2E, the log base 2 of the number of elements in each
557 * array of ioinfo structs.
558 */
559#define IOINFO_L2E 5
560
561/*
562 * Definition of IOINFO_ARRAY_ELTS, the number of elements in ioinfo array
563 */
564#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
565
566/*
567 * Access macros for getting at an ioinfo struct and its fields from a
568 * file handle
569 */
570#define _pioinfo(i) (__pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
571#define _osfhnd(i) (_pioinfo(i)->osfhnd)
572#define _osfile(i) (_pioinfo(i)->osfile)
573#define _pipech(i) (_pioinfo(i)->pipech)
574
575/* since we are not doing a dup2(), this works fine */
c623ac67 576#define _set_osfhnd(fh, osfh) (void)(_osfhnd(fh) = (intptr_t)osfh)
a10b7b7e
GS
577#endif
578#endif
579
3fadfdf1 580/* IO.xs and POSIX.xs define PERLIO_NOT_STDIO to 1 */
6e22d046
JH
581#if defined(PERL_EXT_IO) || defined(PERL_EXT_POSIX)
582#undef PERLIO_NOT_STDIO
583#endif
adb71456
NIS
584#define PERLIO_NOT_STDIO 0
585
586#include "perlio.h"
587
4f63d024
GS
588/*
589 * This provides a layer of functions and macros to ensure extensions will
590 * get to use the same RTL functions as the core.
591 */
592#include "win32iop.h"
593
b4748376
NIS
594#define EXEC_ARGV_CAST(x) ((const char *const *) x)
595
4fb841ef
NIS
596#if !defined(ECONNABORTED) && defined(WSAECONNABORTED)
597#define ECONNABORTED WSAECONNABORTED
598#endif
f2b62286
AT
599#if !defined(ECONNRESET) && defined(WSAECONNRESET)
600#define ECONNRESET WSAECONNRESET
601#endif
4fb841ef
NIS
602#if !defined(EAFNOSUPPORT) && defined(WSAEAFNOSUPPORT)
603#define EAFNOSUPPORT WSAEAFNOSUPPORT
604#endif
f2b62286 605/* Why not needed for ECONNREFUSED? --abe */
4fb841ef 606
f4958739 607DllExport void *win32_signal_context(void);
1018e26f
NIS
608#define PERL_GET_SIG_CONTEXT win32_signal_context()
609
45496817 610#ifdef UNDER_CE
7bd379e8
YO
611#define Win_GetModuleHandle XCEGetModuleHandleA
612#define Win_GetProcAddress XCEGetProcAddressA
613#define Win_GetModuleFileName XCEGetModuleFileNameA
614#define Win_CreateSemaphore CreateSemaphoreW
615#else
616#define Win_GetModuleHandle GetModuleHandle
617#define Win_GetProcAddress GetProcAddress
618#define Win_GetModuleFileName GetModuleFileName
619#define Win_CreateSemaphore CreateSemaphore
620#endif
621
68dc0745 622#endif /* _INC_WIN32_PERL5 */
7a9ec5a3 623