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