3 * (c) 1995 Microsoft Corporation. All rights reserved.
4 * Developed by hip communications inc., http://info.hip.com/info/
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.
9 #ifndef _INC_WIN32_PERL5
10 #define _INC_WIN32_PERL5
13 # define DYNAMIC_ENV_FETCH
14 # define ENV_HV_NAME "___ENV_HV_NAME___"
15 # define prime_env_iter()
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
20 # define win32_get_privlib PerlEnv_lib_path
21 # define win32_get_sitelib PerlEnv_sitelib_path
25 typedef long long __int64;
26 # define Win32_Winsock
27 /* GCC does not do __declspec() - render it a nop
28 * and turn on options to avoid importing data
30 # define __declspec(x)
32 # define PERL_GLOBAL_STRUCT
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.
43 #if defined(PERL_OBJECT)
46 #if defined(PERLDLL) || defined(WIN95FIX)
48 /*#define DllExport __declspec(dllexport)*/ /* noises with VC5+sp3 */
50 #define DllExport __declspec(dllimport)
54 #define WIN32_LEAN_AND_MEAN
57 #ifdef WIN32_LEAN_AND_MEAN /* C file is NOT a Perl5 original. */
58 #define CONTEXT PERL_CONTEXT /* Avoid conflict of CONTEXT defs. */
59 #endif /*WIN32_LEAN_AND_MEAN */
61 #ifndef TLS_OUT_OF_INDEXES
62 #define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
82 #ifndef START_EXTERN_C
85 # define START_EXTERN_C extern "C" {
86 # define END_EXTERN_C }
87 # define EXTERN_C extern "C"
89 # define START_EXTERN_C
96 #define DOSISH 1 /* no escaping our roots */
97 #define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */
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
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 */
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
114 #define ENV_IS_CASELESS
116 #ifndef VER_PLATFORM_WIN32_WINDOWS /* VC-2.0 headers don't have this */
117 #define VER_PLATFORM_WIN32_WINDOWS 1
120 #ifndef FILE_SHARE_DELETE /* VC-4.0 headers don't have this */
121 #define FILE_SHARE_DELETE 0x00000004
124 /* Compiler-specific stuff. */
126 #ifdef __BORLANDC__ /* Borland C++ */
128 #define _access access
130 #include <sys/types.h>
133 #define DllMain DllEntryPoint
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" */
146 #define USE_RTL_WAIT /* Borland has a working wait() */
148 /* Borland is picky about a bare member function name used as its ptr */
150 #define FUNC_NAME_TO_PTR(name) &(name)
155 #ifdef _MSC_VER /* Microsoft Visual C++ */
159 #pragma warning(disable: 4018 4035 4101 4102 4244 4245 4761)
163 /* Visual C thinks that a pointer to a member variable is 16 bytes in size. */
164 #define STRUCT_MGVTBL_DEFINITION \
167 int (CPERLscope(*svt_get)) _((SV *sv, MAGIC* mg)); \
168 char handle_VC_problem1[16]; \
171 int (CPERLscope(*svt_set)) _((SV *sv, MAGIC* mg)); \
172 char handle_VC_problem2[16]; \
175 U32 (CPERLscope(*svt_len)) _((SV *sv, MAGIC* mg)); \
176 char handle_VC_problem3[16]; \
179 int (CPERLscope(*svt_clear)) _((SV *sv, MAGIC* mg)); \
180 char handle_VC_problem4[16]; \
183 int (CPERLscope(*svt_free)) _((SV *sv, MAGIC* mg)); \
184 char handle_VC_problem5[16]; \
188 #define BASEOP_DEFINITION \
191 OP* (CPERLscope(*op_ppaddr))_((ARGSproto)); \
192 char handle_VC_problem[12]; \
199 #define UNION_ANY_DEFINITION union any { \
204 void (CPERLscope(*any_dptr)) _((void*)); \
205 char handle_VC_problem[16]; \
208 #endif /* PERL_OBJECT */
210 #endif /* _MSC_VER */
212 #ifdef __MINGW32__ /* Minimal Gnu-Win32 */
216 #define _environ environ
217 #define flushall _flushall
218 #define fcloseall _fcloseall
221 #define FUNC_NAME_TO_PTR(name) &(name)
225 # define _O_NOINHERIT 0x0080
226 # ifndef _NO_OLDNAMES
227 # define O_NOINHERIT _O_NOINHERIT
232 # define _O_NOINHERIT 0x0080
233 # ifndef _NO_OLDNAMES
234 # define O_NOINHERIT _O_NOINHERIT
238 #endif /* __MINGW32__ */
240 /* compatibility stuff for other compilers goes here */
245 /* For UNIX compatibility. */
247 extern uid_t getuid(void);
248 extern gid_t getgid(void);
249 extern uid_t geteuid(void);
250 extern gid_t getegid(void);
251 extern int setuid(uid_t uid);
252 extern int setgid(gid_t gid);
253 extern int kill(int pid, int sig);
254 extern void *sbrk(int need);
255 extern char * getlogin(void);
256 extern int chown(const char *p, uid_t o, gid_t g);
259 #define Stat win32_stat
261 #undef init_os_extras
262 #define init_os_extras Perl_init_os_extras
264 DllExport void Perl_win32_init(int *argcp, char ***argvp);
265 DllExport void Perl_init_os_extras(void);
266 DllExport void win32_str_os_error(void *sv, DWORD err);
268 #ifndef USE_SOCKETS_AS_HANDLES
269 extern FILE * my_fdopen(int, char *);
271 extern int my_fclose(FILE *);
272 extern int do_aspawn(void *really, void **mark, void **sp);
273 extern int do_spawn(char *cmd);
274 extern int do_spawn_nowait(char *cmd);
275 extern char do_exec(char *cmd);
276 extern char * win32_get_privlib(char *pl);
277 extern char * win32_get_sitelib(char *pl);
278 extern int IsWin95(void);
279 extern int IsWinNT(void);
281 extern char * staticlinkmodules[];
285 typedef char * caddr_t; /* In malloc.c (core address). */
288 * handle socket stuff, assuming socket is always available
290 #include <sys/socket.h>
294 #define EMBEDMYMALLOC /**/
295 /* #define USE_PERL_SBRK /**/
296 /* #define PERL_SBRK_VIA_MALLOC /**/
299 #if defined(PERLDLL) && !defined(PERL_CORE)
303 #ifdef USE_BINMODE_SCRIPTS
304 #define PERL_SCRIPT_MODE "rb"
305 EXT void win32_strip_return(struct sv *sv);
307 #define PERL_SCRIPT_MODE "r"
308 #define win32_strip_return(sv) NOOP
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;
318 long w32_num_children;
319 HANDLE w32_child_pids[MAXIMUM_WAIT_OBJECTS];
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)
329 # define w32_num_children (PL_sys_intern.w32_num_children)
330 # define w32_child_pids (PL_sys_intern.w32_child_pids)
334 * Now Win32 specific per-thread data stuff
338 # ifndef USE_DECLSPEC_THREAD
339 # define HAVE_THREAD_INTERN
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];
346 char Ww32_perllib_root[MAX_PATH+1];
347 # ifdef USE_SOCKETS_AS_HANDLES
350 # ifdef HAVE_DES_FCRYPT
351 char Wcrypt_buffer[30];
353 # ifdef USE_RTL_THREAD_API
354 void * retv; /* slot for thread return value */
357 # endif /* !USE_DECLSPEC_THREAD */
358 #endif /* USE_THREADS */
360 #endif /* _INC_WIN32_PERL5 */