Two tweaks to allow quiet compile qith egcs-1.1
[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 PERL_OBJECT
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
19 #  endif
20 #  define win32_get_privlib PerlEnv_lib_path
21 #  define win32_get_sitelib PerlEnv_sitelib_path
22 #endif
23
24 #ifdef __GNUC__
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 
29  */
30 #ifndef __declspec
31 #  define __declspec(x)
32 #endif
33 #  ifndef PERL_OBJECT
34 #    define PERL_GLOBAL_STRUCT
35 #    define MULTIPLICITY
36 #  endif
37 #endif
38
39 /* Define DllExport akin to perl's EXT, 
40  * If we are in the DLL or mimicing the DLL for Win95 work round
41  * then Export the symbol, 
42  * otherwise import it.
43  */
44
45 #if defined(PERL_OBJECT)
46 #define DllExport
47 #else
48 #if defined(PERLDLL) || defined(WIN95FIX)
49 #define DllExport
50 /*#define DllExport __declspec(dllexport)*/     /* noises with VC5+sp3 */
51 #else 
52 #define DllExport __declspec(dllimport)
53 #endif
54 #endif
55
56 #define  WIN32_LEAN_AND_MEAN
57 #include <windows.h>
58
59 #ifdef   WIN32_LEAN_AND_MEAN            /* C file is NOT a Perl5 original. */
60 #define  CONTEXT        PERL_CONTEXT    /* Avoid conflict of CONTEXT defs. */
61 #endif /*WIN32_LEAN_AND_MEAN */
62
63 #ifndef TLS_OUT_OF_INDEXES
64 #define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
65 #endif
66
67 #include <dirent.h>
68 #include <io.h>
69 #include <process.h>
70 #include <stdio.h>
71 #include <direct.h>
72 #include <stdlib.h>
73 #ifndef EXT
74 #include "EXTERN.h"
75 #endif
76
77 struct tms {
78         long    tms_utime;
79         long    tms_stime;
80         long    tms_cutime;
81         long    tms_cstime;
82 };
83
84 #ifndef START_EXTERN_C
85 #undef EXTERN_C
86 #ifdef __cplusplus
87 #  define START_EXTERN_C extern "C" {
88 #  define END_EXTERN_C }
89 #  define EXTERN_C extern "C"
90 #else
91 #  define START_EXTERN_C 
92 #  define END_EXTERN_C 
93 #  define EXTERN_C
94 #endif
95 #endif
96
97 #define  STANDARD_C     1
98 #define  DOSISH         1               /* no escaping our roots */
99 #define  OP_BINARY      O_BINARY        /* mistake in in pp_sys.c? */
100
101 /* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as
102  * real filehandles. XXX Should always be defined (the other version is untested) */
103 #define USE_SOCKETS_AS_HANDLES
104
105 /* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls
106  * to read the environment, bypassing the runtime's (usually broken)
107  * facilities for accessing the same.  See note in util.c/my_setenv(). */
108 /*#define USE_WIN32_RTL_ENV */
109
110 /* Define USE_FIXED_OSFHANDLE to fix VC's _open_osfhandle() on W95.
111  * Can only enable it if not using the DLL CRT (it doesn't expose internals) */
112 #if defined(_MSC_VER) && !defined(_DLL) && defined(_M_IX86)
113 #define USE_FIXED_OSFHANDLE
114 #endif
115
116 #define ENV_IS_CASELESS
117
118 #ifndef VER_PLATFORM_WIN32_WINDOWS      /* VC-2.0 headers don't have this */
119 #define VER_PLATFORM_WIN32_WINDOWS      1
120 #endif
121
122 #ifndef FILE_SHARE_DELETE               /* VC-4.0 headers don't have this */
123 #define FILE_SHARE_DELETE               0x00000004
124 #endif
125
126 /* Compiler-specific stuff. */
127
128 #ifdef __BORLANDC__             /* Borland C++ */
129
130 #define _access access
131 #define _chdir chdir
132 #include <sys/types.h>
133
134 #ifndef DllMain
135 #define DllMain DllEntryPoint
136 #endif
137
138 #pragma warn -ccc       /* "condition is always true/false" */
139 #pragma warn -rch       /* "unreachable code" */
140 #pragma warn -sig       /* "conversion may lose significant digits" */
141 #pragma warn -pia       /* "possibly incorrect assignment" */
142 #pragma warn -par       /* "parameter 'foo' is never used" */
143 #pragma warn -aus       /* "'foo' is assigned a value that is never used" */
144 #pragma warn -use       /* "'foo' is declared but never used" */
145 #pragma warn -csu       /* "comparing signed and unsigned values" */
146 #pragma warn -pro       /* "call to function with no prototype" */
147
148 #define USE_RTL_WAIT    /* Borland has a working wait() */
149
150 /* Borland is picky about a bare member function name used as its ptr */
151 #ifdef PERL_OBJECT
152 #define FUNC_NAME_TO_PTR(name)  &(name)
153 #endif
154
155 #endif
156
157 #ifdef _MSC_VER                 /* Microsoft Visual C++ */
158
159 typedef long            uid_t;
160 typedef long            gid_t;
161 #pragma  warning(disable: 4018 4035 4101 4102 4244 4245 4761)
162
163 #ifndef PERL_OBJECT
164
165 /* Visual C thinks that a pointer to a member variable is 16 bytes in size. */
166 #define STRUCT_MGVTBL_DEFINITION                                        \
167 struct mgvtbl {                                                         \
168     union {                                                             \
169         int         (CPERLscope(*svt_get))      _((SV *sv, MAGIC* mg)); \
170         char        handle_VC_problem1[16];                             \
171     };                                                                  \
172     union {                                                             \
173         int         (CPERLscope(*svt_set))      _((SV *sv, MAGIC* mg)); \
174         char        handle_VC_problem2[16];                             \
175     };                                                                  \
176     union {                                                             \
177         U32         (CPERLscope(*svt_len))      _((SV *sv, MAGIC* mg)); \
178         char        handle_VC_problem3[16];                             \
179     };                                                                  \
180     union {                                                             \
181         int         (CPERLscope(*svt_clear))    _((SV *sv, MAGIC* mg)); \
182         char        handle_VC_problem4[16];                             \
183     };                                                                  \
184     union {                                                             \
185         int         (CPERLscope(*svt_free))     _((SV *sv, MAGIC* mg)); \
186         char        handle_VC_problem5[16];                             \
187     };                                                                  \
188 }
189
190 #define BASEOP_DEFINITION               \
191     OP*         op_next;                \
192     OP*         op_sibling;             \
193     OP*         (CPERLscope(*op_ppaddr))_((ARGSproto));         \
194     char        handle_VC_problem[12];  \
195     PADOFFSET   op_targ;                \
196     OPCODE      op_type;                \
197     U16         op_seq;                 \
198     U8          op_flags;               \
199     U8          op_private;
200
201 #define UNION_ANY_DEFINITION union any {                \
202     void*       any_ptr;                                \
203     I32         any_i32;                                \
204     IV          any_iv;                                 \
205     long        any_long;                               \
206     void        (CPERLscope(*any_dptr)) _((void*));     \
207     char        handle_VC_problem[16];                  \
208 }
209
210 #endif /* PERL_OBJECT */
211
212 #endif /* _MSC_VER */
213
214 #ifdef __MINGW32__              /* Minimal Gnu-Win32 */
215
216 typedef long            uid_t;
217 typedef long            gid_t;
218 #ifndef _environ
219 #define _environ        environ
220 #endif
221 #define flushall        _flushall
222 #define fcloseall       _fcloseall
223
224 #ifdef PERL_OBJECT
225 #define FUNC_NAME_TO_PTR(name)  &(name)
226 #endif
227
228 #ifndef _O_NOINHERIT
229 #  define _O_NOINHERIT  0x0080
230 #  ifndef _NO_OLDNAMES
231 #    define O_NOINHERIT _O_NOINHERIT
232 #  endif
233 #endif
234
235 #ifndef _O_NOINHERIT
236 #  define _O_NOINHERIT  0x0080
237 #  ifndef _NO_OLDNAMES
238 #    define O_NOINHERIT _O_NOINHERIT
239 #  endif
240 #endif
241
242 #endif /* __MINGW32__ */
243
244 /* compatibility stuff for other compilers goes here */
245
246
247 START_EXTERN_C
248
249 /* For UNIX compatibility. */
250
251 extern  uid_t   getuid(void);
252 extern  gid_t   getgid(void);
253 extern  uid_t   geteuid(void);
254 extern  gid_t   getegid(void);
255 extern  int     setuid(uid_t uid);
256 extern  int     setgid(gid_t gid);
257 extern  int     kill(int pid, int sig);
258 extern  void    *sbrk(int need);
259 extern  char *  getlogin(void);
260 extern  int     chown(const char *p, uid_t o, gid_t g);
261
262 #undef   Stat
263 #define  Stat           win32_stat
264
265 #undef   init_os_extras
266 #define  init_os_extras Perl_init_os_extras
267
268 DllExport void          Perl_win32_init(int *argcp, char ***argvp);
269 DllExport void          Perl_init_os_extras(void);
270 DllExport void          win32_str_os_error(void *sv, DWORD err);
271
272 #ifndef USE_SOCKETS_AS_HANDLES
273 extern FILE *           my_fdopen(int, char *);
274 #endif
275 extern int              my_fclose(FILE *);
276 extern int              do_aspawn(void *really, void **mark, void **sp);
277 extern int              do_spawn(char *cmd);
278 extern int              do_spawn_nowait(char *cmd);
279 extern char             do_exec(char *cmd);
280 extern char *           win32_get_privlib(char *pl);
281 extern char *           win32_get_sitelib(char *pl);
282 extern int              IsWin95(void);
283 extern int              IsWinNT(void);
284
285 extern char *           staticlinkmodules[];
286
287 END_EXTERN_C
288
289 typedef  char *         caddr_t;        /* In malloc.c (core address). */
290
291 /*
292  * handle socket stuff, assuming socket is always available
293  */
294 #include <sys/socket.h>
295 #include <netdb.h>
296
297 #ifdef MYMALLOC
298 #define EMBEDMYMALLOC   /**/
299 /* #define USE_PERL_SBRK        /**/
300 /* #define PERL_SBRK_VIA_MALLOC /**/
301 #endif
302
303 #if defined(PERLDLL) && !defined(PERL_CORE)
304 #define PERL_CORE
305 #endif
306
307 #ifdef USE_BINMODE_SCRIPTS
308 #define PERL_SCRIPT_MODE "rb"
309 EXT void win32_strip_return(struct sv *sv);
310 #else
311 #define PERL_SCRIPT_MODE "r"
312 #define win32_strip_return(sv) NOOP
313 #endif
314
315 #define HAVE_INTERP_INTERN
316 struct interp_intern {
317     char *      w32_perlshell_tokens;
318     char **     w32_perlshell_vec;
319     long        w32_perlshell_items;
320     struct av * w32_fdpid;
321 #ifndef USE_RTL_WAIT
322     long        w32_num_children;
323     HANDLE      w32_child_pids[MAXIMUM_WAIT_OBJECTS];
324 #endif
325 };
326
327 #define w32_perlshell_tokens    (PL_sys_intern.w32_perlshell_tokens)
328 #define w32_perlshell_vec       (PL_sys_intern.w32_perlshell_vec)
329 #define w32_perlshell_items     (PL_sys_intern.w32_perlshell_items)
330 #define w32_fdpid               (PL_sys_intern.w32_fdpid)
331
332 #ifndef USE_RTL_WAIT
333 #  define w32_num_children      (PL_sys_intern.w32_num_children)
334 #  define w32_child_pids        (PL_sys_intern.w32_child_pids)
335 #endif
336
337 /* 
338  * Now Win32 specific per-thread data stuff 
339  */
340
341 #ifdef USE_THREADS
342 #  ifndef USE_DECLSPEC_THREAD
343 #    define HAVE_THREAD_INTERN
344
345 struct thread_intern {
346     /* XXX can probably use one buffer instead of several */
347     char                Wstrerror_buffer[512];
348     struct servent      Wservent;
349     char                Wgetlogin_buffer[128];
350     char                Ww32_perllib_root[MAX_PATH+1];
351 #    ifdef USE_SOCKETS_AS_HANDLES
352     int                 Winit_socktype;
353 #    endif
354 #    ifdef HAVE_DES_FCRYPT
355     char                Wcrypt_buffer[30];
356 #    endif
357 #    ifdef USE_RTL_THREAD_API
358     void *              retv;   /* slot for thread return value */
359 #    endif
360 };
361 #  endif /* !USE_DECLSPEC_THREAD */
362 #endif /* USE_THREADS */
363
364 #endif /* _INC_WIN32_PERL5 */