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