Create a struct for all perls globals (as an option)
[p5sagit/p5-mst-13.2.git] / win32 / win32.h
1 /* WIN32.H
2  *
3  * (c) 1995 Microsoft Corporation. All rights reserved. 
4  *              Developed by hip communications inc., http://info.hip.com/info/
5  *
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.
8  */
9 #ifndef  _INC_WIN32_PERL5
10 #define  _INC_WIN32_PERL5
11
12 #ifdef __GNUC__
13 typedef long long __int64;
14 #define Win32_Winsock
15 /* GCC does not do __declspec() - render it a nop 
16  * and turn on options to avoid importing data 
17  */
18 #define __declspec(x)
19 #define PERL_GLOBAL_STRUCT
20 #define MULTIPLICITY
21 #endif
22
23 /* Define DllExport akin to perl's EXT, 
24  * If we are in the DLL or mimicing the DLL for Win95 work round
25  * then Export the symbol, 
26  * otherwise import it.
27  */
28
29 #if defined(PERLDLL) || defined(WIN95FIX)
30 #define DllExport __declspec(dllexport)
31 #else 
32 #define DllExport __declspec(dllimport)
33 #endif
34
35 #define  WIN32_LEAN_AND_MEAN
36 #include <windows.h>
37
38 #ifdef   WIN32_LEAN_AND_MEAN            /* C file is NOT a Perl5 original. */
39 #define  CONTEXT        PERL_CONTEXT    /* Avoid conflict of CONTEXT defs. */
40 #define  index          strchr          /* Why 'index'? */
41 #endif /*WIN32_LEAN_AND_MEAN */
42
43 #include <dirent.h>
44 #include <io.h>
45 #include <process.h>
46 #include <stdio.h>
47 #include <direct.h>
48 #include <stdlib.h>
49 #ifndef EXT
50 #include "EXTERN.h"
51 #endif
52
53 struct tms {
54         long    tms_utime;
55         long    tms_stime;
56         long    tms_cutime;
57         long    tms_cstime;
58 };
59
60 #ifndef START_EXTERN_C
61 #ifdef __cplusplus
62 #  define START_EXTERN_C extern "C" {
63 #  define END_EXTERN_C }
64 #  define EXTERN_C extern "C"
65 #else
66 #  define START_EXTERN_C 
67 #  define END_EXTERN_C 
68 #  define EXTERN_C
69 #endif
70 #endif
71
72 #define  STANDARD_C     1
73 #define  DOSISH         1               /* no escaping our roots */
74 #define  OP_BINARY      O_BINARY        /* mistake in in pp_sys.c? */
75
76 /* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as
77  * real filehandles. XXX Should always be defined (the other version is untested) */
78 #define USE_SOCKETS_AS_HANDLES
79
80 /* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls
81  * to read the environment, bypassing the runtime's (usually broken)
82  * facilities for accessing the same.  See note in util.c/my_setenv(). */
83 /*#define USE_WIN32_RTL_ENV */
84
85 /* Define USE_FIXED_OSFHANDLE to fix VC's _open_osfhandle() on W95.
86  * Can only enable it if not using the DLL CRT (it doesn't expose internals) */
87 #if defined(_MSC_VER) && !defined(_DLL) && defined(_M_IX86)
88 #define USE_FIXED_OSFHANDLE
89 #endif
90
91 #ifndef VER_PLATFORM_WIN32_WINDOWS      /* VC-2.0 headers dont have this */
92 #define VER_PLATFORM_WIN32_WINDOWS      1
93 #endif
94
95 /* Compiler-specific stuff. */
96
97 #ifdef __BORLANDC__             /* Microsoft Visual C++ */
98
99 #define _access access
100 #define _chdir chdir
101 #include <sys/types.h>
102
103 #ifndef DllMain
104 #define DllMain DllEntryPoint
105 #endif
106
107 #pragma warn -ccc
108 #pragma warn -rch
109 #pragma warn -sig
110 #pragma warn -pia
111 #pragma warn -par
112 #pragma warn -aus
113 #pragma warn -use
114 #pragma warn -csu
115 #pragma warn -pro
116
117 #else
118
119 #ifdef _MSC_VER                 /* Microsoft Visual C++ */
120
121 typedef long            uid_t;
122 typedef long            gid_t;
123 #pragma  warning(disable: 4018 4035 4101 4102 4244 4245 4761)
124
125 #endif /* _MSC_VER */
126
127 /* compatibility stuff for other compilers goes here */
128
129 #endif
130
131 START_EXTERN_C
132
133 /* For UNIX compatibility. */
134
135 extern  uid_t   getuid(void);
136 extern  gid_t   getgid(void);
137 extern  uid_t   geteuid(void);
138 extern  gid_t   getegid(void);
139 extern  int     setuid(uid_t uid);
140 extern  int     setgid(gid_t gid);
141 extern  int     kill(int pid, int sig);
142 extern  void    *sbrk(int need);
143
144 #undef   Stat
145 #define  Stat           win32_stat
146
147 #undef   init_os_extras
148 #define  init_os_extras Perl_init_os_extras
149
150 DllExport void          Perl_win32_init(int *argcp, char ***argvp);
151 DllExport void          Perl_init_os_extras(void);
152
153 #ifndef USE_SOCKETS_AS_HANDLES
154 extern FILE *           my_fdopen(int, char *);
155 #endif
156 extern int              my_fclose(FILE *);
157 extern int              do_aspawn(void* really, void ** mark, void ** arglast);
158 extern int              do_spawn(char *cmd);
159 extern char             do_exec(char *cmd);
160 extern char *           win32PerlLibPath(char *sfx,...);
161 extern int              IsWin95(void);
162 extern int              IsWinNT(void);
163
164 extern char *           staticlinkmodules[];
165
166 END_EXTERN_C
167
168 typedef  char *         caddr_t;        /* In malloc.c (core address). */
169
170 /*
171  * handle socket stuff, assuming socket is always available
172  */
173 #include <sys/socket.h>
174 #include <netdb.h>
175
176 #ifdef MYMALLOC
177 #define EMBEDMYMALLOC   /**/
178 /* #define USE_PERL_SBRK        /**/
179 /* #define PERL_SBRK_VIA_MALLOC /**/
180 #endif
181
182 #if defined(PERLDLL) && !defined(PERL_CORE)
183 #define PERL_CORE
184 #endif
185
186 #ifdef USE_BINMODE_SCRIPTS
187 #define PERL_SCRIPT_MODE "rb"
188 EXT void win32_strip_return(struct sv *sv);
189 #else
190 #define PERL_SCRIPT_MODE "r"
191 #define win32_strip_return(sv) NOOP
192 #endif
193
194 /* 
195  * Now Win32 specific per-thread data stuff 
196  */
197
198 #ifdef USE_THREADS
199 #ifndef USE_DECLSPEC_THREAD
200 #define HAVE_THREAD_INTERN
201
202 struct thread_intern
203 {
204  char           Wstrerror_buffer[512];
205  struct servent Wservent;
206 };
207 #endif
208 #endif
209
210 #endif /* _INC_WIN32_PERL5 */