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