This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
new perldelta
[perl5.git] / win32 / win32.h
CommitLineData
68dc0745 1/* WIN32.H
2 *
3fadfdf1 3 * (c) 1995 Microsoft Corporation. All rights reserved.
0d130a44 4 * Developed by hip communications inc.
68dc0745 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 9#ifndef _INC_WIN32_PERL5
10#define _INC_WIN32_PERL5
11
5db10396 12#ifndef _WIN32_WINNT
8cbe99e5 13# define _WIN32_WINNT 0x0500 /* needed for CreateHardlink() etc. */
5db10396 14#endif
638eceb6 15
8ce7a7e8 16/* Win32 only optimizations for faster building */
19253ae6 17#ifdef PERL_IS_MINIPERL
8ce7a7e8
DD
18/* less I/O calls during each require */
19# define PERL_DISABLE_PMC
e5fb2b49 20
0c6362ad 21/* unnecessary for miniperl to lookup anything from an "installed" perl */
6937817d
DD
22# define WIN32_NO_REGISTRY
23
e5fb2b49 24/* allow minitest to work */
ead233d2 25# define PERL_TEXTMODE_SCRIPTS
19253ae6
DD
26#endif
27
acfe0abc 28#if defined(PERL_IMPLICIT_SYS)
e9ee4811 29# define DYNAMIC_ENV_FETCH
a6c40364 30# define HAS_GETENV_LEN
ab39fa9d 31# define WIN32IO_IS_STDIO /* don't pull in custom stdio layer */
c5be433b 32# define WIN32SCK_IS_STDSCK /* don't pull in custom wsock layer */
9d8a25dc
DL
33#endif
34
a835ef8a 35#ifdef __GNUC__
b7c82df9
GS
36# ifndef __int64 /* some versions seem to #define it already */
37# define __int64 long long
38# endif
db15561c 39# define Win32_Winsock
1c85e96a
NIS
40#endif
41
a835ef8a 42
3fadfdf1 43/* Define DllExport akin to perl's EXT,
8cbe99e5 44 * If we are in the DLL then Export the symbol,
22239a37
NIS
45 * otherwise import it.
46 */
47
5db10396 48/* now even GCC supports __declspec() */
a19baa61 49/* miniperl has no reason to export anything */
79c32fc2 50#if defined(PERL_IS_MINIPERL)
a19baa61 51# define DllExport
3fadfdf1 52#else
a19baa61
DD
53# if defined(PERLDLL)
54# define DllExport __declspec(dllexport)
55# else
56# define DllExport __declspec(dllimport)
57# endif
22239a37 58#endif
c69f112c 59
50fd5961
JD
60/* The Perl APIs can only be called directly inside the perl5xx.dll.
61 * All other code has to import them. By declaring them as "dllimport"
62 * we tell the compiler to generate an indirect call instruction and
63 * avoid redirection through a call thunk.
64 *
65 * The XS code in the re extension is special, in that it redefines
66 * core APIs locally, so don't mark them as "dllimport" because GCC
67 * cannot handle this situation.
1b30b4a8
DD
68 *
69 * Certain old GCCs will not allow the function pointer of dllimport marked
70 * function to be "const". This was fixed later on. Since this is a
71 * deoptimization, target "gcc version 3.4.5 (mingw-vista special r3)" only,
72 * The GCC bug was fixed in GCC patch "varasm.c (initializer_constant_valid_p):
73 * Don't deny DECL_DLLIMPORT_P on functions", which probably was first released
74 * in GCC 4.3.0, this #if can be expanded upto but not including 4.3.0 if more
75 * deployed GCC are found that wont build with the follow error, initializer
76 * element is a PerlIO func exported from perl5xx.dll.
77 *
78 * encoding.xs:610: error: initializer element is not constant
79 * encoding.xs:610: error: (near initialization for `PerlIO_encode.Open')
50fd5961 80 */
1b30b4a8
DD
81
82#if (defined(__GNUC__) && defined(__MINGW32__) && \
83 !defined(__MINGW64_VERSION_MAJOR) && !defined(__clang__) && \
1604cfb0 84 ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ <= 5))))
1b30b4a8
DD
85/* use default fallbacks from perl.h for this particular GCC */
86#else
87# if !defined(PERLDLL) && !defined(PERL_EXT_RE_BUILD)
88# ifdef __cplusplus
89# define PERL_CALLCONV extern "C" __declspec(dllimport)
90# ifdef _MSC_VER
91# define PERL_CALLCONV_NO_RET extern "C" __declspec(dllimport) __declspec(noreturn)
92# endif
93# else
94# define PERL_CALLCONV __declspec(dllimport)
95# ifdef _MSC_VER
96# define PERL_CALLCONV_NO_RET __declspec(dllimport) __declspec(noreturn)
97# endif
12a2785c 98# endif
1b30b4a8 99# else /* MSVC noreturn support inside the interp */
12a2785c 100# ifdef _MSC_VER
1b30b4a8 101# define PERL_CALLCONV_NO_RET __declspec(noreturn)
12a2785c 102# endif
ad6ab6c5
JD
103# endif
104#endif
105
98c015b7
DD
106#ifdef _MSC_VER
107# define PERL_STATIC_NO_RET __declspec(noreturn) static
108# define PERL_STATIC_INLINE_NO_RET __declspec(noreturn) PERL_STATIC_INLINE
f1e99d0d
TK
109# define PERL_STATIC_FORCE_INLINE __forceinline static
110# define PERL_STATIC_FORCE_INLINE_NO_RET __declspec(noreturn) __forceinline static
98c015b7
DD
111#endif
112
0a753a76 113#define WIN32_LEAN_AND_MEAN
114#include <windows.h>
115
fa58a56f
S
116/*
117 * Bug in winbase.h in mingw-w64 4.4.0-1 at least... they
118 * do #define GetEnvironmentStringsA GetEnvironmentStrings and fail
119 * to declare GetEnvironmentStringsA.
120 */
121#if defined(__MINGW64__) && defined(GetEnvironmentStringsA) && !defined(UNICODE)
122#ifdef __cplusplus
123extern "C" {
124#endif
125#undef GetEnvironmentStringsA
126WINBASEAPI LPCH WINAPI GetEnvironmentStringsA(VOID);
127#define GetEnvironmentStrings GetEnvironmentStringsA
128#ifdef __cplusplus
129}
130#endif
131#endif
132
68dc0745 133#ifdef WIN32_LEAN_AND_MEAN /* C file is NOT a Perl5 original. */
134#define CONTEXT PERL_CONTEXT /* Avoid conflict of CONTEXT defs. */
68dc0745 135#endif /*WIN32_LEAN_AND_MEAN */
0a753a76 136
eda5ff31
GS
137#ifndef TLS_OUT_OF_INDEXES
138#define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
139#endif
140
0a753a76 141#include <dirent.h>
142#include <io.h>
143#include <process.h>
144#include <stdio.h>
145#include <direct.h>
390b85e7 146#include <stdlib.h>
c623ac67 147#include <stddef.h>
7a1f88ac 148#include <fcntl.h>
390b85e7
GS
149#ifndef EXT
150#include "EXTERN.h"
151#endif
152
c69f112c 153struct tms {
1604cfb0
MS
154 long tms_utime;
155 long tms_stime;
156 long tms_cutime;
157 long tms_cstime;
c69f112c
NIS
158};
159
b2af26b1
GS
160#ifndef SYS_NMLN
161#define SYS_NMLN 257
162#endif
163
164struct utsname {
165 char sysname[SYS_NMLN];
166 char nodename[SYS_NMLN];
167 char release[SYS_NMLN];
168 char version[SYS_NMLN];
169 char machine[SYS_NMLN];
170};
171
390b85e7 172#ifndef START_EXTERN_C
b3e5c95e 173#undef EXTERN_C
390b85e7
GS
174#ifdef __cplusplus
175# define START_EXTERN_C extern "C" {
176# define END_EXTERN_C }
177# define EXTERN_C extern "C"
178#else
3fadfdf1
NIS
179# define START_EXTERN_C
180# define END_EXTERN_C
390b85e7
GS
181# define EXTERN_C
182#endif
183#endif
184
390b85e7
GS
185#define DOSISH 1 /* no escaping our roots */
186#define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */
0a753a76 187
a7092146 188/* read() and write() aren't transparent for socket handles */
19253ae6
DD
189#ifndef WIN32_NO_SOCKETS
190# define PERL_SOCK_SYSREAD_IS_RECV
191# define PERL_SOCK_SYSWRITE_IS_SEND
192#endif
a7092146 193
6937817d
DD
194#ifdef WIN32_NO_REGISTRY
195/* the last _ in WIN32_NO_REGISTRY_M_ is like the _ in aTHX_ */
196# define WIN32_NO_REGISTRY_M_(x)
197#else
198# define WIN32_NO_REGISTRY_M_(x) x,
199#endif
200
902173a3
GS
201#define ENV_IS_CASELESS
202
479b2847
GS
203#define PIPESOCK_MODE "b" /* pipes, sockets default to binmode */
204
327c3667
GS
205/* access() mode bits */
206#ifndef R_OK
53175c60
YO
207# define R_OK 4
208# define W_OK 2
209# define X_OK 1
210# define F_OK 0
327c3667
GS
211#endif
212
cc236deb
GS
213/* for waitpid() */
214#ifndef WNOHANG
215# define WNOHANG 1
216#endif
217
c44d3fdb
GS
218#define PERL_GET_CONTEXT_DEFINED
219
f3986ebb
GS
220/* Compiler-specific stuff. */
221
654eccd5 222/* VC uses non-standard way to determine the size and alignment if bit-fields */
4eab039d 223/* MinGW will compile with -mms-bitfields, so should use the same types */
4b16e2bb
YO
224#define PERL_BITFIELD8 U8
225#define PERL_BITFIELD16 U16
226#define PERL_BITFIELD32 U32
654eccd5 227
f3986ebb
GS
228#ifdef _MSC_VER /* Microsoft Visual C++ */
229
0a753a76 230typedef long uid_t;
231typedef long gid_t;
a6c40364 232typedef unsigned short mode_t;
f4257e4d 233
80e18237
SH
234#define snprintf _snprintf
235#define vsnprintf _vsnprintf
5fb4d820 236
6879a07b 237MSVC_DIAG_IGNORE(4756 4056)
3c81f0b3
DD
238PERL_STATIC_INLINE
239double S_Infinity() {
240 /* this is a real C literal which can get further constant folded
241 unlike using HUGE_VAL/_HUGE which are data symbol imports from the CRT
242 and therefore can not by folded by VC, an example of constant
243 folding INF is creating -INF */
244 return (DBL_MAX+DBL_MAX);
245}
6879a07b
TK
246MSVC_DIAG_RESTORE
247
1f664ef5 248#define NV_INF S_Infinity()
3c81f0b3
DD
249
250/* selectany allows duplicate and unused data symbols to be removed by
251 VC linker, if this were static, each translation unit will have its own,
252 usually unused __PL_nan_u, if this were plain extern it will cause link
253 to fail due to multiple definitions, since we dont know if we are being
254 compiled as static or DLL XS, selectany simply always works, the cost of
255 importing __PL_nan_u across DLL boundaries in size in the importing DLL
256 will be more than the 8 bytes it will take up being in each XS DLL if
257 that DLL actually uses __PL_nan_u */
068732a9
CW
258union PerlNan { unsigned __int64 __q; double __d; };
259extern const __declspec(selectany) union PerlNan __PL_nan_u = { 0x7FF8000000000000UI64 };
1f664ef5
SH
260#define NV_NAN ((NV)__PL_nan_u.__d)
261
26b63da6
TC
262#endif /* ifdef _MSC_VER */
263
1f664ef5 264/* The CRT was rewritten in VS2015. */
26b63da6 265#ifdef _UCRT
1f664ef5
SH
266
267/* No longer declared in stdio.h */
e7a4ac29 268EXTERN_C char *gets(char* buffer);
1f664ef5
SH
269
270#define tzname _tzname
271
272/* From corecrt_internal_stdio.h: */
273typedef struct
274{
275 union
276 {
277 FILE _public_file;
278 char* _ptr;
709d3527 279 } u;
1f664ef5
SH
280
281 char* _base;
282 int _cnt;
283 long _flags;
284 long _file;
285 int _charbuf;
286 int _bufsiz;
287 char* _tmpfname;
288 CRITICAL_SECTION _lock;
289} __crt_stdio_stream_data;
290
291#define PERLIO_FILE_flag_RD 0x0001 /* _IOREAD */
292#define PERLIO_FILE_flag_WR 0x0002 /* _IOWRITE */
293#define PERLIO_FILE_flag_RW 0x0004 /* _IOUPDATE */
709d3527 294#define PERLIO_FILE_ptr(f) (((__crt_stdio_stream_data*)(f))->u._ptr)
1f664ef5
SH
295#define PERLIO_FILE_base(f) (((__crt_stdio_stream_data*)(f))->_base)
296#define PERLIO_FILE_cnt(f) (((__crt_stdio_stream_data*)(f))->_cnt)
297#define PERLIO_FILE_flag(f) ((int)(((__crt_stdio_stream_data*)(f))->_flags))
002a8415 298#define PERLIO_FILE_file(f) (*(int*)(&((__crt_stdio_stream_data*)(f))->_file))
1f664ef5 299
26b63da6 300#else /* ifdef _UCRT */
1f664ef5
SH
301
302/* Note: PERLIO_FILE_ptr/base/cnt are not actually used for GCC or <VS2015
303 * since FILE_ptr/base/cnt do the same thing anyway but it doesn't hurt to
304 * define them all here for completeness. */
305#define PERLIO_FILE_flag_RD _IOREAD /* 0x001 */
306#define PERLIO_FILE_flag_WR _IOWRT /* 0x002 */
307#define PERLIO_FILE_flag_RW _IORW /* 0x080 */
308#define PERLIO_FILE_ptr(f) ((f)->_ptr)
309#define PERLIO_FILE_base(f) ((f)->_base)
310#define PERLIO_FILE_cnt(f) ((f)->_cnt)
311#define PERLIO_FILE_flag(f) ((f)->_flag)
312#define PERLIO_FILE_file(f) ((f)->_file)
313
314#endif
315
910dfcc8
GS
316#ifdef __MINGW32__ /* Minimal Gnu-Win32 */
317
318typedef long uid_t;
319typedef long gid_t;
b1d1613b 320#ifndef _environ
3730b96e 321#define _environ environ
b1d1613b 322#endif
3730b96e
GS
323#define flushall _flushall
324#define fcloseall _fcloseall
44604af1 325#ifndef isnan
6940069f 326#define isnan _isnan /* ...same libraries as MSVC */
44604af1 327#endif
910dfcc8 328
ac4c12e7
GS
329#ifndef _O_NOINHERIT
330# define _O_NOINHERIT 0x0080
331# ifndef _NO_OLDNAMES
332# define O_NOINHERIT _O_NOINHERIT
333# endif
334#endif
335
8659febc
S
336/* <stdint.h>, pulled in by <io.h> as of mingw-runtime-3.3, typedef's
337 * (u)intptr_t but doesn't set the _(U)INTPTR_T_DEFINED defines */
338#ifdef _STDINT_H
339# ifndef _INTPTR_T_DEFINED
340# define _INTPTR_T_DEFINED
341# endif
342# ifndef _UINTPTR_T_DEFINED
343# define _UINTPTR_T_DEFINED
344# endif
345#endif
346
f8fb7c90
GS
347#ifndef CP_UTF8
348# define CP_UTF8 65001
349#endif
350
70764c00
SH
351#endif /* __MINGW32__ */
352
c623ac67
GS
353#ifndef _INTPTR_T_DEFINED
354typedef int intptr_t;
355# define _INTPTR_T_DEFINED
356#endif
357
358#ifndef _UINTPTR_T_DEFINED
359typedef unsigned int uintptr_t;
360# define _UINTPTR_T_DEFINED
361#endif
362
390b85e7 363START_EXTERN_C
f3986ebb
GS
364
365/* For UNIX compatibility. */
366
e37d7e38 367#ifdef PERL_CORE
0a753a76 368extern uid_t getuid(void);
369extern gid_t getgid(void);
370extern uid_t geteuid(void);
371extern gid_t getegid(void);
0c38a575
SH
372extern int setuid(uid_t uid);
373extern int setgid(gid_t gid);
0a753a76 374extern int kill(int pid, int sig);
c623ac67
GS
375#ifndef USE_PERL_SBRK
376extern void *sbrk(ptrdiff_t need);
377# define HAS_SBRK_PROTO
378#endif
e34ffe5a 379extern char * getlogin(void);
b990f8c8 380extern int chown(const char *p, uid_t o, gid_t g);
341a561f
SH
381#if((!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 4) && \
382 (!defined(__MINGW32_MAJOR_VERSION) || __MINGW32_MAJOR_VERSION < 3 || \
383 (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION < 21)))
00b02797 384extern int mkstemp(const char *path);
e37d7e38 385#endif
f33b2f58 386#endif
d55594ae 387
f3986ebb
GS
388#undef Stat
389#define Stat win32_stat
3e3baf6d 390
f3986ebb
GS
391#undef init_os_extras
392#define init_os_extras Perl_init_os_extras
390b85e7 393
22239a37 394DllExport void Perl_win32_init(int *argcp, char ***argvp);
23f519f0 395DllExport void Perl_win32_term(void);
cb359b41 396DllExport void Perl_init_os_extras(void);
c5be433b
GS
397DllExport void win32_str_os_error(void *sv, DWORD err);
398DllExport int RunPerl(int argc, char **argv, char **env);
0551aaa8 399
635bbe87
GS
400typedef struct {
401 HANDLE childStdIn;
402 HANDLE childStdOut;
403 HANDLE childStdErr;
f83751a7
GS
404 /*
405 * the following correspond to the fields of the same name
406 * in the STARTUPINFO structure. Embedders can use these to
407 * control the spawning process' look.
408 * Example - to hide the window of the spawned process:
409 * dwFlags = STARTF_USESHOWWINDOW;
410 * wShowWindow = SW_HIDE;
411 */
412 DWORD dwFlags;
3fadfdf1
NIS
413 DWORD dwX;
414 DWORD dwY;
415 DWORD dwXSize;
416 DWORD dwYSize;
417 DWORD dwXCountChars;
418 DWORD dwYCountChars;
f83751a7 419 DWORD dwFillAttribute;
3fadfdf1 420 WORD wShowWindow;
635bbe87
GS
421} child_IO_table;
422
423DllExport void win32_get_child_IO(child_IO_table* ptr);
b69b0499 424DllExport HWND win32_create_message_window(void);
39c93f11 425DllExport int win32_async_check(pTHX);
635bbe87 426
6937817d 427extern char * win32_get_privlib(WIN32_NO_REGISTRY_M_(const char *pl) STRLEN *const len);
e6a0bbf8
NC
428extern char * win32_get_sitelib(const char *pl, STRLEN *const len);
429extern char * win32_get_vendorlib(const char *pl, STRLEN *const len);
d55594ae 430
1c0ca838
GS
431#ifdef PERL_IMPLICIT_SYS
432extern void win32_delete_internal_host(void *h);
433#endif
434
c9beaf97
SH
435extern int win32_get_errno(int err);
436
fe1c5936 437extern const char * const staticlinkmodules[];
390b85e7
GS
438
439END_EXTERN_C
d55594ae 440
68dc0745 441typedef char * caddr_t; /* In malloc.c (core address). */
0a753a76 442
68dc0745 443/*
68dc0745 444 * handle socket stuff, assuming socket is always available
445 */
0a753a76 446#include <sys/socket.h>
447#include <netdb.h>
448
bbc8f9de
NIS
449#ifdef MYMALLOC
450#define EMBEDMYMALLOC /**/
08088357 451/* #define USE_PERL_SBRK / **/
452/* #define PERL_SBRK_VIA_MALLOC / **/
bbc8f9de
NIS
453#endif
454
e68cb057 455#ifdef PERL_TEXTMODE_SCRIPTS
c39cd008 456# define PERL_SCRIPT_MODE "r"
a868473f 457#else
c39cd008 458# define PERL_SCRIPT_MODE "rb"
a868473f
NIS
459#endif
460
3fadfdf1
NIS
461/*
462 * Now Win32 specific per-thread data stuff
3352bfcb
GS
463 */
464
aeecf691
JD
465/* Leave the first couple ids after WM_USER unused because they
466 * might be used by an embedding application, and on Windows
467 * version before 2000 we might end up eating those messages
468 * if they were not meant for us.
469 */
470#define WM_USER_MIN (WM_USER+30)
471#define WM_USER_MESSAGE (WM_USER_MIN)
472#define WM_USER_KILL (WM_USER_MIN+1)
473#define WM_USER_MAX (WM_USER_MIN+1)
474
3352bfcb
GS
475struct thread_intern {
476 /* XXX can probably use one buffer instead of several */
477 char Wstrerror_buffer[512];
478 struct servent Wservent;
479 char Wgetlogin_buffer[128];
f4257e4d 480 int Winit_socktype;
3352bfcb 481 char Wcrypt_buffer[30];
3352bfcb
GS
482# ifdef USE_RTL_THREAD_API
483 void * retv; /* slot for thread return value */
484# endif
02637f4c
JD
485 BOOL Wuse_showwindow;
486 WORD Wshowwindow;
3352bfcb
GS
487};
488
4b556e6c 489#define HAVE_INTERP_INTERN
0aaad0ff
GS
490typedef struct {
491 long num;
492 DWORD pids[MAXIMUM_WAIT_OBJECTS];
7766f137 493 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
0aaad0ff
GS
494} child_tab;
495
aeecf691
JD
496#ifdef USE_ITHREADS
497typedef struct {
498 long num;
499 DWORD pids[MAXIMUM_WAIT_OBJECTS];
500 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
501 HWND message_hwnds[MAXIMUM_WAIT_OBJECTS];
8a3cb9c6 502 char sigterm[MAXIMUM_WAIT_OBJECTS];
aeecf691
JD
503} pseudo_child_tab;
504#endif
505
3fadfdf1
NIS
506#ifndef Sighandler_t
507typedef Signal_t (*Sighandler_t) (int);
508#define Sighandler_t Sighandler_t
509#endif
510
4b556e6c 511struct interp_intern {
0aaad0ff
GS
512 char * perlshell_tokens;
513 char ** perlshell_vec;
514 long perlshell_items;
515 struct av * fdpid;
516 child_tab * children;
7766f137
GS
517#ifdef USE_ITHREADS
518 DWORD pseudo_id;
aeecf691 519 pseudo_child_tab * pseudo_children;
7766f137
GS
520#endif
521 void * internal_host;
3352bfcb 522 struct thread_intern thr_intern;
aeecf691 523 HWND message_hwnd;
8fb3fcfb 524 UINT timerid;
05ec9bb3 525 unsigned poll_count;
3fadfdf1 526 Sighandler_t sigtable[SIG_SIZE];
4b556e6c
JD
527};
528
05ec9bb3 529#define WIN32_POLL_INTERVAL 32768
8fb3fcfb 530#define PERL_ASYNC_CHECK() if (w32_do_async || PL_sig_pending) win32_async_check(aTHX)
4b556e6c 531
0aaad0ff
GS
532#define w32_perlshell_tokens (PL_sys_intern.perlshell_tokens)
533#define w32_perlshell_vec (PL_sys_intern.perlshell_vec)
534#define w32_perlshell_items (PL_sys_intern.perlshell_items)
535#define w32_fdpid (PL_sys_intern.fdpid)
536#define w32_children (PL_sys_intern.children)
537#define w32_num_children (w32_children->num)
538#define w32_child_pids (w32_children->pids)
7766f137
GS
539#define w32_child_handles (w32_children->handles)
540#define w32_pseudo_id (PL_sys_intern.pseudo_id)
541#define w32_pseudo_children (PL_sys_intern.pseudo_children)
542#define w32_num_pseudo_children (w32_pseudo_children->num)
543#define w32_pseudo_child_pids (w32_pseudo_children->pids)
544#define w32_pseudo_child_handles (w32_pseudo_children->handles)
aeecf691 545#define w32_pseudo_child_message_hwnds (w32_pseudo_children->message_hwnds)
8a3cb9c6 546#define w32_pseudo_child_sigterm (w32_pseudo_children->sigterm)
7766f137 547#define w32_internal_host (PL_sys_intern.internal_host)
8fb3fcfb 548#define w32_timerid (PL_sys_intern.timerid)
aeecf691 549#define w32_message_hwnd (PL_sys_intern.message_hwnd)
3fadfdf1 550#define w32_sighandler (PL_sys_intern.sigtable)
05ec9bb3
NIS
551#define w32_poll_count (PL_sys_intern.poll_count)
552#define w32_do_async (w32_poll_count++ > WIN32_POLL_INTERVAL)
3db8f154
MB
553#define w32_strerror_buffer (PL_sys_intern.thr_intern.Wstrerror_buffer)
554#define w32_getlogin_buffer (PL_sys_intern.thr_intern.Wgetlogin_buffer)
555#define w32_crypt_buffer (PL_sys_intern.thr_intern.Wcrypt_buffer)
556#define w32_servent (PL_sys_intern.thr_intern.Wservent)
f4257e4d 557#define w32_init_socktype (PL_sys_intern.thr_intern.Winit_socktype)
3db8f154
MB
558#define w32_use_showwindow (PL_sys_intern.thr_intern.Wuse_showwindow)
559#define w32_showwindow (PL_sys_intern.thr_intern.Wshowwindow)
c53bd28a 560
7766f137 561#ifdef USE_ITHREADS
8a3cb9c6
JD
562void win32_wait_for_children(pTHX);
563# define PERL_WAIT_FOR_CHILDREN win32_wait_for_children(aTHX)
7766f137
GS
564#endif
565
3fadfdf1 566/* IO.xs and POSIX.xs define PERLIO_NOT_STDIO to 1 */
6e22d046
JH
567#if defined(PERL_EXT_IO) || defined(PERL_EXT_POSIX)
568#undef PERLIO_NOT_STDIO
569#endif
adb71456
NIS
570#define PERLIO_NOT_STDIO 0
571
b4748376
NIS
572#define EXEC_ARGV_CAST(x) ((const char *const *) x)
573
f4958739 574DllExport void *win32_signal_context(void);
1018e26f
NIS
575#define PERL_GET_SIG_CONTEXT win32_signal_context()
576
7bd379e8
YO
577#define Win_GetModuleHandle GetModuleHandle
578#define Win_GetProcAddress GetProcAddress
579#define Win_GetModuleFileName GetModuleFileName
580#define Win_CreateSemaphore CreateSemaphore
7bd379e8 581
52bd4b10
TC
582#if defined(PERL_CORE) && !defined(O_ACCMODE)
583# define O_ACCMODE (O_RDWR | O_WRONLY | O_RDONLY)
584#endif
585
92b3a3eb
TC
586/* ucrt at least seems to allocate a whole bit per type,
587 just mask off one bit from the mask for our symlink
01052a1d 588 and socket file types.
92b3a3eb 589*/
01052a1d
TC
590#define _S_IFLNK ((unsigned)(_S_IFDIR | _S_IFCHR))
591#define _S_IFSOCK ((unsigned)(_S_IFDIR | _S_IFIFO))
592/* mingw64 defines _S_IFBLK to 0x3000 which is _S_IFDIR | _S_IFIFO */
593#ifndef _S_IFBLK
594# define _S_IFBLK ((unsigned)(_S_IFCHR | _S_IFIFO))
595#endif
92b3a3eb
TC
596#undef S_ISLNK
597#define S_ISLNK(mode) (((mode) & _S_IFMT) == _S_IFLNK)
01052a1d
TC
598#undef S_ISSOCK
599#define S_ISSOCK(mode) (((mode) & _S_IFMT) == _S_IFSOCK)
600#undef S_ISBLK
601#define S_ISBLK(mode) (((mode) & _S_IFMT) == _S_IFBLK)
92b3a3eb
TC
602
603/*
604
605The default CRT struct stat uses unsigned short for st_dev and st_ino
606which obviously isn't enough, so we define our own structure.
607
608 */
609
610typedef DWORD Dev_t;
611typedef unsigned __int64 Ino_t;
612
613struct w32_stat {
614 Dev_t st_dev;
615 Ino_t st_ino;
616 unsigned short st_mode;
617 DWORD st_nlink;
618 short st_uid;
619 short st_gid;
620 Dev_t st_rdev;
621 Off_t st_size;
622 time_t st_atime;
623 time_t st_mtime;
624 time_t st_ctime;
625};
626
68dc0745 627#endif /* _INC_WIN32_PERL5 */
7a9ec5a3 628