This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
COW documentation
[perl5.git] / win32 / win32.h
CommitLineData
68dc0745 1/* WIN32.H
2 *
3fadfdf1 3 * (c) 1995 Microsoft Corporation. All rights reserved.
0d130a44 4 * Developed by hip communications inc.
68dc0745 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 */
0a753a76 9#ifndef _INC_WIN32_PERL5
10#define _INC_WIN32_PERL5
11
5db10396 12#ifndef _WIN32_WINNT
8cbe99e5 13# define _WIN32_WINNT 0x0500 /* needed for CreateHardlink() etc. */
5db10396 14#endif
638eceb6 15
19253ae6
DD
16#ifdef PERL_IS_MINIPERL
17/* this macro will remove Winsock only on miniperl, PERL_IMPLICIT_SYS and
18 * makedef.pl create dependencies that will keep Winsock linked in even with
19 * this macro defined, even though sockets will be umimplemented from a script
20 * level in full perl
21 */
22# define WIN32_NO_SOCKETS
23#endif
24
25#ifdef WIN32_NO_SOCKETS
26# undef HAS_SOCKET
27# undef HAS_GETPROTOBYNAME
28# undef HAS_GETPROTOBYNUMBER
29# undef HAS_GETPROTOENT
30# undef HAS_GETNETBYNAME
31# undef HAS_GETNETBYADDR
32# undef HAS_GETNETENT
33# undef HAS_GETSERVBYNAME
34# undef HAS_GETSERVBYPORT
35# undef HAS_GETSERVENT
36# undef HAS_GETHOSTBYNAME
37# undef HAS_GETHOSTBYADDR
38# undef HAS_GETHOSTENT
39# undef HAS_SELECT
40# undef HAS_IOCTL
41# undef HAS_NTOHL
42# undef HAS_HTONL
43# undef HAS_HTONS
44# undef HAS_NTOHS
45# define WIN32SCK_IS_STDSCK
46#endif
47
acfe0abc 48#if defined(PERL_IMPLICIT_SYS)
e9ee4811 49# define DYNAMIC_ENV_FETCH
a6c40364 50# define HAS_GETENV_LEN
e9ee4811 51# define prime_env_iter()
ab39fa9d 52# define WIN32IO_IS_STDIO /* don't pull in custom stdio layer */
c5be433b 53# define WIN32SCK_IS_STDSCK /* don't pull in custom wsock layer */
ab39fa9d 54# ifdef PERL_GLOBAL_STRUCT
32e30700 55# error PERL_GLOBAL_STRUCT cannot be defined with PERL_IMPLICIT_SYS
ab39fa9d 56# endif
e5a95ffb 57# define win32_get_privlib PerlEnv_lib_path
ab39fa9d 58# define win32_get_sitelib PerlEnv_sitelib_path
4ea817c6 59# define win32_get_vendorlib PerlEnv_vendorlib_path
9d8a25dc
DL
60#endif
61
a835ef8a 62#ifdef __GNUC__
b7c82df9
GS
63# ifndef __int64 /* some versions seem to #define it already */
64# define __int64 long long
65# endif
db15561c 66# define Win32_Winsock
1c85e96a
NIS
67#ifdef __cplusplus
68/* Mingw32 gcc -xc++ objects to __attribute((unused)) at least */
3fadfdf1
NIS
69#undef PERL_UNUSED_DECL
70#define PERL_UNUSED_DECL
a835ef8a 71#endif
1c85e96a
NIS
72#endif
73
a835ef8a 74
3fadfdf1 75/* Define DllExport akin to perl's EXT,
8cbe99e5 76 * If we are in the DLL then Export the symbol,
22239a37
NIS
77 * otherwise import it.
78 */
79
5db10396 80/* now even GCC supports __declspec() */
a19baa61
DD
81/* miniperl has no reason to export anything */
82#if defined(PERL_IS_MINIPERL) && !defined(UNDER_CE) && defined(_MSC_VER)
83# define DllExport
3fadfdf1 84#else
a19baa61
DD
85# if defined(PERLDLL)
86# define DllExport __declspec(dllexport)
87# else
88# define DllExport __declspec(dllimport)
89# endif
22239a37 90#endif
c69f112c 91
50fd5961
JD
92/* The Perl APIs can only be called directly inside the perl5xx.dll.
93 * All other code has to import them. By declaring them as "dllimport"
94 * we tell the compiler to generate an indirect call instruction and
95 * avoid redirection through a call thunk.
96 *
97 * The XS code in the re extension is special, in that it redefines
98 * core APIs locally, so don't mark them as "dllimport" because GCC
99 * cannot handle this situation.
100 */
101#if !defined(PERLDLL) && !defined(PERL_EXT_RE_BUILD)
ad6ab6c5
JD
102# ifdef __cplusplus
103# define PERL_CALLCONV extern "C" __declspec(dllimport)
12a2785c 104# ifdef _MSC_VER
03c98af0 105# define PERL_CALLCONV_NO_RET extern "C" __declspec(dllimport) __declspec(noreturn)
12a2785c 106# endif
ad6ab6c5
JD
107# else
108# define PERL_CALLCONV __declspec(dllimport)
12a2785c 109# ifdef _MSC_VER
03c98af0 110# define PERL_CALLCONV_NO_RET __declspec(dllimport) __declspec(noreturn)
12a2785c 111# endif
ad6ab6c5 112# endif
50e8e1f5
DD
113#else /* MSVC noreturn support inside the interp */
114# ifdef _MSC_VER
115# define PERL_CALLCONV_NO_RET __declspec(noreturn)
116# endif
ad6ab6c5
JD
117#endif
118
98c015b7
DD
119#ifdef _MSC_VER
120# define PERL_STATIC_NO_RET __declspec(noreturn) static
121# define PERL_STATIC_INLINE_NO_RET __declspec(noreturn) PERL_STATIC_INLINE
122#endif
123
0a753a76 124#define WIN32_LEAN_AND_MEAN
125#include <windows.h>
126
fa58a56f
S
127/*
128 * Bug in winbase.h in mingw-w64 4.4.0-1 at least... they
129 * do #define GetEnvironmentStringsA GetEnvironmentStrings and fail
130 * to declare GetEnvironmentStringsA.
131 */
132#if defined(__MINGW64__) && defined(GetEnvironmentStringsA) && !defined(UNICODE)
133#ifdef __cplusplus
134extern "C" {
135#endif
136#undef GetEnvironmentStringsA
137WINBASEAPI LPCH WINAPI GetEnvironmentStringsA(VOID);
138#define GetEnvironmentStrings GetEnvironmentStringsA
139#ifdef __cplusplus
140}
141#endif
142#endif
143
68dc0745 144#ifdef WIN32_LEAN_AND_MEAN /* C file is NOT a Perl5 original. */
145#define CONTEXT PERL_CONTEXT /* Avoid conflict of CONTEXT defs. */
68dc0745 146#endif /*WIN32_LEAN_AND_MEAN */
0a753a76 147
eda5ff31
GS
148#ifndef TLS_OUT_OF_INDEXES
149#define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
150#endif
151
0a753a76 152#include <dirent.h>
153#include <io.h>
154#include <process.h>
155#include <stdio.h>
156#include <direct.h>
390b85e7 157#include <stdlib.h>
c623ac67 158#include <stddef.h>
7a1f88ac 159#include <fcntl.h>
390b85e7
GS
160#ifndef EXT
161#include "EXTERN.h"
162#endif
163
c69f112c
NIS
164struct tms {
165 long tms_utime;
166 long tms_stime;
167 long tms_cutime;
168 long tms_cstime;
169};
170
b2af26b1
GS
171#ifndef SYS_NMLN
172#define SYS_NMLN 257
173#endif
174
175struct utsname {
176 char sysname[SYS_NMLN];
177 char nodename[SYS_NMLN];
178 char release[SYS_NMLN];
179 char version[SYS_NMLN];
180 char machine[SYS_NMLN];
181};
182
390b85e7 183#ifndef START_EXTERN_C
b3e5c95e 184#undef EXTERN_C
390b85e7
GS
185#ifdef __cplusplus
186# define START_EXTERN_C extern "C" {
187# define END_EXTERN_C }
188# define EXTERN_C extern "C"
189#else
3fadfdf1
NIS
190# define START_EXTERN_C
191# define END_EXTERN_C
390b85e7
GS
192# define EXTERN_C
193#endif
194#endif
195
196#define STANDARD_C 1
197#define DOSISH 1 /* no escaping our roots */
198#define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */
0a753a76 199
a7092146 200/* read() and write() aren't transparent for socket handles */
19253ae6
DD
201#ifndef WIN32_NO_SOCKETS
202# define PERL_SOCK_SYSREAD_IS_RECV
203# define PERL_SOCK_SYSWRITE_IS_SEND
204#endif
a7092146 205
682fc664 206#define PERL_NO_FORCE_LINK /* no need for PL_force_link_funcs */
a7092146 207
902173a3
GS
208#define ENV_IS_CASELESS
209
479b2847
GS
210#define PIPESOCK_MODE "b" /* pipes, sockets default to binmode */
211
327c3667
GS
212/* access() mode bits */
213#ifndef R_OK
214# define R_OK 4
215# define W_OK 2
216# define X_OK 1
217# define F_OK 0
218#endif
219
cc236deb
GS
220/* for waitpid() */
221#ifndef WNOHANG
222# define WNOHANG 1
223#endif
224
c44d3fdb
GS
225#define PERL_GET_CONTEXT_DEFINED
226
f3986ebb
GS
227/* Compiler-specific stuff. */
228
654eccd5 229/* VC uses non-standard way to determine the size and alignment if bit-fields */
4eab039d
SH
230/* MinGW will compile with -mms-bitfields, so should use the same types */
231#define PERL_BITFIELD8 unsigned char
232#define PERL_BITFIELD16 unsigned short
233#define PERL_BITFIELD32 unsigned int
654eccd5 234
f3986ebb
GS
235#ifdef _MSC_VER /* Microsoft Visual C++ */
236
f4257e4d 237#ifndef UNDER_CE
0a753a76 238typedef long uid_t;
239typedef long gid_t;
a6c40364 240typedef unsigned short mode_t;
f4257e4d
YO
241#endif
242
c623ac67 243#pragma warning(disable: 4102) /* "unreferenced label" */
f3986ebb 244
3e7c2d43
SH
245#if _MSC_VER < 1800
246#define isnan _isnan /* Defined already in VC++ 12.0 */
247#endif
27329181
DD
248#ifdef UNDER_CE /* revisit what function this becomes celib vs corelibc, prv warning here*/
249# undef snprintf
250#endif
80e18237
SH
251#define snprintf _snprintf
252#define vsnprintf _vsnprintf
5fb4d820 253
9ea40801 254#ifdef USING_MSVC6
cab190d4
JD
255/* VC6 has broken NaN semantics: NaN == NaN returns true instead of false */
256#define NAN_COMPARE_BROKEN 1
257#endif
258
8961ec41
DD
259/* on VC2003, msvcrt.lib is missing these symbols */
260#if _MSC_VER >= 1300 && _MSC_VER < 1400
261# pragma intrinsic(_rotl64,_rotr64)
262#endif
263
f3986ebb
GS
264#endif /* _MSC_VER */
265
910dfcc8
GS
266#ifdef __MINGW32__ /* Minimal Gnu-Win32 */
267
268typedef long uid_t;
269typedef long gid_t;
b1d1613b 270#ifndef _environ
3730b96e 271#define _environ environ
b1d1613b 272#endif
3730b96e
GS
273#define flushall _flushall
274#define fcloseall _fcloseall
44604af1 275#ifndef isnan
6940069f 276#define isnan _isnan /* ...same libraries as MSVC */
44604af1 277#endif
910dfcc8 278
ac4c12e7
GS
279#ifndef _O_NOINHERIT
280# define _O_NOINHERIT 0x0080
281# ifndef _NO_OLDNAMES
282# define O_NOINHERIT _O_NOINHERIT
283# endif
284#endif
285
8659febc
S
286/* <stdint.h>, pulled in by <io.h> as of mingw-runtime-3.3, typedef's
287 * (u)intptr_t but doesn't set the _(U)INTPTR_T_DEFINED defines */
288#ifdef _STDINT_H
289# ifndef _INTPTR_T_DEFINED
290# define _INTPTR_T_DEFINED
291# endif
292# ifndef _UINTPTR_T_DEFINED
293# define _UINTPTR_T_DEFINED
294# endif
295#endif
296
f8fb7c90
GS
297#ifndef CP_UTF8
298# define CP_UTF8 65001
299#endif
300
70764c00
SH
301#endif /* __MINGW32__ */
302
c623ac67
GS
303#ifndef _INTPTR_T_DEFINED
304typedef int intptr_t;
305# define _INTPTR_T_DEFINED
306#endif
307
308#ifndef _UINTPTR_T_DEFINED
309typedef unsigned int uintptr_t;
310# define _UINTPTR_T_DEFINED
311#endif
312
390b85e7 313START_EXTERN_C
f3986ebb
GS
314
315/* For UNIX compatibility. */
316
e37d7e38 317#ifdef PERL_CORE
0a753a76 318extern uid_t getuid(void);
319extern gid_t getgid(void);
320extern uid_t geteuid(void);
321extern gid_t getegid(void);
0c38a575
SH
322extern int setuid(uid_t uid);
323extern int setgid(gid_t gid);
0a753a76 324extern int kill(int pid, int sig);
542cb85f 325extern int killpg(int pid, int sig);
c623ac67
GS
326#ifndef USE_PERL_SBRK
327extern void *sbrk(ptrdiff_t need);
328# define HAS_SBRK_PROTO
329#endif
e34ffe5a 330extern char * getlogin(void);
b990f8c8 331extern int chown(const char *p, uid_t o, gid_t g);
00b02797 332extern int mkstemp(const char *path);
e37d7e38 333#endif
d55594ae 334
f3986ebb
GS
335#undef Stat
336#define Stat win32_stat
3e3baf6d 337
f3986ebb
GS
338#undef init_os_extras
339#define init_os_extras Perl_init_os_extras
390b85e7 340
22239a37 341DllExport void Perl_win32_init(int *argcp, char ***argvp);
23f519f0 342DllExport void Perl_win32_term(void);
cb359b41 343DllExport void Perl_init_os_extras(void);
c5be433b
GS
344DllExport void win32_str_os_error(void *sv, DWORD err);
345DllExport int RunPerl(int argc, char **argv, char **env);
0551aaa8 346
635bbe87
GS
347typedef struct {
348 HANDLE childStdIn;
349 HANDLE childStdOut;
350 HANDLE childStdErr;
f83751a7
GS
351 /*
352 * the following correspond to the fields of the same name
353 * in the STARTUPINFO structure. Embedders can use these to
354 * control the spawning process' look.
355 * Example - to hide the window of the spawned process:
356 * dwFlags = STARTF_USESHOWWINDOW;
357 * wShowWindow = SW_HIDE;
358 */
359 DWORD dwFlags;
3fadfdf1
NIS
360 DWORD dwX;
361 DWORD dwY;
362 DWORD dwXSize;
363 DWORD dwYSize;
364 DWORD dwXCountChars;
365 DWORD dwYCountChars;
f83751a7 366 DWORD dwFillAttribute;
3fadfdf1 367 WORD wShowWindow;
635bbe87
GS
368} child_IO_table;
369
370DllExport void win32_get_child_IO(child_IO_table* ptr);
b69b0499 371DllExport HWND win32_create_message_window(void);
635bbe87 372
f3986ebb 373extern int my_fclose(FILE *);
e6a0bbf8
NC
374extern char * win32_get_privlib(const char *pl, STRLEN *const len);
375extern char * win32_get_sitelib(const char *pl, STRLEN *const len);
376extern char * win32_get_vendorlib(const char *pl, STRLEN *const len);
d55594ae 377
1c0ca838
GS
378#ifdef PERL_IMPLICIT_SYS
379extern void win32_delete_internal_host(void *h);
380#endif
381
c9beaf97
SH
382extern int win32_get_errno(int err);
383
fe1c5936 384extern const char * const staticlinkmodules[];
390b85e7
GS
385
386END_EXTERN_C
d55594ae 387
68dc0745 388typedef char * caddr_t; /* In malloc.c (core address). */
0a753a76 389
68dc0745 390/*
68dc0745 391 * handle socket stuff, assuming socket is always available
392 */
0a753a76 393#include <sys/socket.h>
394#include <netdb.h>
395
bbc8f9de
NIS
396#ifdef MYMALLOC
397#define EMBEDMYMALLOC /**/
398/* #define USE_PERL_SBRK /**/
399/* #define PERL_SBRK_VIA_MALLOC /**/
400#endif
401
e68cb057 402#ifdef PERL_TEXTMODE_SCRIPTS
c39cd008 403# define PERL_SCRIPT_MODE "r"
a868473f 404#else
c39cd008 405# define PERL_SCRIPT_MODE "rb"
a868473f
NIS
406#endif
407
3fadfdf1
NIS
408/*
409 * Now Win32 specific per-thread data stuff
3352bfcb
GS
410 */
411
aeecf691
JD
412/* Leave the first couple ids after WM_USER unused because they
413 * might be used by an embedding application, and on Windows
414 * version before 2000 we might end up eating those messages
415 * if they were not meant for us.
416 */
417#define WM_USER_MIN (WM_USER+30)
418#define WM_USER_MESSAGE (WM_USER_MIN)
419#define WM_USER_KILL (WM_USER_MIN+1)
420#define WM_USER_MAX (WM_USER_MIN+1)
421
3352bfcb
GS
422struct thread_intern {
423 /* XXX can probably use one buffer instead of several */
424 char Wstrerror_buffer[512];
425 struct servent Wservent;
426 char Wgetlogin_buffer[128];
f4257e4d 427 int Winit_socktype;
3352bfcb 428 char Wcrypt_buffer[30];
3352bfcb
GS
429# ifdef USE_RTL_THREAD_API
430 void * retv; /* slot for thread return value */
431# endif
02637f4c
JD
432 BOOL Wuse_showwindow;
433 WORD Wshowwindow;
3352bfcb
GS
434};
435
4b556e6c 436#define HAVE_INTERP_INTERN
0aaad0ff
GS
437typedef struct {
438 long num;
439 DWORD pids[MAXIMUM_WAIT_OBJECTS];
7766f137 440 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
0aaad0ff
GS
441} child_tab;
442
aeecf691
JD
443#ifdef USE_ITHREADS
444typedef struct {
445 long num;
446 DWORD pids[MAXIMUM_WAIT_OBJECTS];
447 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
448 HWND message_hwnds[MAXIMUM_WAIT_OBJECTS];
8a3cb9c6 449 char sigterm[MAXIMUM_WAIT_OBJECTS];
aeecf691
JD
450} pseudo_child_tab;
451#endif
452
3fadfdf1
NIS
453#ifndef Sighandler_t
454typedef Signal_t (*Sighandler_t) (int);
455#define Sighandler_t Sighandler_t
456#endif
457
4b556e6c 458struct interp_intern {
0aaad0ff
GS
459 char * perlshell_tokens;
460 char ** perlshell_vec;
461 long perlshell_items;
462 struct av * fdpid;
463 child_tab * children;
7766f137
GS
464#ifdef USE_ITHREADS
465 DWORD pseudo_id;
aeecf691 466 pseudo_child_tab * pseudo_children;
7766f137
GS
467#endif
468 void * internal_host;
3352bfcb 469 struct thread_intern thr_intern;
aeecf691 470 HWND message_hwnd;
8fb3fcfb 471 UINT timerid;
05ec9bb3 472 unsigned poll_count;
3fadfdf1 473 Sighandler_t sigtable[SIG_SIZE];
4b556e6c
JD
474};
475
8fb3fcfb
NIS
476DllExport int win32_async_check(pTHX);
477
05ec9bb3 478#define WIN32_POLL_INTERVAL 32768
8fb3fcfb 479#define PERL_ASYNC_CHECK() if (w32_do_async || PL_sig_pending) win32_async_check(aTHX)
4b556e6c 480
0aaad0ff
GS
481#define w32_perlshell_tokens (PL_sys_intern.perlshell_tokens)
482#define w32_perlshell_vec (PL_sys_intern.perlshell_vec)
483#define w32_perlshell_items (PL_sys_intern.perlshell_items)
484#define w32_fdpid (PL_sys_intern.fdpid)
485#define w32_children (PL_sys_intern.children)
486#define w32_num_children (w32_children->num)
487#define w32_child_pids (w32_children->pids)
7766f137
GS
488#define w32_child_handles (w32_children->handles)
489#define w32_pseudo_id (PL_sys_intern.pseudo_id)
490#define w32_pseudo_children (PL_sys_intern.pseudo_children)
491#define w32_num_pseudo_children (w32_pseudo_children->num)
492#define w32_pseudo_child_pids (w32_pseudo_children->pids)
493#define w32_pseudo_child_handles (w32_pseudo_children->handles)
aeecf691 494#define w32_pseudo_child_message_hwnds (w32_pseudo_children->message_hwnds)
8a3cb9c6 495#define w32_pseudo_child_sigterm (w32_pseudo_children->sigterm)
7766f137 496#define w32_internal_host (PL_sys_intern.internal_host)
8fb3fcfb 497#define w32_timerid (PL_sys_intern.timerid)
aeecf691 498#define w32_message_hwnd (PL_sys_intern.message_hwnd)
3fadfdf1 499#define w32_sighandler (PL_sys_intern.sigtable)
05ec9bb3
NIS
500#define w32_poll_count (PL_sys_intern.poll_count)
501#define w32_do_async (w32_poll_count++ > WIN32_POLL_INTERVAL)
3db8f154
MB
502#define w32_strerror_buffer (PL_sys_intern.thr_intern.Wstrerror_buffer)
503#define w32_getlogin_buffer (PL_sys_intern.thr_intern.Wgetlogin_buffer)
504#define w32_crypt_buffer (PL_sys_intern.thr_intern.Wcrypt_buffer)
505#define w32_servent (PL_sys_intern.thr_intern.Wservent)
f4257e4d 506#define w32_init_socktype (PL_sys_intern.thr_intern.Winit_socktype)
3db8f154
MB
507#define w32_use_showwindow (PL_sys_intern.thr_intern.Wuse_showwindow)
508#define w32_showwindow (PL_sys_intern.thr_intern.Wshowwindow)
c53bd28a 509
7766f137 510#ifdef USE_ITHREADS
8a3cb9c6
JD
511void win32_wait_for_children(pTHX);
512# define PERL_WAIT_FOR_CHILDREN win32_wait_for_children(aTHX)
7766f137
GS
513#endif
514
b47a847f
DD
515#ifdef PERL_CORE
516/* C doesn't like repeat struct definitions */
517#if defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION>=3)
518#undef _CRTIMP
519#endif
520#ifndef _CRTIMP
521#define _CRTIMP __declspec(dllimport)
522#endif
523
524
525/* VV 2005 has multiple ioinfo struct definitions through VC 2005's release life
526 * VC 2008-2012 have been stable but do not assume future VCs will have the
527 * same ioinfo struct, just because past struct stability. If research is done
528 * on the CRTs of future VS, the version check can be bumped up so the newer
529 * VC uses a fixed ioinfo size.
530 */
531#if ! (_MSC_VER < 1400 || (_MSC_VER >= 1500 && _MSC_VER <= 1700) \
532 || defined(__MINGW32__))
533/* size of ioinfo struct is determined at runtime */
534# define WIN32_DYN_IOINFO_SIZE
535#endif
536
537#ifndef WIN32_DYN_IOINFO_SIZE
538/*
539 * Control structure for lowio file handles
540 */
541typedef struct {
542 intptr_t osfhnd;/* underlying OS file HANDLE */
543 char osfile; /* attributes of file (e.g., open in text mode?) */
544 char pipech; /* one char buffer for handles opened on pipes */
545 int lockinitflag;
546 CRITICAL_SECTION lock;
547/* this struct defintion breaks ABI compatibility with
548 * not using, cl.exe's native VS version specitfic CRT. */
549# if _MSC_VER >= 1400 && _MSC_VER < 1500
550# error "This ioinfo struct is incomplete for Visual C 2005"
551# endif
552/* VC 2005 CRT has atleast 3 different definitions of this struct based on the
553 * CRT DLL's build number. */
554# if _MSC_VER >= 1500
555# ifndef _SAFECRT_IMPL
556 /* Not used in the safecrt downlevel. We do not define them, so we cannot
557 * use them accidentally */
558 char textmode : 7;/* __IOINFO_TM_ANSI or __IOINFO_TM_UTF8 or __IOINFO_TM_UTF16LE */
559 char unicode : 1; /* Was the file opened as unicode? */
560 char pipech2[2]; /* 2 more peak ahead chars for UNICODE mode */
561 __int64 startpos; /* File position that matches buffer start */
562 BOOL utf8translations; /* Buffer contains translations other than CRLF*/
563 char dbcsBuffer; /* Buffer for the lead byte of dbcs when converting from dbcs to unicode */
564 BOOL dbcsBufferUsed; /* Bool for the lead byte buffer is used or not */
565# endif
566# endif
567} ioinfo;
568#else
569typedef intptr_t ioinfo;
570#endif
571
572/*
573 * Array of arrays of control structures for lowio files.
574 */
575EXTERN_C _CRTIMP ioinfo* __pioinfo[];
576
577/*
578 * Definition of IOINFO_L2E, the log base 2 of the number of elements in each
579 * array of ioinfo structs.
580 */
581#define IOINFO_L2E 5
582
583/*
584 * Definition of IOINFO_ARRAY_ELTS, the number of elements in ioinfo array
585 */
586#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
587
588/*
589 * Access macros for getting at an ioinfo struct and its fields from a
590 * file handle
591 */
592#ifdef WIN32_DYN_IOINFO_SIZE
593# define _pioinfo(i) ((intptr_t *) \
594 (((Size_t)__pioinfo[(i) >> IOINFO_L2E])/* * to head of array ioinfo [] */\
595 /* offset to the head of a particular ioinfo struct */ \
596 + (((i) & (IOINFO_ARRAY_ELTS - 1)) * w32_ioinfo_size)) \
597 )
598/* first slice of ioinfo is always the OS handle */
599# define _osfhnd(i) (*(_pioinfo(i)))
600#else
601# define _pioinfo(i) (__pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
602# define _osfhnd(i) (_pioinfo(i)->osfhnd)
603#endif
604
605/* since we are not doing a dup2(), this works fine */
606# define _set_osfhnd(fh, osfh) (void)(_osfhnd(fh) = (intptr_t)osfh)
607#endif /* PERL_CORE */
608
3fadfdf1 609/* IO.xs and POSIX.xs define PERLIO_NOT_STDIO to 1 */
6e22d046
JH
610#if defined(PERL_EXT_IO) || defined(PERL_EXT_POSIX)
611#undef PERLIO_NOT_STDIO
612#endif
adb71456
NIS
613#define PERLIO_NOT_STDIO 0
614
615#include "perlio.h"
616
4f63d024
GS
617/*
618 * This provides a layer of functions and macros to ensure extensions will
619 * get to use the same RTL functions as the core.
620 */
621#include "win32iop.h"
622
b4748376
NIS
623#define EXEC_ARGV_CAST(x) ((const char *const *) x)
624
f4958739 625DllExport void *win32_signal_context(void);
1018e26f
NIS
626#define PERL_GET_SIG_CONTEXT win32_signal_context()
627
45496817 628#ifdef UNDER_CE
7bd379e8
YO
629#define Win_GetModuleHandle XCEGetModuleHandleA
630#define Win_GetProcAddress XCEGetProcAddressA
631#define Win_GetModuleFileName XCEGetModuleFileNameA
632#define Win_CreateSemaphore CreateSemaphoreW
633#else
634#define Win_GetModuleHandle GetModuleHandle
635#define Win_GetProcAddress GetProcAddress
636#define Win_GetModuleFileName GetModuleFileName
637#define Win_CreateSemaphore CreateSemaphore
638#endif
639
68dc0745 640#endif /* _INC_WIN32_PERL5 */
7a9ec5a3 641