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 |
13 | #define ENV_HV_NAME "ENV_HV_NAME" |
14 | #define DYNAMIC_ENV_FETCH |
15 | #define prime_env_iter() |
16 | #ifdef PERL_GLOBAL_STRUCT |
17 | #error PERL_GLOBAL_STRUCT cannot be defined with PERL_OBJECT |
18 | #endif |
19 | #define win32_perllib_path PerlEnv_lib_path |
20 | #endif |
21 | |
a835ef8a |
22 | #ifdef __GNUC__ |
a835ef8a |
23 | typedef long long __int64; |
24 | #define Win32_Winsock |
22239a37 |
25 | /* GCC does not do __declspec() - render it a nop |
26 | * and turn on options to avoid importing data |
27 | */ |
28 | #define __declspec(x) |
29 | #define PERL_GLOBAL_STRUCT |
30 | #define MULTIPLICITY |
d56e6723 |
31 | #ifndef TLS_OUT_OF_INDEXES |
32 | #define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF |
33 | #endif |
a835ef8a |
34 | #endif |
35 | |
22239a37 |
36 | /* Define DllExport akin to perl's EXT, |
37 | * If we are in the DLL or mimicing the DLL for Win95 work round |
38 | * then Export the symbol, |
39 | * otherwise import it. |
40 | */ |
41 | |
c69f6586 |
42 | #if defined(PERL_OBJECT) |
43 | #define DllExport |
44 | #else |
22239a37 |
45 | #if defined(PERLDLL) || defined(WIN95FIX) |
46 | #define DllExport __declspec(dllexport) |
47 | #else |
48 | #define DllExport __declspec(dllimport) |
49 | #endif |
c69f6586 |
50 | #endif |
c69f112c |
51 | |
0a753a76 |
52 | #define WIN32_LEAN_AND_MEAN |
53 | #include <windows.h> |
54 | |
68dc0745 |
55 | #ifdef WIN32_LEAN_AND_MEAN /* C file is NOT a Perl5 original. */ |
56 | #define CONTEXT PERL_CONTEXT /* Avoid conflict of CONTEXT defs. */ |
57 | #define index strchr /* Why 'index'? */ |
58 | #endif /*WIN32_LEAN_AND_MEAN */ |
0a753a76 |
59 | |
60 | #include <dirent.h> |
61 | #include <io.h> |
62 | #include <process.h> |
63 | #include <stdio.h> |
64 | #include <direct.h> |
390b85e7 |
65 | #include <stdlib.h> |
66 | #ifndef EXT |
67 | #include "EXTERN.h" |
68 | #endif |
69 | |
c69f112c |
70 | struct tms { |
71 | long tms_utime; |
72 | long tms_stime; |
73 | long tms_cutime; |
74 | long tms_cstime; |
75 | }; |
76 | |
390b85e7 |
77 | #ifndef START_EXTERN_C |
78 | #ifdef __cplusplus |
79 | # define START_EXTERN_C extern "C" { |
80 | # define END_EXTERN_C } |
81 | # define EXTERN_C extern "C" |
82 | #else |
83 | # define START_EXTERN_C |
84 | # define END_EXTERN_C |
85 | # define EXTERN_C |
86 | #endif |
87 | #endif |
88 | |
89 | #define STANDARD_C 1 |
90 | #define DOSISH 1 /* no escaping our roots */ |
91 | #define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */ |
0a753a76 |
92 | |
f3986ebb |
93 | /* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as |
94 | * real filehandles. XXX Should always be defined (the other version is untested) */ |
95 | #define USE_SOCKETS_AS_HANDLES |
96 | |
97 | /* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls |
98 | * to read the environment, bypassing the runtime's (usually broken) |
99 | * facilities for accessing the same. See note in util.c/my_setenv(). */ |
100 | /*#define USE_WIN32_RTL_ENV */ |
0a753a76 |
101 | |
f3986ebb |
102 | /* Define USE_FIXED_OSFHANDLE to fix VC's _open_osfhandle() on W95. |
103 | * Can only enable it if not using the DLL CRT (it doesn't expose internals) */ |
104 | #if defined(_MSC_VER) && !defined(_DLL) && defined(_M_IX86) |
105 | #define USE_FIXED_OSFHANDLE |
106 | #endif |
107 | |
902173a3 |
108 | #define ENV_IS_CASELESS |
109 | |
f3986ebb |
110 | #ifndef VER_PLATFORM_WIN32_WINDOWS /* VC-2.0 headers dont have this */ |
111 | #define VER_PLATFORM_WIN32_WINDOWS 1 |
112 | #endif |
113 | |
114 | /* Compiler-specific stuff. */ |
115 | |
910dfcc8 |
116 | #ifdef __BORLANDC__ /* Borland C++ */ |
3e3baf6d |
117 | |
118 | #define _access access |
119 | #define _chdir chdir |
120 | #include <sys/types.h> |
121 | |
84902520 |
122 | #ifndef DllMain |
123 | #define DllMain DllEntryPoint |
124 | #endif |
125 | |
189b2af5 |
126 | #pragma warn -ccc /* "condition is always true/false" */ |
127 | #pragma warn -rch /* "unreachable code" */ |
128 | #pragma warn -sig /* "conversion may lose significant digits" */ |
129 | #pragma warn -pia /* "possibly incorrect assignment" */ |
130 | #pragma warn -par /* "parameter 'foo' is never used" */ |
131 | #pragma warn -aus /* "'foo' is assigned a value that is never used" */ |
132 | #pragma warn -use /* "'foo' is declared but never used" */ |
133 | #pragma warn -csu /* "comparing signed and unsigned values" */ |
134 | #pragma warn -pro /* "call to function with no prototype" */ |
3e3baf6d |
135 | |
910dfcc8 |
136 | #endif |
3e3baf6d |
137 | |
f3986ebb |
138 | #ifdef _MSC_VER /* Microsoft Visual C++ */ |
139 | |
0a753a76 |
140 | typedef long uid_t; |
141 | typedef long gid_t; |
f3986ebb |
142 | #pragma warning(disable: 4018 4035 4101 4102 4244 4245 4761) |
143 | |
144 | #endif /* _MSC_VER */ |
145 | |
910dfcc8 |
146 | #ifdef __MINGW32__ /* Minimal Gnu-Win32 */ |
147 | |
148 | typedef long uid_t; |
149 | typedef long gid_t; |
3730b96e |
150 | #define _environ environ |
151 | #define flushall _flushall |
152 | #define fcloseall _fcloseall |
910dfcc8 |
153 | |
154 | #endif /* __MINGW32__ */ |
155 | |
f3986ebb |
156 | /* compatibility stuff for other compilers goes here */ |
0a753a76 |
157 | |
0a753a76 |
158 | |
390b85e7 |
159 | START_EXTERN_C |
f3986ebb |
160 | |
161 | /* For UNIX compatibility. */ |
162 | |
0a753a76 |
163 | extern uid_t getuid(void); |
164 | extern gid_t getgid(void); |
165 | extern uid_t geteuid(void); |
166 | extern gid_t getegid(void); |
0a753a76 |
167 | extern int setuid(uid_t uid); |
168 | extern int setgid(gid_t gid); |
169 | extern int kill(int pid, int sig); |
161b471a |
170 | extern void *sbrk(int need); |
e34ffe5a |
171 | extern char * getlogin(void); |
b990f8c8 |
172 | extern int chown(const char *p, uid_t o, gid_t g); |
d55594ae |
173 | |
f3986ebb |
174 | #undef Stat |
175 | #define Stat win32_stat |
3e3baf6d |
176 | |
f3986ebb |
177 | #undef init_os_extras |
178 | #define init_os_extras Perl_init_os_extras |
390b85e7 |
179 | |
22239a37 |
180 | DllExport void Perl_win32_init(int *argcp, char ***argvp); |
181 | DllExport void Perl_init_os_extras(void); |
3730b96e |
182 | DllExport void win32_str_os_error(void *sv, DWORD err); |
0551aaa8 |
183 | |
f3986ebb |
184 | #ifndef USE_SOCKETS_AS_HANDLES |
185 | extern FILE * my_fdopen(int, char *); |
d55594ae |
186 | #endif |
f3986ebb |
187 | extern int my_fclose(FILE *); |
2d7a9237 |
188 | extern int do_aspawn(void *really, void **mark, void **sp); |
f3986ebb |
189 | extern int do_spawn(char *cmd); |
2d7a9237 |
190 | extern int do_spawn_nowait(char *cmd); |
f3986ebb |
191 | extern char do_exec(char *cmd); |
2d7a9237 |
192 | extern char * win32_perllib_path(char *sfx,...); |
f3986ebb |
193 | extern int IsWin95(void); |
194 | extern int IsWinNT(void); |
d55594ae |
195 | |
f3986ebb |
196 | extern char * staticlinkmodules[]; |
390b85e7 |
197 | |
198 | END_EXTERN_C |
d55594ae |
199 | |
68dc0745 |
200 | typedef char * caddr_t; /* In malloc.c (core address). */ |
0a753a76 |
201 | |
68dc0745 |
202 | /* |
68dc0745 |
203 | * handle socket stuff, assuming socket is always available |
204 | */ |
0a753a76 |
205 | #include <sys/socket.h> |
206 | #include <netdb.h> |
207 | |
bbc8f9de |
208 | #ifdef MYMALLOC |
209 | #define EMBEDMYMALLOC /**/ |
210 | /* #define USE_PERL_SBRK /**/ |
211 | /* #define PERL_SBRK_VIA_MALLOC /**/ |
212 | #endif |
213 | |
c31fac66 |
214 | #if defined(PERLDLL) && !defined(PERL_CORE) |
bbc8f9de |
215 | #define PERL_CORE |
216 | #endif |
217 | |
a868473f |
218 | #ifdef USE_BINMODE_SCRIPTS |
219 | #define PERL_SCRIPT_MODE "rb" |
220 | EXT void win32_strip_return(struct sv *sv); |
221 | #else |
222 | #define PERL_SCRIPT_MODE "r" |
223 | #define win32_strip_return(sv) NOOP |
224 | #endif |
225 | |
c53bd28a |
226 | /* |
227 | * Now Win32 specific per-thread data stuff |
228 | */ |
229 | |
230 | #ifdef USE_THREADS |
e34ffe5a |
231 | # ifndef USE_DECLSPEC_THREAD |
232 | # define HAVE_THREAD_INTERN |
233 | |
234 | struct thread_intern { |
235 | /* XXX can probably use one buffer instead of several */ |
236 | char Wstrerror_buffer[512]; |
237 | struct servent Wservent; |
238 | char Wgetlogin_buffer[128]; |
239 | # ifdef HAVE_DES_FCRYPT |
240 | char Wcrypt_buffer[30]; |
241 | # endif |
2d7a9237 |
242 | # ifdef USE_RTL_THREAD_API |
243 | void * retv; /* slot for thread return value */ |
244 | # endif |
c53bd28a |
245 | }; |
e34ffe5a |
246 | # endif /* !USE_DECLSPEC_THREAD */ |
247 | #endif /* USE_THREADS */ |
c53bd28a |
248 | |
68dc0745 |
249 | #endif /* _INC_WIN32_PERL5 */ |