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
31 # define __declspec(x)
34 # define PERL_GLOBAL_STRUCT
41 /* Define DllExport akin to perl's EXT,
42 * If we are in the DLL or mimicing the DLL for Win95 work round
43 * then Export the symbol,
44 * otherwise import it.
47 #if defined(PERL_OBJECT)
50 #if defined(PERLDLL) || defined(WIN95FIX)
52 /*#define DllExport __declspec(dllexport)*/ /* noises with VC5+sp3 */
54 #define DllExport __declspec(dllimport)
58 #define WIN32_LEAN_AND_MEAN
61 #ifdef WIN32_LEAN_AND_MEAN /* C file is NOT a Perl5 original. */
62 #define CONTEXT PERL_CONTEXT /* Avoid conflict of CONTEXT defs. */
63 #endif /*WIN32_LEAN_AND_MEAN */
65 #ifndef TLS_OUT_OF_INDEXES
66 #define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
91 char sysname[SYS_NMLN];
92 char nodename[SYS_NMLN];
93 char release[SYS_NMLN];
94 char version[SYS_NMLN];
95 char machine[SYS_NMLN];
98 #ifndef START_EXTERN_C
101 # define START_EXTERN_C extern "C" {
102 # define END_EXTERN_C }
103 # define EXTERN_C extern "C"
105 # define START_EXTERN_C
106 # define END_EXTERN_C
112 #define DOSISH 1 /* no escaping our roots */
113 #define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */
115 /* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as
116 * real filehandles. XXX Should always be defined (the other version is untested) */
117 #define USE_SOCKETS_AS_HANDLES
119 /* read() and write() aren't transparent for socket handles */
120 #define PERL_SOCK_SYSREAD_IS_RECV
121 #define PERL_SOCK_SYSWRITE_IS_SEND
124 /* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls
125 * to read the environment, bypassing the runtime's (usually broken)
126 * facilities for accessing the same. See note in util.c/my_setenv(). */
127 /*#define USE_WIN32_RTL_ENV */
129 /* Define USE_FIXED_OSFHANDLE to fix VC's _open_osfhandle() on W95.
130 * Can only enable it if not using the DLL CRT (it doesn't expose internals) */
131 #if defined(_MSC_VER) && !defined(_DLL) && defined(_M_IX86)
132 #define USE_FIXED_OSFHANDLE
135 #define ENV_IS_CASELESS
137 #ifndef VER_PLATFORM_WIN32_WINDOWS /* VC-2.0 headers don't have this */
138 #define VER_PLATFORM_WIN32_WINDOWS 1
141 #ifndef FILE_SHARE_DELETE /* VC-4.0 headers don't have this */
142 #define FILE_SHARE_DELETE 0x00000004
145 /* access() mode bits */
153 /* Compiler-specific stuff. */
155 #ifdef __BORLANDC__ /* Borland C++ */
157 #define _access access
159 #include <sys/types.h>
162 #define DllMain DllEntryPoint
165 #pragma warn -ccc /* "condition is always true/false" */
166 #pragma warn -rch /* "unreachable code" */
167 #pragma warn -sig /* "conversion may lose significant digits" */
168 #pragma warn -pia /* "possibly incorrect assignment" */
169 #pragma warn -par /* "parameter 'foo' is never used" */
170 #pragma warn -aus /* "'foo' is assigned a value that is never used" */
171 #pragma warn -use /* "'foo' is declared but never used" */
172 #pragma warn -csu /* "comparing signed and unsigned values" */
173 #pragma warn -pro /* "call to function with no prototype" */
174 #pragma warn -stu /* "undefined structure 'foo'" */
176 /* Borland is picky about a bare member function name used as its ptr */
178 #define FUNC_NAME_TO_PTR(name) &(name)
183 #ifdef _MSC_VER /* Microsoft Visual C++ */
187 #pragma warning(disable: 4018 4035 4101 4102 4244 4245 4761)
191 /* Visual C thinks that a pointer to a member variable is 16 bytes in size. */
192 #define STRUCT_MGVTBL_DEFINITION \
195 int (CPERLscope(*svt_get)) _((SV *sv, MAGIC* mg)); \
196 char handle_VC_problem1[16]; \
199 int (CPERLscope(*svt_set)) _((SV *sv, MAGIC* mg)); \
200 char handle_VC_problem2[16]; \
203 U32 (CPERLscope(*svt_len)) _((SV *sv, MAGIC* mg)); \
204 char handle_VC_problem3[16]; \
207 int (CPERLscope(*svt_clear)) _((SV *sv, MAGIC* mg)); \
208 char handle_VC_problem4[16]; \
211 int (CPERLscope(*svt_free)) _((SV *sv, MAGIC* mg)); \
212 char handle_VC_problem5[16]; \
216 #define BASEOP_DEFINITION \
219 OP* (CPERLscope(*op_ppaddr))_((ARGSproto)); \
220 char handle_VC_problem[12]; \
227 #define UNION_ANY_DEFINITION union any { \
232 void (CPERLscope(*any_dptr)) _((void*)); \
233 char handle_VC_problem[16]; \
236 #endif /* PERL_OBJECT */
238 #endif /* _MSC_VER */
240 #ifdef __MINGW32__ /* Minimal Gnu-Win32 */
245 #define _environ environ
247 #define flushall _flushall
248 #define fcloseall _fcloseall
251 #define FUNC_NAME_TO_PTR(name) &(name)
255 # define _O_NOINHERIT 0x0080
256 # ifndef _NO_OLDNAMES
257 # define O_NOINHERIT _O_NOINHERIT
262 # define _O_NOINHERIT 0x0080
263 # ifndef _NO_OLDNAMES
264 # define O_NOINHERIT _O_NOINHERIT
268 #endif /* __MINGW32__ */
270 /* compatibility stuff for other compilers goes here */
275 /* For UNIX compatibility. */
277 extern uid_t getuid(void);
278 extern gid_t getgid(void);
279 extern uid_t geteuid(void);
280 extern gid_t getegid(void);
281 extern int setuid(uid_t uid);
282 extern int setgid(gid_t gid);
283 extern int kill(int pid, int sig);
284 extern void *sbrk(int need);
285 extern char * getlogin(void);
286 extern int chown(const char *p, uid_t o, gid_t g);
289 #define Stat win32_stat
291 #undef init_os_extras
292 #define init_os_extras Perl_init_os_extras
294 DllExport void Perl_win32_init(int *argcp, char ***argvp);
295 DllExport void Perl_init_os_extras(void);
296 DllExport void win32_str_os_error(void *sv, DWORD err);
298 #ifndef USE_SOCKETS_AS_HANDLES
299 extern FILE * my_fdopen(int, char *);
301 extern int my_fclose(FILE *);
302 extern int do_aspawn(void *really, void **mark, void **sp);
303 extern int do_spawn(char *cmd);
304 extern int do_spawn_nowait(char *cmd);
305 extern char do_exec(char *cmd);
306 extern char * win32_get_privlib(char *pl);
307 extern char * win32_get_sitelib(char *pl);
308 extern int IsWin95(void);
309 extern int IsWinNT(void);
311 extern char * staticlinkmodules[];
315 typedef char * caddr_t; /* In malloc.c (core address). */
318 * handle socket stuff, assuming socket is always available
320 #include <sys/socket.h>
324 #define EMBEDMYMALLOC /**/
325 /* #define USE_PERL_SBRK /**/
326 /* #define PERL_SBRK_VIA_MALLOC /**/
329 #if defined(PERLDLL) && !defined(PERL_CORE)
333 #ifdef USE_BINMODE_SCRIPTS
334 #define PERL_SCRIPT_MODE "rb"
335 EXT void win32_strip_return(struct sv *sv);
337 #define PERL_SCRIPT_MODE "r"
338 #define win32_strip_return(sv) NOOP
341 #define HAVE_INTERP_INTERN
344 DWORD pids[MAXIMUM_WAIT_OBJECTS];
347 struct interp_intern {
348 char * perlshell_tokens;
349 char ** perlshell_vec;
350 long perlshell_items;
352 child_tab * children;
353 HANDLE child_handles[MAXIMUM_WAIT_OBJECTS];
357 #define w32_perlshell_tokens (PL_sys_intern.perlshell_tokens)
358 #define w32_perlshell_vec (PL_sys_intern.perlshell_vec)
359 #define w32_perlshell_items (PL_sys_intern.perlshell_items)
360 #define w32_fdpid (PL_sys_intern.fdpid)
361 #define w32_children (PL_sys_intern.children)
362 #define w32_num_children (w32_children->num)
363 #define w32_child_pids (w32_children->pids)
364 #define w32_child_handles (PL_sys_intern.child_handles)
367 * Now Win32 specific per-thread data stuff
371 # ifndef USE_DECLSPEC_THREAD
372 # define HAVE_THREAD_INTERN
374 struct thread_intern {
375 /* XXX can probably use one buffer instead of several */
376 char Wstrerror_buffer[512];
377 struct servent Wservent;
378 char Wgetlogin_buffer[128];
379 char Ww32_perllib_root[MAX_PATH+1];
380 # ifdef USE_SOCKETS_AS_HANDLES
383 # ifdef HAVE_DES_FCRYPT
384 char Wcrypt_buffer[30];
386 # ifdef USE_RTL_THREAD_API
387 void * retv; /* slot for thread return value */
390 # endif /* !USE_DECLSPEC_THREAD */
391 #endif /* USE_THREADS */
393 #endif /* _INC_WIN32_PERL5 */