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 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
17 # define win32_get_privlib PerlEnv_lib_path
18 # define win32_get_sitelib PerlEnv_sitelib_path
22 typedef long long __int64;
23 # define Win32_Winsock
24 /* GCC does not do __declspec() - render it a nop
25 * and turn on options to avoid importing data
27 # define __declspec(x)
29 # define PERL_GLOBAL_STRUCT
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.
40 #if defined(PERL_OBJECT)
43 #if defined(PERLDLL) || defined(WIN95FIX)
45 /*#define DllExport __declspec(dllexport)*/ /* noises with VC5+sp3 */
47 #define DllExport __declspec(dllimport)
51 #define WIN32_LEAN_AND_MEAN
54 #ifdef WIN32_LEAN_AND_MEAN /* C file is NOT a Perl5 original. */
55 #define CONTEXT PERL_CONTEXT /* Avoid conflict of CONTEXT defs. */
56 #endif /*WIN32_LEAN_AND_MEAN */
58 #ifndef TLS_OUT_OF_INDEXES
59 #define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
79 #ifndef START_EXTERN_C
82 # define START_EXTERN_C extern "C" {
83 # define END_EXTERN_C }
84 # define EXTERN_C extern "C"
86 # define START_EXTERN_C
93 #define DOSISH 1 /* no escaping our roots */
94 #define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */
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
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 */
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
111 #define ENV_IS_CASELESS
113 #ifndef VER_PLATFORM_WIN32_WINDOWS /* VC-2.0 headers don't have this */
114 #define VER_PLATFORM_WIN32_WINDOWS 1
117 #ifndef FILE_SHARE_DELETE /* VC-4.0 headers don't have this */
118 #define FILE_SHARE_DELETE 0x00000004
121 /* Compiler-specific stuff. */
123 #ifdef __BORLANDC__ /* Borland C++ */
125 #define _access access
127 #include <sys/types.h>
130 #define DllMain DllEntryPoint
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" */
143 #define USE_RTL_WAIT /* Borland has a working wait() */
145 /* Borland is picky about a bare member function name used as its ptr */
147 #define FUNC_NAME_TO_PTR(name) &(name)
152 #ifdef _MSC_VER /* Microsoft Visual C++ */
156 #pragma warning(disable: 4018 4035 4101 4102 4244 4245 4761)
160 /* Visual C thinks that a pointer to a member variable is 16 bytes in size. */
161 #define STRUCT_MGVTBL_DEFINITION \
164 int (CPERLscope(*svt_get)) _((SV *sv, MAGIC* mg)); \
165 char handle_VC_problem1[16]; \
168 int (CPERLscope(*svt_set)) _((SV *sv, MAGIC* mg)); \
169 char handle_VC_problem2[16]; \
172 U32 (CPERLscope(*svt_len)) _((SV *sv, MAGIC* mg)); \
173 char handle_VC_problem3[16]; \
176 int (CPERLscope(*svt_clear)) _((SV *sv, MAGIC* mg)); \
177 char handle_VC_problem4[16]; \
180 int (CPERLscope(*svt_free)) _((SV *sv, MAGIC* mg)); \
181 char handle_VC_problem5[16]; \
185 #define BASEOP_DEFINITION \
188 OP* (CPERLscope(*op_ppaddr))_((ARGSproto)); \
189 char handle_VC_problem[12]; \
196 #define UNION_ANY_DEFINITION union any { \
201 void (CPERLscope(*any_dptr)) _((void*)); \
202 char handle_VC_problem[16]; \
205 #endif /* PERL_OBJECT */
207 #endif /* _MSC_VER */
209 #ifdef __MINGW32__ /* Minimal Gnu-Win32 */
213 #define _environ environ
214 #define flushall _flushall
215 #define fcloseall _fcloseall
218 #define FUNC_NAME_TO_PTR(name) &(name)
222 # define _O_NOINHERIT 0x0080
223 # ifndef _NO_OLDNAMES
224 # define O_NOINHERIT _O_NOINHERIT
229 # define _O_NOINHERIT 0x0080
230 # ifndef _NO_OLDNAMES
231 # define O_NOINHERIT _O_NOINHERIT
235 #endif /* __MINGW32__ */
237 /* compatibility stuff for other compilers goes here */
242 /* For UNIX compatibility. */
244 extern uid_t getuid(void);
245 extern gid_t getgid(void);
246 extern uid_t geteuid(void);
247 extern gid_t getegid(void);
248 extern int setuid(uid_t uid);
249 extern int setgid(gid_t gid);
250 extern int kill(int pid, int sig);
251 extern void *sbrk(int need);
252 extern char * getlogin(void);
253 extern int chown(const char *p, uid_t o, gid_t g);
256 #define Stat win32_stat
258 #undef init_os_extras
259 #define init_os_extras Perl_init_os_extras
261 DllExport void Perl_win32_init(int *argcp, char ***argvp);
262 DllExport void Perl_init_os_extras(void);
263 DllExport void win32_str_os_error(void *sv, DWORD err);
265 #ifndef USE_SOCKETS_AS_HANDLES
266 extern FILE * my_fdopen(int, char *);
268 extern int my_fclose(FILE *);
269 extern int do_aspawn(void *really, void **mark, void **sp);
270 extern int do_spawn(char *cmd);
271 extern int do_spawn_nowait(char *cmd);
272 extern char do_exec(char *cmd);
273 extern char * win32_get_privlib(char *pl);
274 extern char * win32_get_sitelib(char *pl);
275 extern int IsWin95(void);
276 extern int IsWinNT(void);
278 extern char * staticlinkmodules[];
282 typedef char * caddr_t; /* In malloc.c (core address). */
285 * handle socket stuff, assuming socket is always available
287 #include <sys/socket.h>
291 #define EMBEDMYMALLOC /**/
292 /* #define USE_PERL_SBRK /**/
293 /* #define PERL_SBRK_VIA_MALLOC /**/
296 #if defined(PERLDLL) && !defined(PERL_CORE)
300 #ifdef USE_BINMODE_SCRIPTS
301 #define PERL_SCRIPT_MODE "rb"
302 EXT void win32_strip_return(struct sv *sv);
304 #define PERL_SCRIPT_MODE "r"
305 #define win32_strip_return(sv) NOOP
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;
315 long w32_num_children;
316 HANDLE w32_child_pids[MAXIMUM_WAIT_OBJECTS];
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)
326 # define w32_num_children (PL_sys_intern.w32_num_children)
327 # define w32_child_pids (PL_sys_intern.w32_child_pids)
331 * Now Win32 specific per-thread data stuff
335 # ifndef USE_DECLSPEC_THREAD
336 # define HAVE_THREAD_INTERN
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];
343 char Ww32_perllib_root[MAX_PATH+1];
344 # ifdef USE_SOCKETS_AS_HANDLES
347 # ifdef HAVE_DES_FCRYPT
348 char Wcrypt_buffer[30];
350 # ifdef USE_RTL_THREAD_API
351 void * retv; /* slot for thread return value */
354 # endif /* !USE_DECLSPEC_THREAD */
355 #endif /* USE_THREADS */
357 #endif /* _INC_WIN32_PERL5 */