Commit | Line | Data |
---|---|---|
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 DD |
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 | |
8ce7a7e8 DD |
24 | /* less I/O calls during each require */ |
25 | # define PERL_DISABLE_PMC | |
19253ae6 DD |
26 | #endif |
27 | ||
28 | #ifdef WIN32_NO_SOCKETS | |
29 | # undef HAS_SOCKET | |
30 | # undef HAS_GETPROTOBYNAME | |
31 | # undef HAS_GETPROTOBYNUMBER | |
32 | # undef HAS_GETPROTOENT | |
33 | # undef HAS_GETNETBYNAME | |
34 | # undef HAS_GETNETBYADDR | |
35 | # undef HAS_GETNETENT | |
36 | # undef HAS_GETSERVBYNAME | |
37 | # undef HAS_GETSERVBYPORT | |
38 | # undef HAS_GETSERVENT | |
39 | # undef HAS_GETHOSTBYNAME | |
40 | # undef HAS_GETHOSTBYADDR | |
41 | # undef HAS_GETHOSTENT | |
42 | # undef HAS_SELECT | |
43 | # undef HAS_IOCTL | |
44 | # undef HAS_NTOHL | |
45 | # undef HAS_HTONL | |
46 | # undef HAS_HTONS | |
47 | # undef HAS_NTOHS | |
48 | # define WIN32SCK_IS_STDSCK | |
49 | #endif | |
50 | ||
acfe0abc | 51 | #if defined(PERL_IMPLICIT_SYS) |
e9ee4811 | 52 | # define DYNAMIC_ENV_FETCH |
a6c40364 | 53 | # define HAS_GETENV_LEN |
e9ee4811 | 54 | # define prime_env_iter() |
ab39fa9d | 55 | # define WIN32IO_IS_STDIO /* don't pull in custom stdio layer */ |
c5be433b | 56 | # define WIN32SCK_IS_STDSCK /* don't pull in custom wsock layer */ |
ab39fa9d | 57 | # ifdef PERL_GLOBAL_STRUCT |
32e30700 | 58 | # error PERL_GLOBAL_STRUCT cannot be defined with PERL_IMPLICIT_SYS |
ab39fa9d | 59 | # endif |
e5a95ffb | 60 | # define win32_get_privlib PerlEnv_lib_path |
ab39fa9d | 61 | # define win32_get_sitelib PerlEnv_sitelib_path |
4ea817c6 | 62 | # define win32_get_vendorlib PerlEnv_vendorlib_path |
9d8a25dc DL |
63 | #endif |
64 | ||
a835ef8a | 65 | #ifdef __GNUC__ |
b7c82df9 GS |
66 | # ifndef __int64 /* some versions seem to #define it already */ |
67 | # define __int64 long long | |
68 | # endif | |
db15561c | 69 | # define Win32_Winsock |
1c85e96a NIS |
70 | #ifdef __cplusplus |
71 | /* Mingw32 gcc -xc++ objects to __attribute((unused)) at least */ | |
3fadfdf1 NIS |
72 | #undef PERL_UNUSED_DECL |
73 | #define PERL_UNUSED_DECL | |
a835ef8a | 74 | #endif |
1c85e96a NIS |
75 | #endif |
76 | ||
a835ef8a | 77 | |
3fadfdf1 | 78 | /* Define DllExport akin to perl's EXT, |
8cbe99e5 | 79 | * If we are in the DLL then Export the symbol, |
22239a37 NIS |
80 | * otherwise import it. |
81 | */ | |
82 | ||
5db10396 | 83 | /* now even GCC supports __declspec() */ |
a19baa61 DD |
84 | /* miniperl has no reason to export anything */ |
85 | #if defined(PERL_IS_MINIPERL) && !defined(UNDER_CE) && defined(_MSC_VER) | |
86 | # define DllExport | |
3fadfdf1 | 87 | #else |
a19baa61 DD |
88 | # if defined(PERLDLL) |
89 | # define DllExport __declspec(dllexport) | |
90 | # else | |
91 | # define DllExport __declspec(dllimport) | |
92 | # endif | |
22239a37 | 93 | #endif |
c69f112c | 94 | |
50fd5961 JD |
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) | |
ad6ab6c5 JD |
105 | # ifdef __cplusplus |
106 | # define PERL_CALLCONV extern "C" __declspec(dllimport) | |
12a2785c | 107 | # ifdef _MSC_VER |
03c98af0 | 108 | # define PERL_CALLCONV_NO_RET extern "C" __declspec(dllimport) __declspec(noreturn) |
12a2785c | 109 | # endif |
ad6ab6c5 JD |
110 | # else |
111 | # define PERL_CALLCONV __declspec(dllimport) | |
12a2785c | 112 | # ifdef _MSC_VER |
03c98af0 | 113 | # define PERL_CALLCONV_NO_RET __declspec(dllimport) __declspec(noreturn) |
12a2785c | 114 | # endif |
ad6ab6c5 | 115 | # endif |
50e8e1f5 DD |
116 | #else /* MSVC noreturn support inside the interp */ |
117 | # ifdef _MSC_VER | |
118 | # define PERL_CALLCONV_NO_RET __declspec(noreturn) | |
119 | # endif | |
ad6ab6c5 JD |
120 | #endif |
121 | ||
98c015b7 DD |
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 | ||
0a753a76 | 127 | #define WIN32_LEAN_AND_MEAN |
128 | #include <windows.h> | |
129 | ||
fa58a56f S |
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 | ||
68dc0745 | 147 | #ifdef WIN32_LEAN_AND_MEAN /* C file is NOT a Perl5 original. */ |
148 | #define CONTEXT PERL_CONTEXT /* Avoid conflict of CONTEXT defs. */ | |
68dc0745 | 149 | #endif /*WIN32_LEAN_AND_MEAN */ |
0a753a76 | 150 | |
eda5ff31 GS |
151 | #ifndef TLS_OUT_OF_INDEXES |
152 | #define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF | |
153 | #endif | |
154 | ||
0a753a76 | 155 | #include <dirent.h> |
156 | #include <io.h> | |
157 | #include <process.h> | |
158 | #include <stdio.h> | |
159 | #include <direct.h> | |
390b85e7 | 160 | #include <stdlib.h> |
c623ac67 | 161 | #include <stddef.h> |
7a1f88ac | 162 | #include <fcntl.h> |
390b85e7 GS |
163 | #ifndef EXT |
164 | #include "EXTERN.h" | |
165 | #endif | |
166 | ||
c69f112c NIS |
167 | struct tms { |
168 | long tms_utime; | |
169 | long tms_stime; | |
170 | long tms_cutime; | |
171 | long tms_cstime; | |
172 | }; | |
173 | ||
b2af26b1 GS |
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 | ||
390b85e7 | 186 | #ifndef START_EXTERN_C |
b3e5c95e | 187 | #undef EXTERN_C |
390b85e7 GS |
188 | #ifdef __cplusplus |
189 | # define START_EXTERN_C extern "C" { | |
190 | # define END_EXTERN_C } | |
191 | # define EXTERN_C extern "C" | |
192 | #else | |
3fadfdf1 NIS |
193 | # define START_EXTERN_C |
194 | # define END_EXTERN_C | |
390b85e7 GS |
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? */ | |
0a753a76 | 202 | |
a7092146 | 203 | /* read() and write() aren't transparent for socket handles */ |
19253ae6 DD |
204 | #ifndef WIN32_NO_SOCKETS |
205 | # define PERL_SOCK_SYSREAD_IS_RECV | |
206 | # define PERL_SOCK_SYSWRITE_IS_SEND | |
207 | #endif | |
a7092146 | 208 | |
682fc664 | 209 | #define PERL_NO_FORCE_LINK /* no need for PL_force_link_funcs */ |
a7092146 | 210 | |
902173a3 GS |
211 | #define ENV_IS_CASELESS |
212 | ||
479b2847 GS |
213 | #define PIPESOCK_MODE "b" /* pipes, sockets default to binmode */ |
214 | ||
327c3667 GS |
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 | ||
cc236deb GS |
223 | /* for waitpid() */ |
224 | #ifndef WNOHANG | |
225 | # define WNOHANG 1 | |
226 | #endif | |
227 | ||
c44d3fdb GS |
228 | #define PERL_GET_CONTEXT_DEFINED |
229 | ||
f3986ebb GS |
230 | /* Compiler-specific stuff. */ |
231 | ||
654eccd5 | 232 | /* VC uses non-standard way to determine the size and alignment if bit-fields */ |
4eab039d SH |
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 | |
654eccd5 | 237 | |
f3986ebb GS |
238 | #ifdef _MSC_VER /* Microsoft Visual C++ */ |
239 | ||
f4257e4d | 240 | #ifndef UNDER_CE |
0a753a76 | 241 | typedef long uid_t; |
242 | typedef long gid_t; | |
a6c40364 | 243 | typedef unsigned short mode_t; |
f4257e4d YO |
244 | #endif |
245 | ||
c623ac67 | 246 | #pragma warning(disable: 4102) /* "unreferenced label" */ |
f3986ebb | 247 | |
3e7c2d43 SH |
248 | #if _MSC_VER < 1800 |
249 | #define isnan _isnan /* Defined already in VC++ 12.0 */ | |
250 | #endif | |
27329181 DD |
251 | #ifdef UNDER_CE /* revisit what function this becomes celib vs corelibc, prv warning here*/ |
252 | # undef snprintf | |
253 | #endif | |
80e18237 SH |
254 | #define snprintf _snprintf |
255 | #define vsnprintf _vsnprintf | |
5fb4d820 | 256 | |
9ea40801 | 257 | #ifdef USING_MSVC6 |
cab190d4 JD |
258 | /* VC6 has broken NaN semantics: NaN == NaN returns true instead of false */ |
259 | #define NAN_COMPARE_BROKEN 1 | |
260 | #endif | |
261 | ||
8961ec41 DD |
262 | /* on VC2003, msvcrt.lib is missing these symbols */ |
263 | #if _MSC_VER >= 1300 && _MSC_VER < 1400 | |
264 | # pragma intrinsic(_rotl64,_rotr64) | |
265 | #endif | |
266 | ||
f3986ebb GS |
267 | #endif /* _MSC_VER */ |
268 | ||
910dfcc8 GS |
269 | #ifdef __MINGW32__ /* Minimal Gnu-Win32 */ |
270 | ||
271 | typedef long uid_t; | |
272 | typedef long gid_t; | |
b1d1613b | 273 | #ifndef _environ |
3730b96e | 274 | #define _environ environ |
b1d1613b | 275 | #endif |
3730b96e GS |
276 | #define flushall _flushall |
277 | #define fcloseall _fcloseall | |
44604af1 | 278 | #ifndef isnan |
6940069f | 279 | #define isnan _isnan /* ...same libraries as MSVC */ |
44604af1 | 280 | #endif |
910dfcc8 | 281 | |
ac4c12e7 GS |
282 | #ifndef _O_NOINHERIT |
283 | # define _O_NOINHERIT 0x0080 | |
284 | # ifndef _NO_OLDNAMES | |
285 | # define O_NOINHERIT _O_NOINHERIT | |
286 | # endif | |
287 | #endif | |
288 | ||
8659febc S |
289 | /* <stdint.h>, pulled in by <io.h> as of mingw-runtime-3.3, typedef's |
290 | * (u)intptr_t but doesn't set the _(U)INTPTR_T_DEFINED defines */ | |
291 | #ifdef _STDINT_H | |
292 | # ifndef _INTPTR_T_DEFINED | |
293 | # define _INTPTR_T_DEFINED | |
294 | # endif | |
295 | # ifndef _UINTPTR_T_DEFINED | |
296 | # define _UINTPTR_T_DEFINED | |
297 | # endif | |
298 | #endif | |
299 | ||
f8fb7c90 GS |
300 | #ifndef CP_UTF8 |
301 | # define CP_UTF8 65001 | |
302 | #endif | |
303 | ||
70764c00 SH |
304 | #endif /* __MINGW32__ */ |
305 | ||
c623ac67 GS |
306 | #ifndef _INTPTR_T_DEFINED |
307 | typedef int intptr_t; | |
308 | # define _INTPTR_T_DEFINED | |
309 | #endif | |
310 | ||
311 | #ifndef _UINTPTR_T_DEFINED | |
312 | typedef unsigned int uintptr_t; | |
313 | # define _UINTPTR_T_DEFINED | |
314 | #endif | |
315 | ||
390b85e7 | 316 | START_EXTERN_C |
f3986ebb GS |
317 | |
318 | /* For UNIX compatibility. */ | |
319 | ||
e37d7e38 | 320 | #ifdef PERL_CORE |
0a753a76 | 321 | extern uid_t getuid(void); |
322 | extern gid_t getgid(void); | |
323 | extern uid_t geteuid(void); | |
324 | extern gid_t getegid(void); | |
0c38a575 SH |
325 | extern int setuid(uid_t uid); |
326 | extern int setgid(gid_t gid); | |
0a753a76 | 327 | extern int kill(int pid, int sig); |
c623ac67 GS |
328 | #ifndef USE_PERL_SBRK |
329 | extern void *sbrk(ptrdiff_t need); | |
330 | # define HAS_SBRK_PROTO | |
331 | #endif | |
e34ffe5a | 332 | extern char * getlogin(void); |
b990f8c8 | 333 | extern int chown(const char *p, uid_t o, gid_t g); |
00b02797 | 334 | extern int mkstemp(const char *path); |
e37d7e38 | 335 | #endif |
d55594ae | 336 | |
f3986ebb GS |
337 | #undef Stat |
338 | #define Stat win32_stat | |
3e3baf6d | 339 | |
f3986ebb GS |
340 | #undef init_os_extras |
341 | #define init_os_extras Perl_init_os_extras | |
390b85e7 | 342 | |
22239a37 | 343 | DllExport void Perl_win32_init(int *argcp, char ***argvp); |
23f519f0 | 344 | DllExport void Perl_win32_term(void); |
cb359b41 | 345 | DllExport void Perl_init_os_extras(void); |
c5be433b GS |
346 | DllExport void win32_str_os_error(void *sv, DWORD err); |
347 | DllExport int RunPerl(int argc, char **argv, char **env); | |
0551aaa8 | 348 | |
635bbe87 GS |
349 | typedef struct { |
350 | HANDLE childStdIn; | |
351 | HANDLE childStdOut; | |
352 | HANDLE childStdErr; | |
f83751a7 GS |
353 | /* |
354 | * the following correspond to the fields of the same name | |
355 | * in the STARTUPINFO structure. Embedders can use these to | |
356 | * control the spawning process' look. | |
357 | * Example - to hide the window of the spawned process: | |
358 | * dwFlags = STARTF_USESHOWWINDOW; | |
359 | * wShowWindow = SW_HIDE; | |
360 | */ | |
361 | DWORD dwFlags; | |
3fadfdf1 NIS |
362 | DWORD dwX; |
363 | DWORD dwY; | |
364 | DWORD dwXSize; | |
365 | DWORD dwYSize; | |
366 | DWORD dwXCountChars; | |
367 | DWORD dwYCountChars; | |
f83751a7 | 368 | DWORD dwFillAttribute; |
3fadfdf1 | 369 | WORD wShowWindow; |
635bbe87 GS |
370 | } child_IO_table; |
371 | ||
372 | DllExport void win32_get_child_IO(child_IO_table* ptr); | |
b69b0499 | 373 | DllExport HWND win32_create_message_window(void); |
635bbe87 | 374 | |
f3986ebb | 375 | extern int my_fclose(FILE *); |
e6a0bbf8 NC |
376 | extern char * win32_get_privlib(const char *pl, STRLEN *const len); |
377 | extern char * win32_get_sitelib(const char *pl, STRLEN *const len); | |
378 | extern char * win32_get_vendorlib(const char *pl, STRLEN *const len); | |
d55594ae | 379 | |
1c0ca838 GS |
380 | #ifdef PERL_IMPLICIT_SYS |
381 | extern void win32_delete_internal_host(void *h); | |
382 | #endif | |
383 | ||
c9beaf97 SH |
384 | extern int win32_get_errno(int err); |
385 | ||
fe1c5936 | 386 | extern const char * const staticlinkmodules[]; |
390b85e7 GS |
387 | |
388 | END_EXTERN_C | |
d55594ae | 389 | |
68dc0745 | 390 | typedef char * caddr_t; /* In malloc.c (core address). */ |
0a753a76 | 391 | |
68dc0745 | 392 | /* |
68dc0745 | 393 | * handle socket stuff, assuming socket is always available |
394 | */ | |
0a753a76 | 395 | #include <sys/socket.h> |
396 | #include <netdb.h> | |
397 | ||
bbc8f9de NIS |
398 | #ifdef MYMALLOC |
399 | #define EMBEDMYMALLOC /**/ | |
400 | /* #define USE_PERL_SBRK /**/ | |
401 | /* #define PERL_SBRK_VIA_MALLOC /**/ | |
402 | #endif | |
403 | ||
e68cb057 | 404 | #ifdef PERL_TEXTMODE_SCRIPTS |
c39cd008 | 405 | # define PERL_SCRIPT_MODE "r" |
a868473f | 406 | #else |
c39cd008 | 407 | # define PERL_SCRIPT_MODE "rb" |
a868473f NIS |
408 | #endif |
409 | ||
3fadfdf1 NIS |
410 | /* |
411 | * Now Win32 specific per-thread data stuff | |
3352bfcb GS |
412 | */ |
413 | ||
aeecf691 JD |
414 | /* Leave the first couple ids after WM_USER unused because they |
415 | * might be used by an embedding application, and on Windows | |
416 | * version before 2000 we might end up eating those messages | |
417 | * if they were not meant for us. | |
418 | */ | |
419 | #define WM_USER_MIN (WM_USER+30) | |
420 | #define WM_USER_MESSAGE (WM_USER_MIN) | |
421 | #define WM_USER_KILL (WM_USER_MIN+1) | |
422 | #define WM_USER_MAX (WM_USER_MIN+1) | |
423 | ||
3352bfcb GS |
424 | struct thread_intern { |
425 | /* XXX can probably use one buffer instead of several */ | |
426 | char Wstrerror_buffer[512]; | |
427 | struct servent Wservent; | |
428 | char Wgetlogin_buffer[128]; | |
f4257e4d | 429 | int Winit_socktype; |
3352bfcb | 430 | char Wcrypt_buffer[30]; |
3352bfcb GS |
431 | # ifdef USE_RTL_THREAD_API |
432 | void * retv; /* slot for thread return value */ | |
433 | # endif | |
02637f4c JD |
434 | BOOL Wuse_showwindow; |
435 | WORD Wshowwindow; | |
3352bfcb GS |
436 | }; |
437 | ||
4b556e6c | 438 | #define HAVE_INTERP_INTERN |
0aaad0ff GS |
439 | typedef struct { |
440 | long num; | |
441 | DWORD pids[MAXIMUM_WAIT_OBJECTS]; | |
7766f137 | 442 | HANDLE handles[MAXIMUM_WAIT_OBJECTS]; |
0aaad0ff GS |
443 | } child_tab; |
444 | ||
aeecf691 JD |
445 | #ifdef USE_ITHREADS |
446 | typedef struct { | |
447 | long num; | |
448 | DWORD pids[MAXIMUM_WAIT_OBJECTS]; | |
449 | HANDLE handles[MAXIMUM_WAIT_OBJECTS]; | |
450 | HWND message_hwnds[MAXIMUM_WAIT_OBJECTS]; | |
8a3cb9c6 | 451 | char sigterm[MAXIMUM_WAIT_OBJECTS]; |
aeecf691 JD |
452 | } pseudo_child_tab; |
453 | #endif | |
454 | ||
3fadfdf1 NIS |
455 | #ifndef Sighandler_t |
456 | typedef Signal_t (*Sighandler_t) (int); | |
457 | #define Sighandler_t Sighandler_t | |
458 | #endif | |
459 | ||
4b556e6c | 460 | struct interp_intern { |
0aaad0ff GS |
461 | char * perlshell_tokens; |
462 | char ** perlshell_vec; | |
463 | long perlshell_items; | |
464 | struct av * fdpid; | |
465 | child_tab * children; | |
7766f137 GS |
466 | #ifdef USE_ITHREADS |
467 | DWORD pseudo_id; | |
aeecf691 | 468 | pseudo_child_tab * pseudo_children; |
7766f137 GS |
469 | #endif |
470 | void * internal_host; | |
3352bfcb | 471 | struct thread_intern thr_intern; |
aeecf691 | 472 | HWND message_hwnd; |
8fb3fcfb | 473 | UINT timerid; |
05ec9bb3 | 474 | unsigned poll_count; |
3fadfdf1 | 475 | Sighandler_t sigtable[SIG_SIZE]; |
4b556e6c JD |
476 | }; |
477 | ||
8fb3fcfb NIS |
478 | DllExport int win32_async_check(pTHX); |
479 | ||
05ec9bb3 | 480 | #define WIN32_POLL_INTERVAL 32768 |
8fb3fcfb | 481 | #define PERL_ASYNC_CHECK() if (w32_do_async || PL_sig_pending) win32_async_check(aTHX) |
4b556e6c | 482 | |
0aaad0ff GS |
483 | #define w32_perlshell_tokens (PL_sys_intern.perlshell_tokens) |
484 | #define w32_perlshell_vec (PL_sys_intern.perlshell_vec) | |
485 | #define w32_perlshell_items (PL_sys_intern.perlshell_items) | |
486 | #define w32_fdpid (PL_sys_intern.fdpid) | |
487 | #define w32_children (PL_sys_intern.children) | |
488 | #define w32_num_children (w32_children->num) | |
489 | #define w32_child_pids (w32_children->pids) | |
7766f137 GS |
490 | #define w32_child_handles (w32_children->handles) |
491 | #define w32_pseudo_id (PL_sys_intern.pseudo_id) | |
492 | #define w32_pseudo_children (PL_sys_intern.pseudo_children) | |
493 | #define w32_num_pseudo_children (w32_pseudo_children->num) | |
494 | #define w32_pseudo_child_pids (w32_pseudo_children->pids) | |
495 | #define w32_pseudo_child_handles (w32_pseudo_children->handles) | |
aeecf691 | 496 | #define w32_pseudo_child_message_hwnds (w32_pseudo_children->message_hwnds) |
8a3cb9c6 | 497 | #define w32_pseudo_child_sigterm (w32_pseudo_children->sigterm) |
7766f137 | 498 | #define w32_internal_host (PL_sys_intern.internal_host) |
8fb3fcfb | 499 | #define w32_timerid (PL_sys_intern.timerid) |
aeecf691 | 500 | #define w32_message_hwnd (PL_sys_intern.message_hwnd) |
3fadfdf1 | 501 | #define w32_sighandler (PL_sys_intern.sigtable) |
05ec9bb3 NIS |
502 | #define w32_poll_count (PL_sys_intern.poll_count) |
503 | #define w32_do_async (w32_poll_count++ > WIN32_POLL_INTERVAL) | |
3db8f154 MB |
504 | #define w32_strerror_buffer (PL_sys_intern.thr_intern.Wstrerror_buffer) |
505 | #define w32_getlogin_buffer (PL_sys_intern.thr_intern.Wgetlogin_buffer) | |
506 | #define w32_crypt_buffer (PL_sys_intern.thr_intern.Wcrypt_buffer) | |
507 | #define w32_servent (PL_sys_intern.thr_intern.Wservent) | |
f4257e4d | 508 | #define w32_init_socktype (PL_sys_intern.thr_intern.Winit_socktype) |
3db8f154 MB |
509 | #define w32_use_showwindow (PL_sys_intern.thr_intern.Wuse_showwindow) |
510 | #define w32_showwindow (PL_sys_intern.thr_intern.Wshowwindow) | |
c53bd28a | 511 | |
7766f137 | 512 | #ifdef USE_ITHREADS |
8a3cb9c6 JD |
513 | void win32_wait_for_children(pTHX); |
514 | # define PERL_WAIT_FOR_CHILDREN win32_wait_for_children(aTHX) | |
7766f137 GS |
515 | #endif |
516 | ||
b47a847f DD |
517 | #ifdef PERL_CORE |
518 | /* C doesn't like repeat struct definitions */ | |
519 | #if defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION>=3) | |
520 | #undef _CRTIMP | |
521 | #endif | |
522 | #ifndef _CRTIMP | |
523 | #define _CRTIMP __declspec(dllimport) | |
524 | #endif | |
525 | ||
526 | ||
527 | /* VV 2005 has multiple ioinfo struct definitions through VC 2005's release life | |
528 | * VC 2008-2012 have been stable but do not assume future VCs will have the | |
529 | * same ioinfo struct, just because past struct stability. If research is done | |
530 | * on the CRTs of future VS, the version check can be bumped up so the newer | |
531 | * VC uses a fixed ioinfo size. | |
532 | */ | |
533 | #if ! (_MSC_VER < 1400 || (_MSC_VER >= 1500 && _MSC_VER <= 1700) \ | |
534 | || defined(__MINGW32__)) | |
535 | /* size of ioinfo struct is determined at runtime */ | |
536 | # define WIN32_DYN_IOINFO_SIZE | |
537 | #endif | |
538 | ||
539 | #ifndef WIN32_DYN_IOINFO_SIZE | |
540 | /* | |
541 | * Control structure for lowio file handles | |
542 | */ | |
543 | typedef struct { | |
544 | intptr_t osfhnd;/* underlying OS file HANDLE */ | |
545 | char osfile; /* attributes of file (e.g., open in text mode?) */ | |
546 | char pipech; /* one char buffer for handles opened on pipes */ | |
547 | int lockinitflag; | |
548 | CRITICAL_SECTION lock; | |
549 | /* this struct defintion breaks ABI compatibility with | |
550 | * not using, cl.exe's native VS version specitfic CRT. */ | |
551 | # if _MSC_VER >= 1400 && _MSC_VER < 1500 | |
552 | # error "This ioinfo struct is incomplete for Visual C 2005" | |
553 | # endif | |
554 | /* VC 2005 CRT has atleast 3 different definitions of this struct based on the | |
555 | * CRT DLL's build number. */ | |
556 | # if _MSC_VER >= 1500 | |
557 | # ifndef _SAFECRT_IMPL | |
558 | /* Not used in the safecrt downlevel. We do not define them, so we cannot | |
559 | * use them accidentally */ | |
560 | char textmode : 7;/* __IOINFO_TM_ANSI or __IOINFO_TM_UTF8 or __IOINFO_TM_UTF16LE */ | |
561 | char unicode : 1; /* Was the file opened as unicode? */ | |
562 | char pipech2[2]; /* 2 more peak ahead chars for UNICODE mode */ | |
563 | __int64 startpos; /* File position that matches buffer start */ | |
564 | BOOL utf8translations; /* Buffer contains translations other than CRLF*/ | |
565 | char dbcsBuffer; /* Buffer for the lead byte of dbcs when converting from dbcs to unicode */ | |
566 | BOOL dbcsBufferUsed; /* Bool for the lead byte buffer is used or not */ | |
567 | # endif | |
568 | # endif | |
569 | } ioinfo; | |
570 | #else | |
571 | typedef intptr_t ioinfo; | |
572 | #endif | |
573 | ||
574 | /* | |
575 | * Array of arrays of control structures for lowio files. | |
576 | */ | |
577 | EXTERN_C _CRTIMP ioinfo* __pioinfo[]; | |
578 | ||
579 | /* | |
580 | * Definition of IOINFO_L2E, the log base 2 of the number of elements in each | |
581 | * array of ioinfo structs. | |
582 | */ | |
583 | #define IOINFO_L2E 5 | |
584 | ||
585 | /* | |
586 | * Definition of IOINFO_ARRAY_ELTS, the number of elements in ioinfo array | |
587 | */ | |
588 | #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) | |
589 | ||
590 | /* | |
591 | * Access macros for getting at an ioinfo struct and its fields from a | |
592 | * file handle | |
593 | */ | |
594 | #ifdef WIN32_DYN_IOINFO_SIZE | |
595 | # define _pioinfo(i) ((intptr_t *) \ | |
596 | (((Size_t)__pioinfo[(i) >> IOINFO_L2E])/* * to head of array ioinfo [] */\ | |
597 | /* offset to the head of a particular ioinfo struct */ \ | |
598 | + (((i) & (IOINFO_ARRAY_ELTS - 1)) * w32_ioinfo_size)) \ | |
599 | ) | |
600 | /* first slice of ioinfo is always the OS handle */ | |
601 | # define _osfhnd(i) (*(_pioinfo(i))) | |
602 | #else | |
603 | # define _pioinfo(i) (__pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1))) | |
604 | # define _osfhnd(i) (_pioinfo(i)->osfhnd) | |
605 | #endif | |
606 | ||
607 | /* since we are not doing a dup2(), this works fine */ | |
608 | # define _set_osfhnd(fh, osfh) (void)(_osfhnd(fh) = (intptr_t)osfh) | |
609 | #endif /* PERL_CORE */ | |
610 | ||
3fadfdf1 | 611 | /* IO.xs and POSIX.xs define PERLIO_NOT_STDIO to 1 */ |
6e22d046 JH |
612 | #if defined(PERL_EXT_IO) || defined(PERL_EXT_POSIX) |
613 | #undef PERLIO_NOT_STDIO | |
614 | #endif | |
adb71456 NIS |
615 | #define PERLIO_NOT_STDIO 0 |
616 | ||
617 | #include "perlio.h" | |
618 | ||
4f63d024 GS |
619 | /* |
620 | * This provides a layer of functions and macros to ensure extensions will | |
621 | * get to use the same RTL functions as the core. | |
622 | */ | |
623 | #include "win32iop.h" | |
624 | ||
b4748376 NIS |
625 | #define EXEC_ARGV_CAST(x) ((const char *const *) x) |
626 | ||
f4958739 | 627 | DllExport void *win32_signal_context(void); |
1018e26f NIS |
628 | #define PERL_GET_SIG_CONTEXT win32_signal_context() |
629 | ||
45496817 | 630 | #ifdef UNDER_CE |
7bd379e8 YO |
631 | #define Win_GetModuleHandle XCEGetModuleHandleA |
632 | #define Win_GetProcAddress XCEGetProcAddressA | |
633 | #define Win_GetModuleFileName XCEGetModuleFileNameA | |
634 | #define Win_CreateSemaphore CreateSemaphoreW | |
635 | #else | |
636 | #define Win_GetModuleHandle GetModuleHandle | |
637 | #define Win_GetProcAddress GetProcAddress | |
638 | #define Win_GetModuleFileName GetModuleFileName | |
639 | #define Win_CreateSemaphore CreateSemaphore | |
640 | #endif | |
641 | ||
68dc0745 | 642 | #endif /* _INC_WIN32_PERL5 */ |
7a9ec5a3 | 643 |