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