This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
doio.c: Stop semop from modifying its argument
[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
f3986ebb
GS
259#endif /* _MSC_VER */
260
910dfcc8
GS
261#ifdef __MINGW32__ /* Minimal Gnu-Win32 */
262
263typedef long uid_t;
264typedef long gid_t;
b1d1613b 265#ifndef _environ
3730b96e 266#define _environ environ
b1d1613b 267#endif
3730b96e
GS
268#define flushall _flushall
269#define fcloseall _fcloseall
44604af1 270#ifndef isnan
6940069f 271#define isnan _isnan /* ...same libraries as MSVC */
44604af1 272#endif
910dfcc8 273
ac4c12e7
GS
274#ifndef _O_NOINHERIT
275# define _O_NOINHERIT 0x0080
276# ifndef _NO_OLDNAMES
277# define O_NOINHERIT _O_NOINHERIT
278# endif
279#endif
280
8659febc
S
281/* <stdint.h>, pulled in by <io.h> as of mingw-runtime-3.3, typedef's
282 * (u)intptr_t but doesn't set the _(U)INTPTR_T_DEFINED defines */
283#ifdef _STDINT_H
284# ifndef _INTPTR_T_DEFINED
285# define _INTPTR_T_DEFINED
286# endif
287# ifndef _UINTPTR_T_DEFINED
288# define _UINTPTR_T_DEFINED
289# endif
290#endif
291
f8fb7c90
GS
292#ifndef CP_UTF8
293# define CP_UTF8 65001
294#endif
295
70764c00
SH
296#endif /* __MINGW32__ */
297
c623ac67
GS
298#ifndef _INTPTR_T_DEFINED
299typedef int intptr_t;
300# define _INTPTR_T_DEFINED
301#endif
302
303#ifndef _UINTPTR_T_DEFINED
304typedef unsigned int uintptr_t;
305# define _UINTPTR_T_DEFINED
306#endif
307
390b85e7 308START_EXTERN_C
f3986ebb
GS
309
310/* For UNIX compatibility. */
311
e37d7e38 312#ifdef PERL_CORE
0a753a76 313extern uid_t getuid(void);
314extern gid_t getgid(void);
315extern uid_t geteuid(void);
316extern gid_t getegid(void);
0c38a575
SH
317extern int setuid(uid_t uid);
318extern int setgid(gid_t gid);
0a753a76 319extern int kill(int pid, int sig);
542cb85f 320extern int killpg(int pid, int sig);
c623ac67
GS
321#ifndef USE_PERL_SBRK
322extern void *sbrk(ptrdiff_t need);
323# define HAS_SBRK_PROTO
324#endif
e34ffe5a 325extern char * getlogin(void);
b990f8c8 326extern int chown(const char *p, uid_t o, gid_t g);
00b02797 327extern int mkstemp(const char *path);
e37d7e38 328#endif
d55594ae 329
f3986ebb
GS
330#undef Stat
331#define Stat win32_stat
3e3baf6d 332
f3986ebb
GS
333#undef init_os_extras
334#define init_os_extras Perl_init_os_extras
390b85e7 335
22239a37 336DllExport void Perl_win32_init(int *argcp, char ***argvp);
23f519f0 337DllExport void Perl_win32_term(void);
cb359b41 338DllExport void Perl_init_os_extras(void);
c5be433b
GS
339DllExport void win32_str_os_error(void *sv, DWORD err);
340DllExport int RunPerl(int argc, char **argv, char **env);
0551aaa8 341
635bbe87
GS
342typedef struct {
343 HANDLE childStdIn;
344 HANDLE childStdOut;
345 HANDLE childStdErr;
f83751a7
GS
346 /*
347 * the following correspond to the fields of the same name
348 * in the STARTUPINFO structure. Embedders can use these to
349 * control the spawning process' look.
350 * Example - to hide the window of the spawned process:
351 * dwFlags = STARTF_USESHOWWINDOW;
352 * wShowWindow = SW_HIDE;
353 */
354 DWORD dwFlags;
3fadfdf1
NIS
355 DWORD dwX;
356 DWORD dwY;
357 DWORD dwXSize;
358 DWORD dwYSize;
359 DWORD dwXCountChars;
360 DWORD dwYCountChars;
f83751a7 361 DWORD dwFillAttribute;
3fadfdf1 362 WORD wShowWindow;
635bbe87
GS
363} child_IO_table;
364
365DllExport void win32_get_child_IO(child_IO_table* ptr);
b69b0499 366DllExport HWND win32_create_message_window(void);
635bbe87 367
f3986ebb 368extern int my_fclose(FILE *);
e6a0bbf8
NC
369extern char * win32_get_privlib(const char *pl, STRLEN *const len);
370extern char * win32_get_sitelib(const char *pl, STRLEN *const len);
371extern char * win32_get_vendorlib(const char *pl, STRLEN *const len);
d55594ae 372
1c0ca838
GS
373#ifdef PERL_IMPLICIT_SYS
374extern void win32_delete_internal_host(void *h);
375#endif
376
c9beaf97
SH
377extern int win32_get_errno(int err);
378
fe1c5936 379extern const char * const staticlinkmodules[];
390b85e7
GS
380
381END_EXTERN_C
d55594ae 382
68dc0745 383typedef char * caddr_t; /* In malloc.c (core address). */
0a753a76 384
68dc0745 385/*
68dc0745 386 * handle socket stuff, assuming socket is always available
387 */
0a753a76 388#include <sys/socket.h>
389#include <netdb.h>
390
bbc8f9de
NIS
391#ifdef MYMALLOC
392#define EMBEDMYMALLOC /**/
393/* #define USE_PERL_SBRK /**/
394/* #define PERL_SBRK_VIA_MALLOC /**/
395#endif
396
e68cb057 397#ifdef PERL_TEXTMODE_SCRIPTS
c39cd008 398# define PERL_SCRIPT_MODE "r"
a868473f 399#else
c39cd008 400# define PERL_SCRIPT_MODE "rb"
a868473f
NIS
401#endif
402
3fadfdf1
NIS
403/*
404 * Now Win32 specific per-thread data stuff
3352bfcb
GS
405 */
406
aeecf691
JD
407/* Leave the first couple ids after WM_USER unused because they
408 * might be used by an embedding application, and on Windows
409 * version before 2000 we might end up eating those messages
410 * if they were not meant for us.
411 */
412#define WM_USER_MIN (WM_USER+30)
413#define WM_USER_MESSAGE (WM_USER_MIN)
414#define WM_USER_KILL (WM_USER_MIN+1)
415#define WM_USER_MAX (WM_USER_MIN+1)
416
3352bfcb
GS
417struct thread_intern {
418 /* XXX can probably use one buffer instead of several */
419 char Wstrerror_buffer[512];
420 struct servent Wservent;
421 char Wgetlogin_buffer[128];
f4257e4d 422 int Winit_socktype;
3352bfcb 423 char Wcrypt_buffer[30];
3352bfcb
GS
424# ifdef USE_RTL_THREAD_API
425 void * retv; /* slot for thread return value */
426# endif
02637f4c
JD
427 BOOL Wuse_showwindow;
428 WORD Wshowwindow;
3352bfcb
GS
429};
430
4b556e6c 431#define HAVE_INTERP_INTERN
0aaad0ff
GS
432typedef struct {
433 long num;
434 DWORD pids[MAXIMUM_WAIT_OBJECTS];
7766f137 435 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
0aaad0ff
GS
436} child_tab;
437
aeecf691
JD
438#ifdef USE_ITHREADS
439typedef struct {
440 long num;
441 DWORD pids[MAXIMUM_WAIT_OBJECTS];
442 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
443 HWND message_hwnds[MAXIMUM_WAIT_OBJECTS];
8a3cb9c6 444 char sigterm[MAXIMUM_WAIT_OBJECTS];
aeecf691
JD
445} pseudo_child_tab;
446#endif
447
3fadfdf1
NIS
448#ifndef Sighandler_t
449typedef Signal_t (*Sighandler_t) (int);
450#define Sighandler_t Sighandler_t
451#endif
452
4b556e6c 453struct interp_intern {
0aaad0ff
GS
454 char * perlshell_tokens;
455 char ** perlshell_vec;
456 long perlshell_items;
457 struct av * fdpid;
458 child_tab * children;
7766f137
GS
459#ifdef USE_ITHREADS
460 DWORD pseudo_id;
aeecf691 461 pseudo_child_tab * pseudo_children;
7766f137
GS
462#endif
463 void * internal_host;
3352bfcb 464 struct thread_intern thr_intern;
aeecf691 465 HWND message_hwnd;
8fb3fcfb 466 UINT timerid;
05ec9bb3 467 unsigned poll_count;
3fadfdf1 468 Sighandler_t sigtable[SIG_SIZE];
4b556e6c
JD
469};
470
8fb3fcfb
NIS
471DllExport int win32_async_check(pTHX);
472
05ec9bb3 473#define WIN32_POLL_INTERVAL 32768
8fb3fcfb 474#define PERL_ASYNC_CHECK() if (w32_do_async || PL_sig_pending) win32_async_check(aTHX)
4b556e6c 475
0aaad0ff
GS
476#define w32_perlshell_tokens (PL_sys_intern.perlshell_tokens)
477#define w32_perlshell_vec (PL_sys_intern.perlshell_vec)
478#define w32_perlshell_items (PL_sys_intern.perlshell_items)
479#define w32_fdpid (PL_sys_intern.fdpid)
480#define w32_children (PL_sys_intern.children)
481#define w32_num_children (w32_children->num)
482#define w32_child_pids (w32_children->pids)
7766f137
GS
483#define w32_child_handles (w32_children->handles)
484#define w32_pseudo_id (PL_sys_intern.pseudo_id)
485#define w32_pseudo_children (PL_sys_intern.pseudo_children)
486#define w32_num_pseudo_children (w32_pseudo_children->num)
487#define w32_pseudo_child_pids (w32_pseudo_children->pids)
488#define w32_pseudo_child_handles (w32_pseudo_children->handles)
aeecf691 489#define w32_pseudo_child_message_hwnds (w32_pseudo_children->message_hwnds)
8a3cb9c6 490#define w32_pseudo_child_sigterm (w32_pseudo_children->sigterm)
7766f137 491#define w32_internal_host (PL_sys_intern.internal_host)
8fb3fcfb 492#define w32_timerid (PL_sys_intern.timerid)
aeecf691 493#define w32_message_hwnd (PL_sys_intern.message_hwnd)
3fadfdf1 494#define w32_sighandler (PL_sys_intern.sigtable)
05ec9bb3
NIS
495#define w32_poll_count (PL_sys_intern.poll_count)
496#define w32_do_async (w32_poll_count++ > WIN32_POLL_INTERVAL)
3db8f154
MB
497#define w32_strerror_buffer (PL_sys_intern.thr_intern.Wstrerror_buffer)
498#define w32_getlogin_buffer (PL_sys_intern.thr_intern.Wgetlogin_buffer)
499#define w32_crypt_buffer (PL_sys_intern.thr_intern.Wcrypt_buffer)
500#define w32_servent (PL_sys_intern.thr_intern.Wservent)
f4257e4d 501#define w32_init_socktype (PL_sys_intern.thr_intern.Winit_socktype)
3db8f154
MB
502#define w32_use_showwindow (PL_sys_intern.thr_intern.Wuse_showwindow)
503#define w32_showwindow (PL_sys_intern.thr_intern.Wshowwindow)
c53bd28a 504
7766f137 505#ifdef USE_ITHREADS
8a3cb9c6
JD
506void win32_wait_for_children(pTHX);
507# define PERL_WAIT_FOR_CHILDREN win32_wait_for_children(aTHX)
7766f137
GS
508#endif
509
b47a847f
DD
510#ifdef PERL_CORE
511/* C doesn't like repeat struct definitions */
512#if defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION>=3)
513#undef _CRTIMP
514#endif
515#ifndef _CRTIMP
516#define _CRTIMP __declspec(dllimport)
517#endif
518
519
520/* VV 2005 has multiple ioinfo struct definitions through VC 2005's release life
521 * VC 2008-2012 have been stable but do not assume future VCs will have the
522 * same ioinfo struct, just because past struct stability. If research is done
523 * on the CRTs of future VS, the version check can be bumped up so the newer
524 * VC uses a fixed ioinfo size.
525 */
526#if ! (_MSC_VER < 1400 || (_MSC_VER >= 1500 && _MSC_VER <= 1700) \
527 || defined(__MINGW32__))
528/* size of ioinfo struct is determined at runtime */
529# define WIN32_DYN_IOINFO_SIZE
530#endif
531
532#ifndef WIN32_DYN_IOINFO_SIZE
533/*
534 * Control structure for lowio file handles
535 */
536typedef struct {
537 intptr_t osfhnd;/* underlying OS file HANDLE */
538 char osfile; /* attributes of file (e.g., open in text mode?) */
539 char pipech; /* one char buffer for handles opened on pipes */
540 int lockinitflag;
541 CRITICAL_SECTION lock;
542/* this struct defintion breaks ABI compatibility with
543 * not using, cl.exe's native VS version specitfic CRT. */
544# if _MSC_VER >= 1400 && _MSC_VER < 1500
545# error "This ioinfo struct is incomplete for Visual C 2005"
546# endif
547/* VC 2005 CRT has atleast 3 different definitions of this struct based on the
548 * CRT DLL's build number. */
549# if _MSC_VER >= 1500
550# ifndef _SAFECRT_IMPL
551 /* Not used in the safecrt downlevel. We do not define them, so we cannot
552 * use them accidentally */
553 char textmode : 7;/* __IOINFO_TM_ANSI or __IOINFO_TM_UTF8 or __IOINFO_TM_UTF16LE */
554 char unicode : 1; /* Was the file opened as unicode? */
555 char pipech2[2]; /* 2 more peak ahead chars for UNICODE mode */
556 __int64 startpos; /* File position that matches buffer start */
557 BOOL utf8translations; /* Buffer contains translations other than CRLF*/
558 char dbcsBuffer; /* Buffer for the lead byte of dbcs when converting from dbcs to unicode */
559 BOOL dbcsBufferUsed; /* Bool for the lead byte buffer is used or not */
560# endif
561# endif
562} ioinfo;
563#else
564typedef intptr_t ioinfo;
565#endif
566
567/*
568 * Array of arrays of control structures for lowio files.
569 */
570EXTERN_C _CRTIMP ioinfo* __pioinfo[];
571
572/*
573 * Definition of IOINFO_L2E, the log base 2 of the number of elements in each
574 * array of ioinfo structs.
575 */
576#define IOINFO_L2E 5
577
578/*
579 * Definition of IOINFO_ARRAY_ELTS, the number of elements in ioinfo array
580 */
581#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
582
583/*
584 * Access macros for getting at an ioinfo struct and its fields from a
585 * file handle
586 */
587#ifdef WIN32_DYN_IOINFO_SIZE
588# define _pioinfo(i) ((intptr_t *) \
589 (((Size_t)__pioinfo[(i) >> IOINFO_L2E])/* * to head of array ioinfo [] */\
590 /* offset to the head of a particular ioinfo struct */ \
591 + (((i) & (IOINFO_ARRAY_ELTS - 1)) * w32_ioinfo_size)) \
592 )
593/* first slice of ioinfo is always the OS handle */
594# define _osfhnd(i) (*(_pioinfo(i)))
595#else
596# define _pioinfo(i) (__pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
597# define _osfhnd(i) (_pioinfo(i)->osfhnd)
598#endif
599
600/* since we are not doing a dup2(), this works fine */
601# define _set_osfhnd(fh, osfh) (void)(_osfhnd(fh) = (intptr_t)osfh)
602#endif /* PERL_CORE */
603
3fadfdf1 604/* IO.xs and POSIX.xs define PERLIO_NOT_STDIO to 1 */
6e22d046
JH
605#if defined(PERL_EXT_IO) || defined(PERL_EXT_POSIX)
606#undef PERLIO_NOT_STDIO
607#endif
adb71456
NIS
608#define PERLIO_NOT_STDIO 0
609
610#include "perlio.h"
611
4f63d024
GS
612/*
613 * This provides a layer of functions and macros to ensure extensions will
614 * get to use the same RTL functions as the core.
615 */
616#include "win32iop.h"
617
b4748376
NIS
618#define EXEC_ARGV_CAST(x) ((const char *const *) x)
619
f4958739 620DllExport void *win32_signal_context(void);
1018e26f
NIS
621#define PERL_GET_SIG_CONTEXT win32_signal_context()
622
45496817 623#ifdef UNDER_CE
7bd379e8
YO
624#define Win_GetModuleHandle XCEGetModuleHandleA
625#define Win_GetProcAddress XCEGetProcAddressA
626#define Win_GetModuleFileName XCEGetModuleFileNameA
627#define Win_CreateSemaphore CreateSemaphoreW
628#else
629#define Win_GetModuleHandle GetModuleHandle
630#define Win_GetProcAddress GetProcAddress
631#define Win_GetModuleFileName GetModuleFileName
632#define Win_CreateSemaphore CreateSemaphore
633#endif
634
68dc0745 635#endif /* _INC_WIN32_PERL5 */
7a9ec5a3 636