Commit | Line | Data |
68dc0745 |
1 | /* WIN32.H |
2 | * |
3 | * (c) 1995 Microsoft Corporation. All rights reserved. |
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 | |
9d8a25dc |
12 | #ifdef PERL_OBJECT |
e9ee4811 |
13 | # define DYNAMIC_ENV_FETCH |
14 | # define ENV_HV_NAME "___ENV_HV_NAME___" |
15 | # define prime_env_iter() |
ab39fa9d |
16 | # define WIN32IO_IS_STDIO /* don't pull in custom stdio layer */ |
17 | # ifdef PERL_GLOBAL_STRUCT |
18 | # error PERL_GLOBAL_STRUCT cannot be defined with PERL_OBJECT |
19 | # endif |
e5a95ffb |
20 | # define win32_get_privlib PerlEnv_lib_path |
ab39fa9d |
21 | # define win32_get_sitelib PerlEnv_sitelib_path |
9d8a25dc |
22 | #endif |
23 | |
a835ef8a |
24 | #ifdef __GNUC__ |
a835ef8a |
25 | typedef long long __int64; |
db15561c |
26 | # define Win32_Winsock |
22239a37 |
27 | /* GCC does not do __declspec() - render it a nop |
28 | * and turn on options to avoid importing data |
29 | */ |
b1d1613b |
30 | #ifndef __declspec |
db15561c |
31 | # define __declspec(x) |
b1d1613b |
32 | #endif |
db15561c |
33 | # ifndef PERL_OBJECT |
34 | # define PERL_GLOBAL_STRUCT |
b86a2fa7 |
35 | # ifndef MULTIPLICITY |
36 | # define MULTIPLICITY |
37 | # endif |
db15561c |
38 | # endif |
a835ef8a |
39 | #endif |
40 | |
22239a37 |
41 | /* Define DllExport akin to perl's EXT, |
42 | * If we are in the DLL or mimicing the DLL for Win95 work round |
43 | * then Export the symbol, |
44 | * otherwise import it. |
45 | */ |
46 | |
c69f6586 |
47 | #if defined(PERL_OBJECT) |
48 | #define DllExport |
49 | #else |
22239a37 |
50 | #if defined(PERLDLL) || defined(WIN95FIX) |
852c2e52 |
51 | #define DllExport |
52 | /*#define DllExport __declspec(dllexport)*/ /* noises with VC5+sp3 */ |
22239a37 |
53 | #else |
54 | #define DllExport __declspec(dllimport) |
55 | #endif |
c69f6586 |
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> |
75 | #ifndef EXT |
76 | #include "EXTERN.h" |
77 | #endif |
78 | |
c69f112c |
79 | struct tms { |
80 | long tms_utime; |
81 | long tms_stime; |
82 | long tms_cutime; |
83 | long tms_cstime; |
84 | }; |
85 | |
390b85e7 |
86 | #ifndef START_EXTERN_C |
b3e5c95e |
87 | #undef EXTERN_C |
390b85e7 |
88 | #ifdef __cplusplus |
89 | # define START_EXTERN_C extern "C" { |
90 | # define END_EXTERN_C } |
91 | # define EXTERN_C extern "C" |
92 | #else |
93 | # define START_EXTERN_C |
94 | # define END_EXTERN_C |
95 | # define EXTERN_C |
96 | #endif |
97 | #endif |
98 | |
99 | #define STANDARD_C 1 |
100 | #define DOSISH 1 /* no escaping our roots */ |
101 | #define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */ |
0a753a76 |
102 | |
f3986ebb |
103 | /* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as |
104 | * real filehandles. XXX Should always be defined (the other version is untested) */ |
105 | #define USE_SOCKETS_AS_HANDLES |
106 | |
a7092146 |
107 | /* read() and write() aren't transparent for socket handles */ |
108 | #define PERL_SOCK_SYSREAD_IS_RECV |
109 | #define PERL_SOCK_SYSWRITE_IS_SEND |
110 | |
111 | |
f3986ebb |
112 | /* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls |
113 | * to read the environment, bypassing the runtime's (usually broken) |
114 | * facilities for accessing the same. See note in util.c/my_setenv(). */ |
115 | /*#define USE_WIN32_RTL_ENV */ |
0a753a76 |
116 | |
f3986ebb |
117 | /* Define USE_FIXED_OSFHANDLE to fix VC's _open_osfhandle() on W95. |
118 | * Can only enable it if not using the DLL CRT (it doesn't expose internals) */ |
119 | #if defined(_MSC_VER) && !defined(_DLL) && defined(_M_IX86) |
120 | #define USE_FIXED_OSFHANDLE |
121 | #endif |
122 | |
902173a3 |
123 | #define ENV_IS_CASELESS |
124 | |
d41de25a |
125 | #ifndef VER_PLATFORM_WIN32_WINDOWS /* VC-2.0 headers don't have this */ |
f3986ebb |
126 | #define VER_PLATFORM_WIN32_WINDOWS 1 |
127 | #endif |
128 | |
d41de25a |
129 | #ifndef FILE_SHARE_DELETE /* VC-4.0 headers don't have this */ |
130 | #define FILE_SHARE_DELETE 0x00000004 |
131 | #endif |
132 | |
327c3667 |
133 | /* access() mode bits */ |
134 | #ifndef R_OK |
135 | # define R_OK 4 |
136 | # define W_OK 2 |
137 | # define X_OK 1 |
138 | # define F_OK 0 |
139 | #endif |
140 | |
f3986ebb |
141 | /* Compiler-specific stuff. */ |
142 | |
910dfcc8 |
143 | #ifdef __BORLANDC__ /* Borland C++ */ |
3e3baf6d |
144 | |
145 | #define _access access |
146 | #define _chdir chdir |
147 | #include <sys/types.h> |
148 | |
84902520 |
149 | #ifndef DllMain |
150 | #define DllMain DllEntryPoint |
151 | #endif |
152 | |
189b2af5 |
153 | #pragma warn -ccc /* "condition is always true/false" */ |
154 | #pragma warn -rch /* "unreachable code" */ |
155 | #pragma warn -sig /* "conversion may lose significant digits" */ |
156 | #pragma warn -pia /* "possibly incorrect assignment" */ |
157 | #pragma warn -par /* "parameter 'foo' is never used" */ |
158 | #pragma warn -aus /* "'foo' is assigned a value that is never used" */ |
159 | #pragma warn -use /* "'foo' is declared but never used" */ |
160 | #pragma warn -csu /* "comparing signed and unsigned values" */ |
161 | #pragma warn -pro /* "call to function with no prototype" */ |
327c3667 |
162 | #pragma warn -stu /* "undefined structure 'foo'" */ |
3e3baf6d |
163 | |
4b556e6c |
164 | #define USE_RTL_WAIT /* Borland has a working wait() */ |
165 | |
ac4c12e7 |
166 | /* Borland is picky about a bare member function name used as its ptr */ |
167 | #ifdef PERL_OBJECT |
168 | #define FUNC_NAME_TO_PTR(name) &(name) |
169 | #endif |
170 | |
910dfcc8 |
171 | #endif |
3e3baf6d |
172 | |
f3986ebb |
173 | #ifdef _MSC_VER /* Microsoft Visual C++ */ |
174 | |
0a753a76 |
175 | typedef long uid_t; |
176 | typedef long gid_t; |
f3986ebb |
177 | #pragma warning(disable: 4018 4035 4101 4102 4244 4245 4761) |
178 | |
0f4eea8f |
179 | #ifndef PERL_OBJECT |
180 | |
181 | /* Visual C thinks that a pointer to a member variable is 16 bytes in size. */ |
182 | #define STRUCT_MGVTBL_DEFINITION \ |
183 | struct mgvtbl { \ |
184 | union { \ |
185 | int (CPERLscope(*svt_get)) _((SV *sv, MAGIC* mg)); \ |
186 | char handle_VC_problem1[16]; \ |
187 | }; \ |
188 | union { \ |
189 | int (CPERLscope(*svt_set)) _((SV *sv, MAGIC* mg)); \ |
190 | char handle_VC_problem2[16]; \ |
191 | }; \ |
192 | union { \ |
193 | U32 (CPERLscope(*svt_len)) _((SV *sv, MAGIC* mg)); \ |
194 | char handle_VC_problem3[16]; \ |
195 | }; \ |
196 | union { \ |
197 | int (CPERLscope(*svt_clear)) _((SV *sv, MAGIC* mg)); \ |
198 | char handle_VC_problem4[16]; \ |
199 | }; \ |
200 | union { \ |
201 | int (CPERLscope(*svt_free)) _((SV *sv, MAGIC* mg)); \ |
202 | char handle_VC_problem5[16]; \ |
203 | }; \ |
204 | } |
205 | |
206 | #define BASEOP_DEFINITION \ |
207 | OP* op_next; \ |
208 | OP* op_sibling; \ |
209 | OP* (CPERLscope(*op_ppaddr))_((ARGSproto)); \ |
210 | char handle_VC_problem[12]; \ |
211 | PADOFFSET op_targ; \ |
212 | OPCODE op_type; \ |
213 | U16 op_seq; \ |
214 | U8 op_flags; \ |
215 | U8 op_private; |
216 | |
217 | #define UNION_ANY_DEFINITION union any { \ |
218 | void* any_ptr; \ |
219 | I32 any_i32; \ |
220 | IV any_iv; \ |
221 | long any_long; \ |
222 | void (CPERLscope(*any_dptr)) _((void*)); \ |
223 | char handle_VC_problem[16]; \ |
224 | } |
225 | |
226 | #endif /* PERL_OBJECT */ |
227 | |
f3986ebb |
228 | #endif /* _MSC_VER */ |
229 | |
910dfcc8 |
230 | #ifdef __MINGW32__ /* Minimal Gnu-Win32 */ |
231 | |
232 | typedef long uid_t; |
233 | typedef long gid_t; |
b1d1613b |
234 | #ifndef _environ |
3730b96e |
235 | #define _environ environ |
b1d1613b |
236 | #endif |
3730b96e |
237 | #define flushall _flushall |
238 | #define fcloseall _fcloseall |
910dfcc8 |
239 | |
db15561c |
240 | #ifdef PERL_OBJECT |
241 | #define FUNC_NAME_TO_PTR(name) &(name) |
242 | #endif |
243 | |
ac4c12e7 |
244 | #ifndef _O_NOINHERIT |
245 | # define _O_NOINHERIT 0x0080 |
246 | # ifndef _NO_OLDNAMES |
247 | # define O_NOINHERIT _O_NOINHERIT |
248 | # endif |
249 | #endif |
250 | |
ba3eb2af |
251 | #ifndef _O_NOINHERIT |
252 | # define _O_NOINHERIT 0x0080 |
253 | # ifndef _NO_OLDNAMES |
254 | # define O_NOINHERIT _O_NOINHERIT |
255 | # endif |
256 | #endif |
257 | |
910dfcc8 |
258 | #endif /* __MINGW32__ */ |
259 | |
f3986ebb |
260 | /* compatibility stuff for other compilers goes here */ |
0a753a76 |
261 | |
0a753a76 |
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); |
161b471a |
274 | extern void *sbrk(int need); |
e34ffe5a |
275 | extern char * getlogin(void); |
b990f8c8 |
276 | extern int chown(const char *p, uid_t o, gid_t g); |
d55594ae |
277 | |
f3986ebb |
278 | #undef Stat |
279 | #define Stat win32_stat |
3e3baf6d |
280 | |
f3986ebb |
281 | #undef init_os_extras |
282 | #define init_os_extras Perl_init_os_extras |
390b85e7 |
283 | |
22239a37 |
284 | DllExport void Perl_win32_init(int *argcp, char ***argvp); |
285 | DllExport void Perl_init_os_extras(void); |
3730b96e |
286 | DllExport void win32_str_os_error(void *sv, DWORD err); |
0551aaa8 |
287 | |
f3986ebb |
288 | #ifndef USE_SOCKETS_AS_HANDLES |
289 | extern FILE * my_fdopen(int, char *); |
d55594ae |
290 | #endif |
f3986ebb |
291 | extern int my_fclose(FILE *); |
2d7a9237 |
292 | extern int do_aspawn(void *really, void **mark, void **sp); |
f3986ebb |
293 | extern int do_spawn(char *cmd); |
2d7a9237 |
294 | extern int do_spawn_nowait(char *cmd); |
f3986ebb |
295 | extern char do_exec(char *cmd); |
e5a95ffb |
296 | extern char * win32_get_privlib(char *pl); |
00dc2f4f |
297 | extern char * win32_get_sitelib(char *pl); |
f3986ebb |
298 | extern int IsWin95(void); |
299 | extern int IsWinNT(void); |
d55594ae |
300 | |
f3986ebb |
301 | extern char * staticlinkmodules[]; |
390b85e7 |
302 | |
303 | END_EXTERN_C |
d55594ae |
304 | |
68dc0745 |
305 | typedef char * caddr_t; /* In malloc.c (core address). */ |
0a753a76 |
306 | |
68dc0745 |
307 | /* |
68dc0745 |
308 | * handle socket stuff, assuming socket is always available |
309 | */ |
0a753a76 |
310 | #include <sys/socket.h> |
311 | #include <netdb.h> |
312 | |
bbc8f9de |
313 | #ifdef MYMALLOC |
314 | #define EMBEDMYMALLOC /**/ |
315 | /* #define USE_PERL_SBRK /**/ |
316 | /* #define PERL_SBRK_VIA_MALLOC /**/ |
317 | #endif |
318 | |
c31fac66 |
319 | #if defined(PERLDLL) && !defined(PERL_CORE) |
bbc8f9de |
320 | #define PERL_CORE |
321 | #endif |
322 | |
a868473f |
323 | #ifdef USE_BINMODE_SCRIPTS |
324 | #define PERL_SCRIPT_MODE "rb" |
325 | EXT void win32_strip_return(struct sv *sv); |
326 | #else |
327 | #define PERL_SCRIPT_MODE "r" |
328 | #define win32_strip_return(sv) NOOP |
329 | #endif |
330 | |
4b556e6c |
331 | #define HAVE_INTERP_INTERN |
332 | struct interp_intern { |
333 | char * w32_perlshell_tokens; |
334 | char ** w32_perlshell_vec; |
335 | long w32_perlshell_items; |
336 | struct av * w32_fdpid; |
337 | #ifndef USE_RTL_WAIT |
338 | long w32_num_children; |
339 | HANDLE w32_child_pids[MAXIMUM_WAIT_OBJECTS]; |
340 | #endif |
341 | }; |
342 | |
b28d0864 |
343 | #define w32_perlshell_tokens (PL_sys_intern.w32_perlshell_tokens) |
344 | #define w32_perlshell_vec (PL_sys_intern.w32_perlshell_vec) |
345 | #define w32_perlshell_items (PL_sys_intern.w32_perlshell_items) |
346 | #define w32_fdpid (PL_sys_intern.w32_fdpid) |
4b556e6c |
347 | |
348 | #ifndef USE_RTL_WAIT |
b28d0864 |
349 | # define w32_num_children (PL_sys_intern.w32_num_children) |
350 | # define w32_child_pids (PL_sys_intern.w32_child_pids) |
4b556e6c |
351 | #endif |
352 | |
c53bd28a |
353 | /* |
354 | * Now Win32 specific per-thread data stuff |
355 | */ |
356 | |
357 | #ifdef USE_THREADS |
e34ffe5a |
358 | # ifndef USE_DECLSPEC_THREAD |
359 | # define HAVE_THREAD_INTERN |
360 | |
361 | struct thread_intern { |
362 | /* XXX can probably use one buffer instead of several */ |
363 | char Wstrerror_buffer[512]; |
364 | struct servent Wservent; |
365 | char Wgetlogin_buffer[128]; |
4b556e6c |
366 | char Ww32_perllib_root[MAX_PATH+1]; |
401ef382 |
367 | # ifdef USE_SOCKETS_AS_HANDLES |
368 | int Winit_socktype; |
369 | # endif |
e34ffe5a |
370 | # ifdef HAVE_DES_FCRYPT |
371 | char Wcrypt_buffer[30]; |
372 | # endif |
2d7a9237 |
373 | # ifdef USE_RTL_THREAD_API |
374 | void * retv; /* slot for thread return value */ |
375 | # endif |
c53bd28a |
376 | }; |
e34ffe5a |
377 | # endif /* !USE_DECLSPEC_THREAD */ |
378 | #endif /* USE_THREADS */ |
c53bd28a |
379 | |
68dc0745 |
380 | #endif /* _INC_WIN32_PERL5 */ |