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
12 #if defined(PERL_OBJECT) || defined(PERL_CAPI)
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 # define WIN32SCK_IS_STDSCK /* don't pull in custom wsock layer */
19 # ifdef PERL_GLOBAL_STRUCT
20 # error PERL_GLOBAL_STRUCT cannot be defined with PERL_OBJECT
22 # define win32_get_privlib PerlEnv_lib_path
23 # define win32_get_sitelib PerlEnv_sitelib_path
26 #if defined(PERL_IMPLICIT_CONTEXT)
27 # define PERL_GET_INTERP ((PerlInterpreter*)GetPerlInterpreter())
28 # define PERL_SET_INTERP(i) (SetPerlInterpreter(i))
32 typedef long long __int64;
33 # define Win32_Winsock
34 /* GCC does not do __declspec() - render it a nop
35 * and turn on options to avoid importing data
38 # define __declspec(x)
41 # define PERL_GLOBAL_STRUCT
48 /* Define DllExport akin to perl's EXT,
49 * If we are in the DLL or mimicing the DLL for Win95 work round
50 * then Export the symbol,
51 * otherwise import it.
54 #if defined(PERL_OBJECT)
57 #if defined(PERLDLL) || defined(WIN95FIX)
59 /*#define DllExport __declspec(dllexport)*/ /* noises with VC5+sp3 */
61 #define DllExport __declspec(dllimport)
65 #define WIN32_LEAN_AND_MEAN
68 #ifdef WIN32_LEAN_AND_MEAN /* C file is NOT a Perl5 original. */
69 #define CONTEXT PERL_CONTEXT /* Avoid conflict of CONTEXT defs. */
70 #endif /*WIN32_LEAN_AND_MEAN */
72 #ifndef TLS_OUT_OF_INDEXES
73 #define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
98 char sysname[SYS_NMLN];
99 char nodename[SYS_NMLN];
100 char release[SYS_NMLN];
101 char version[SYS_NMLN];
102 char machine[SYS_NMLN];
105 #ifndef START_EXTERN_C
108 # define START_EXTERN_C extern "C" {
109 # define END_EXTERN_C }
110 # define EXTERN_C extern "C"
112 # define START_EXTERN_C
113 # define END_EXTERN_C
119 #define DOSISH 1 /* no escaping our roots */
120 #define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */
122 /* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as
123 * real filehandles. XXX Should always be defined (the other version is untested) */
124 #define USE_SOCKETS_AS_HANDLES
126 /* read() and write() aren't transparent for socket handles */
127 #define PERL_SOCK_SYSREAD_IS_RECV
128 #define PERL_SOCK_SYSWRITE_IS_SEND
131 /* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls
132 * to read the environment, bypassing the runtime's (usually broken)
133 * facilities for accessing the same. See note in util.c/my_setenv(). */
134 /*#define USE_WIN32_RTL_ENV */
136 /* Define USE_FIXED_OSFHANDLE to fix VC's _open_osfhandle() on W95.
137 * Can only enable it if not using the DLL CRT (it doesn't expose internals) */
138 #if defined(_MSC_VER) && !defined(_DLL) && defined(_M_IX86)
139 #define USE_FIXED_OSFHANDLE
142 #define ENV_IS_CASELESS
144 #ifndef VER_PLATFORM_WIN32_WINDOWS /* VC-2.0 headers don't have this */
145 #define VER_PLATFORM_WIN32_WINDOWS 1
148 #ifndef FILE_SHARE_DELETE /* VC-4.0 headers don't have this */
149 #define FILE_SHARE_DELETE 0x00000004
152 /* access() mode bits */
160 /* Compiler-specific stuff. */
162 #ifdef __BORLANDC__ /* Borland C++ */
164 #define _access access
166 #include <sys/types.h>
169 #define DllMain DllEntryPoint
172 #pragma warn -ccc /* "condition is always true/false" */
173 #pragma warn -rch /* "unreachable code" */
174 #pragma warn -sig /* "conversion may lose significant digits" */
175 #pragma warn -pia /* "possibly incorrect assignment" */
176 #pragma warn -par /* "parameter 'foo' is never used" */
177 #pragma warn -aus /* "'foo' is assigned a value that is never used" */
178 #pragma warn -use /* "'foo' is declared but never used" */
179 #pragma warn -csu /* "comparing signed and unsigned values" */
180 #pragma warn -pro /* "call to function with no prototype" */
181 #pragma warn -stu /* "undefined structure 'foo'" */
183 /* Borland is picky about a bare member function name used as its ptr */
185 # define MEMBER_TO_FPTR(name) &(name)
190 #ifdef _MSC_VER /* Microsoft Visual C++ */
194 typedef unsigned short mode_t;
195 #pragma warning(disable: 4018 4035 4101 4102 4244 4245 4761)
199 /* Visual C thinks that a pointer to a member variable is 16 bytes in size. */
200 #define STRUCT_MGVTBL_DEFINITION \
203 int (CPERLscope(*svt_get))(pTHX_ SV *sv, MAGIC* mg); \
204 char handle_VC_problem1[16]; \
207 int (CPERLscope(*svt_set))(pTHX_ SV *sv, MAGIC* mg); \
208 char handle_VC_problem2[16]; \
211 U32 (CPERLscope(*svt_len))(pTHX_ SV *sv, MAGIC* mg); \
212 char handle_VC_problem3[16]; \
215 int (CPERLscope(*svt_clear))(pTHX_ SV *sv, MAGIC* mg); \
216 char handle_VC_problem4[16]; \
219 int (CPERLscope(*svt_free))(pTHX_ SV *sv, MAGIC* mg); \
220 char handle_VC_problem5[16]; \
224 #define BASEOP_DEFINITION \
227 OP* (CPERLscope(*op_ppaddr))(pTHX); \
228 char handle_VC_problem[12]; \
235 #endif /* PERL_OBJECT */
237 #endif /* _MSC_VER */
239 #ifdef __MINGW32__ /* Minimal Gnu-Win32 */
244 #define _environ environ
246 #define flushall _flushall
247 #define fcloseall _fcloseall
250 # define MEMBER_TO_FPTR(name) &(name)
254 # define _O_NOINHERIT 0x0080
255 # ifndef _NO_OLDNAMES
256 # define O_NOINHERIT _O_NOINHERIT
261 # define _O_NOINHERIT 0x0080
262 # ifndef _NO_OLDNAMES
263 # define O_NOINHERIT _O_NOINHERIT
267 #endif /* __MINGW32__ */
269 /* compatibility stuff for other compilers goes here */
274 /* For UNIX compatibility. */
276 extern uid_t getuid(void);
277 extern gid_t getgid(void);
278 extern uid_t geteuid(void);
279 extern gid_t getegid(void);
280 extern int setuid(uid_t uid);
281 extern int setgid(gid_t gid);
282 extern int kill(int pid, int sig);
283 extern void *sbrk(int need);
284 extern char * getlogin(void);
285 extern int chown(const char *p, uid_t o, gid_t g);
288 #define Stat win32_stat
290 #undef init_os_extras
291 #define init_os_extras Perl_init_os_extras
293 DllExport void Perl_win32_init(int *argcp, char ***argvp);
294 DllExport void Perl_init_os_extras();
295 DllExport void win32_str_os_error(void *sv, DWORD err);
296 DllExport int RunPerl(int argc, char **argv, char **env);
297 DllExport bool SetPerlInterpreter(void* interp);
298 DllExport void* GetPerlInterpreter(void);
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 * win32_get_privlib(char *pl);
308 extern char * win32_get_sitelib(char *pl);
309 extern int IsWin95(void);
310 extern int IsWinNT(void);
312 extern char * staticlinkmodules[];
316 typedef char * caddr_t; /* In malloc.c (core address). */
319 * handle socket stuff, assuming socket is always available
321 #include <sys/socket.h>
325 #define EMBEDMYMALLOC /**/
326 /* #define USE_PERL_SBRK /**/
327 /* #define PERL_SBRK_VIA_MALLOC /**/
330 #if defined(PERLDLL) && !defined(PERL_CORE)
334 #ifdef USE_BINMODE_SCRIPTS
335 #define PERL_SCRIPT_MODE "rb"
336 EXT void win32_strip_return(struct sv *sv);
338 #define PERL_SCRIPT_MODE "r"
339 #define win32_strip_return(sv) NOOP
342 #define HAVE_INTERP_INTERN
345 DWORD pids[MAXIMUM_WAIT_OBJECTS];
351 struct host_link * next;
354 struct interp_intern {
355 char * perlshell_tokens;
356 char ** perlshell_vec;
357 long perlshell_items;
359 child_tab * children;
360 HANDLE child_handles[MAXIMUM_WAIT_OBJECTS];
361 struct host_link * hostlist;
365 #define w32_perlshell_tokens (PL_sys_intern.perlshell_tokens)
366 #define w32_perlshell_vec (PL_sys_intern.perlshell_vec)
367 #define w32_perlshell_items (PL_sys_intern.perlshell_items)
368 #define w32_fdpid (PL_sys_intern.fdpid)
369 #define w32_children (PL_sys_intern.children)
370 #define w32_num_children (w32_children->num)
371 #define w32_child_pids (w32_children->pids)
372 #define w32_child_handles (PL_sys_intern.child_handles)
373 #define w32_host_link (PL_sys_intern.hostlist)
376 * Now Win32 specific per-thread data stuff
380 # ifndef USE_DECLSPEC_THREAD
381 # define HAVE_THREAD_INTERN
383 struct thread_intern {
384 /* XXX can probably use one buffer instead of several */
385 char Wstrerror_buffer[512];
386 struct servent Wservent;
387 char Wgetlogin_buffer[128];
388 char Ww32_perllib_root[MAX_PATH+1];
389 # ifdef USE_SOCKETS_AS_HANDLES
392 # ifdef HAVE_DES_FCRYPT
393 char Wcrypt_buffer[30];
395 # ifdef USE_RTL_THREAD_API
396 void * retv; /* slot for thread return value */
399 # endif /* !USE_DECLSPEC_THREAD */
400 #endif /* USE_THREADS */
402 /* UNICODE<>ANSI translation helpers */
403 /* Use CP_ACP when mode is ANSI */
404 /* Use CP_UTF8 when mode is UTF8 */
406 #define A2WHELPER(lpa, lpw, nBytes)\
407 lpw[0] = 0, MultiByteToWideChar((IN_UTF8) ? CP_UTF8 : CP_ACP, 0, lpa, -1, lpw, (nBytes/sizeof(WCHAR)))
409 #define W2AHELPER(lpw, lpa, nChars)\
410 lpa[0] = '\0', WideCharToMultiByte((IN_UTF8) ? CP_UTF8 : CP_ACP, 0, lpw, -1, (LPSTR)lpa, nChars, NULL, NULL)
412 #define USING_WIDE() (PerlEnv_os_id() == VER_PLATFORM_WIN32_NT)
415 * This provides a layer of functions and macros to ensure extensions will
416 * get to use the same RTL functions as the core.
418 #include "win32iop.h"
420 #endif /* _INC_WIN32_PERL5 */