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 HAS_GETENV_LEN
16 # define prime_env_iter()
17 # define WIN32IO_IS_STDIO /* don't pull in custom stdio layer */
18 # ifdef PERL_GLOBAL_STRUCT
19 # error PERL_GLOBAL_STRUCT cannot be defined with PERL_OBJECT
21 # define win32_get_privlib PerlEnv_lib_path
22 # define win32_get_sitelib PerlEnv_sitelib_path
26 typedef long long __int64;
27 # define Win32_Winsock
28 /* GCC does not do __declspec() - render it a nop
29 * and turn on options to avoid importing data
32 # define __declspec(x)
35 # define PERL_GLOBAL_STRUCT
42 /* Define DllExport akin to perl's EXT,
43 * If we are in the DLL or mimicing the DLL for Win95 work round
44 * then Export the symbol,
45 * otherwise import it.
48 #if defined(PERL_OBJECT)
51 #if defined(PERLDLL) || defined(WIN95FIX)
53 /*#define DllExport __declspec(dllexport)*/ /* noises with VC5+sp3 */
55 #define DllExport __declspec(dllimport)
59 #define WIN32_LEAN_AND_MEAN
62 #ifdef WIN32_LEAN_AND_MEAN /* C file is NOT a Perl5 original. */
63 #define CONTEXT PERL_CONTEXT /* Avoid conflict of CONTEXT defs. */
64 #endif /*WIN32_LEAN_AND_MEAN */
66 #ifndef TLS_OUT_OF_INDEXES
67 #define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
92 char sysname[SYS_NMLN];
93 char nodename[SYS_NMLN];
94 char release[SYS_NMLN];
95 char version[SYS_NMLN];
96 char machine[SYS_NMLN];
99 #ifndef START_EXTERN_C
102 # define START_EXTERN_C extern "C" {
103 # define END_EXTERN_C }
104 # define EXTERN_C extern "C"
106 # define START_EXTERN_C
107 # define END_EXTERN_C
113 #define DOSISH 1 /* no escaping our roots */
114 #define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */
116 /* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as
117 * real filehandles. XXX Should always be defined (the other version is untested) */
118 #define USE_SOCKETS_AS_HANDLES
120 /* read() and write() aren't transparent for socket handles */
121 #define PERL_SOCK_SYSREAD_IS_RECV
122 #define PERL_SOCK_SYSWRITE_IS_SEND
125 /* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls
126 * to read the environment, bypassing the runtime's (usually broken)
127 * facilities for accessing the same. See note in util.c/my_setenv(). */
128 /*#define USE_WIN32_RTL_ENV */
130 /* Define USE_FIXED_OSFHANDLE to fix VC's _open_osfhandle() on W95.
131 * Can only enable it if not using the DLL CRT (it doesn't expose internals) */
132 #if defined(_MSC_VER) && !defined(_DLL) && defined(_M_IX86)
133 #define USE_FIXED_OSFHANDLE
136 #define ENV_IS_CASELESS
138 #ifndef VER_PLATFORM_WIN32_WINDOWS /* VC-2.0 headers don't have this */
139 #define VER_PLATFORM_WIN32_WINDOWS 1
142 #ifndef FILE_SHARE_DELETE /* VC-4.0 headers don't have this */
143 #define FILE_SHARE_DELETE 0x00000004
146 /* access() mode bits */
154 /* Compiler-specific stuff. */
156 #ifdef __BORLANDC__ /* Borland C++ */
158 #define _access access
160 #include <sys/types.h>
163 #define DllMain DllEntryPoint
166 #pragma warn -ccc /* "condition is always true/false" */
167 #pragma warn -rch /* "unreachable code" */
168 #pragma warn -sig /* "conversion may lose significant digits" */
169 #pragma warn -pia /* "possibly incorrect assignment" */
170 #pragma warn -par /* "parameter 'foo' is never used" */
171 #pragma warn -aus /* "'foo' is assigned a value that is never used" */
172 #pragma warn -use /* "'foo' is declared but never used" */
173 #pragma warn -csu /* "comparing signed and unsigned values" */
174 #pragma warn -pro /* "call to function with no prototype" */
175 #pragma warn -stu /* "undefined structure 'foo'" */
177 /* Borland is picky about a bare member function name used as its ptr */
179 #define FUNC_NAME_TO_PTR(name) &(name)
184 #ifdef _MSC_VER /* Microsoft Visual C++ */
188 typedef unsigned short mode_t;
189 #pragma warning(disable: 4018 4035 4101 4102 4244 4245 4761)
193 /* Visual C thinks that a pointer to a member variable is 16 bytes in size. */
194 #define STRUCT_MGVTBL_DEFINITION \
197 int (CPERLscope(*svt_get)) _((SV *sv, MAGIC* mg)); \
198 char handle_VC_problem1[16]; \
201 int (CPERLscope(*svt_set)) _((SV *sv, MAGIC* mg)); \
202 char handle_VC_problem2[16]; \
205 U32 (CPERLscope(*svt_len)) _((SV *sv, MAGIC* mg)); \
206 char handle_VC_problem3[16]; \
209 int (CPERLscope(*svt_clear)) _((SV *sv, MAGIC* mg)); \
210 char handle_VC_problem4[16]; \
213 int (CPERLscope(*svt_free)) _((SV *sv, MAGIC* mg)); \
214 char handle_VC_problem5[16]; \
218 #define BASEOP_DEFINITION \
221 OP* (CPERLscope(*op_ppaddr))_((ARGSproto)); \
222 char handle_VC_problem[12]; \
229 #define UNION_ANY_DEFINITION union any { \
234 void (CPERLscope(*any_dptr)) _((void*)); \
235 char handle_VC_problem[16]; \
238 #endif /* PERL_OBJECT */
240 #endif /* _MSC_VER */
242 #ifdef __MINGW32__ /* Minimal Gnu-Win32 */
247 #define _environ environ
249 #define flushall _flushall
250 #define fcloseall _fcloseall
253 #define FUNC_NAME_TO_PTR(name) &(name)
257 # define _O_NOINHERIT 0x0080
258 # ifndef _NO_OLDNAMES
259 # define O_NOINHERIT _O_NOINHERIT
264 # define _O_NOINHERIT 0x0080
265 # ifndef _NO_OLDNAMES
266 # define O_NOINHERIT _O_NOINHERIT
270 #endif /* __MINGW32__ */
272 /* compatibility stuff for other compilers goes here */
277 /* For UNIX compatibility. */
279 extern uid_t getuid(void);
280 extern gid_t getgid(void);
281 extern uid_t geteuid(void);
282 extern gid_t getegid(void);
283 extern int setuid(uid_t uid);
284 extern int setgid(gid_t gid);
285 extern int kill(int pid, int sig);
286 extern void *sbrk(int need);
287 extern char * getlogin(void);
288 extern int chown(const char *p, uid_t o, gid_t g);
291 #define Stat win32_stat
293 #undef init_os_extras
294 #define init_os_extras Perl_init_os_extras
296 DllExport void Perl_win32_init(int *argcp, char ***argvp);
297 DllExport void Perl_init_os_extras(void);
298 DllExport void win32_str_os_error(void *sv, DWORD err);
300 #ifndef USE_SOCKETS_AS_HANDLES
301 extern FILE * my_fdopen(int, char *);
303 extern int my_fclose(FILE *);
304 extern int do_aspawn(void *really, void **mark, void **sp);
305 extern int do_spawn(char *cmd);
306 extern int do_spawn_nowait(char *cmd);
307 extern char do_exec(char *cmd);
308 extern char * win32_get_privlib(char *pl);
309 extern char * win32_get_sitelib(char *pl);
310 extern int IsWin95(void);
311 extern int IsWinNT(void);
313 extern char * staticlinkmodules[];
317 typedef char * caddr_t; /* In malloc.c (core address). */
320 * handle socket stuff, assuming socket is always available
322 #include <sys/socket.h>
326 #define EMBEDMYMALLOC /**/
327 /* #define USE_PERL_SBRK /**/
328 /* #define PERL_SBRK_VIA_MALLOC /**/
331 #if defined(PERLDLL) && !defined(PERL_CORE)
335 #ifdef USE_BINMODE_SCRIPTS
336 #define PERL_SCRIPT_MODE "rb"
337 EXT void win32_strip_return(struct sv *sv);
339 #define PERL_SCRIPT_MODE "r"
340 #define win32_strip_return(sv) NOOP
343 #define HAVE_INTERP_INTERN
346 DWORD pids[MAXIMUM_WAIT_OBJECTS];
349 struct interp_intern {
350 char * perlshell_tokens;
351 char ** perlshell_vec;
352 long perlshell_items;
354 child_tab * children;
355 HANDLE child_handles[MAXIMUM_WAIT_OBJECTS];
359 #define w32_perlshell_tokens (PL_sys_intern.perlshell_tokens)
360 #define w32_perlshell_vec (PL_sys_intern.perlshell_vec)
361 #define w32_perlshell_items (PL_sys_intern.perlshell_items)
362 #define w32_fdpid (PL_sys_intern.fdpid)
363 #define w32_children (PL_sys_intern.children)
364 #define w32_num_children (w32_children->num)
365 #define w32_child_pids (w32_children->pids)
366 #define w32_child_handles (PL_sys_intern.child_handles)
369 * Now Win32 specific per-thread data stuff
373 # ifndef USE_DECLSPEC_THREAD
374 # define HAVE_THREAD_INTERN
376 struct thread_intern {
377 /* XXX can probably use one buffer instead of several */
378 char Wstrerror_buffer[512];
379 struct servent Wservent;
380 char Wgetlogin_buffer[128];
381 char Ww32_perllib_root[MAX_PATH+1];
382 # ifdef USE_SOCKETS_AS_HANDLES
385 # ifdef HAVE_DES_FCRYPT
386 char Wcrypt_buffer[30];
388 # ifdef USE_RTL_THREAD_API
389 void * retv; /* slot for thread return value */
392 # endif /* !USE_DECLSPEC_THREAD */
393 #endif /* USE_THREADS */
395 #endif /* _INC_WIN32_PERL5 */