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