xref: /openbsd/gnu/usr.bin/perl/win32/win32.h (revision 3d61058a)
1 /* WIN32.H
2  *
3  * (c) 1995 Microsoft Corporation. All rights reserved.
4  * 		Developed by hip communications inc.
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 #ifndef _WIN32_WINNT
13 #  define _WIN32_WINNT 0x0500     /* needed for CreateHardlink() etc. */
14 #endif
15 
16 /* Win32 only optimizations for faster building */
17 #ifdef PERL_IS_MINIPERL
18 /* less I/O calls during each require */
19 #  define PERL_DISABLE_PMC
20 
21 /* unnecessary for miniperl to lookup anything from an "installed" perl */
22 #  define WIN32_NO_REGISTRY
23 
24 /* allow minitest to work */
25 #  define PERL_TEXTMODE_SCRIPTS
26 #endif
27 
28 #if defined(PERL_IMPLICIT_SYS)
29 #  define DYNAMIC_ENV_FETCH
30 #  define HAS_GETENV_LEN
31 #  define WIN32IO_IS_STDIO		/* don't pull in custom stdio layer */
32 #  define WIN32SCK_IS_STDSCK		/* don't pull in custom wsock layer */
33 #endif
34 
35 #ifdef __GNUC__
36 #  ifndef __int64		/* some versions seem to #define it already */
37 #    define __int64 long long
38 #  endif
39 #  define Win32_Winsock
40 #endif
41 
42 
43 /* Define DllExport akin to perl's EXT,
44  * If we are in the DLL then Export the symbol,
45  * otherwise import it.
46  */
47 
48 /* now even GCC supports __declspec() */
49 /* miniperl has no reason to export anything */
50 #if defined(PERL_IS_MINIPERL)
51 #  define DllExport
52 #else
53 #  if defined(PERLDLL)
54 #    define DllExport __declspec(dllexport)
55 #  else
56 #    define DllExport __declspec(dllimport)
57 #  endif
58 #endif
59 
60 /* The Perl APIs can only be called directly inside the perl5xx.dll.
61  * All other code has to import them.  By declaring them as "dllimport"
62  * we tell the compiler to generate an indirect call instruction and
63  * avoid redirection through a call thunk.
64  *
65  * The XS code in the re extension is special, in that it redefines
66  * core APIs locally, so don't mark them as "dllimport" because GCC
67  * cannot handle this situation.
68  *
69  * Certain old GCCs will not allow the function pointer of dllimport marked
70  * function to be "const". This was fixed later on. Since this is a
71  * deoptimization, target "gcc version 3.4.5 (mingw-vista special r3)" only,
72  * The GCC bug was fixed in GCC patch "varasm.c (initializer_constant_valid_p):
73  * Don't deny DECL_DLLIMPORT_P on functions", which probably was first released
74  * in GCC 4.3.0, this #if can be expanded upto but not including 4.3.0 if more
75  * deployed GCC are found that wont build with the follow error, initializer
76  * element is a PerlIO func exported from perl5xx.dll.
77  *
78  * encoding.xs:610: error: initializer element is not constant
79  * encoding.xs:610: error: (near initialization for `PerlIO_encode.Open')
80  */
81 
82 #if (defined(__GNUC__) && defined(__MINGW32__) && \
83      !defined(__MINGW64_VERSION_MAJOR) && !defined(__clang__) && \
84         ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ <= 5))))
85 /* use default fallbacks from perl.h for this particular GCC */
86 #else
87 #  if !defined(PERLDLL) && !defined(PERL_EXT_RE_BUILD)
88 #    ifdef __cplusplus
89 #      define PERL_CALLCONV extern "C" __declspec(dllimport)
90 #      ifdef _MSC_VER
91 #        define PERL_CALLCONV_NO_RET extern "C" __declspec(dllimport) __declspec(noreturn)
92 #      endif
93 #    else
94 #      define PERL_CALLCONV __declspec(dllimport)
95 #      ifdef _MSC_VER
96 #        define PERL_CALLCONV_NO_RET __declspec(dllimport) __declspec(noreturn)
97 #      endif
98 #    endif
99 #  else /* MSVC noreturn support inside the interp */
100 #    ifdef _MSC_VER
101 #      define PERL_CALLCONV_NO_RET __declspec(noreturn)
102 #    endif
103 #  endif
104 #endif
105 
106 #ifdef _MSC_VER
107 #  define PERL_STATIC_NO_RET __declspec(noreturn) static
108 #  define PERL_STATIC_INLINE_NO_RET __declspec(noreturn) PERL_STATIC_INLINE
109 #  define PERL_STATIC_FORCE_INLINE __forceinline static
110 #  define PERL_STATIC_FORCE_INLINE_NO_RET __declspec(noreturn) __forceinline static
111 #endif
112 
113 #define  WIN32_LEAN_AND_MEAN
114 #include <windows.h>
115 
116 /*
117  * Bug in winbase.h in mingw-w64 4.4.0-1 at least... they
118  * do #define GetEnvironmentStringsA GetEnvironmentStrings and fail
119  * to declare GetEnvironmentStringsA.
120  */
121 #if defined(__MINGW64__) && defined(GetEnvironmentStringsA) && !defined(UNICODE)
122 #ifdef __cplusplus
123 extern "C" {
124 #endif
125 #undef GetEnvironmentStringsA
126 WINBASEAPI LPCH WINAPI GetEnvironmentStringsA(VOID);
127 #define GetEnvironmentStrings GetEnvironmentStringsA
128 #ifdef __cplusplus
129 }
130 #endif
131 #endif
132 
133 #ifdef   WIN32_LEAN_AND_MEAN		/* C file is NOT a Perl5 original. */
134 #define  CONTEXT	PERL_CONTEXT	/* Avoid conflict of CONTEXT defs. */
135 #endif /*WIN32_LEAN_AND_MEAN */
136 
137 #ifndef TLS_OUT_OF_INDEXES
138 #define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
139 #endif
140 
141 #include <dirent.h>
142 #include <io.h>
143 #include <process.h>
144 #include <stdio.h>
145 #include <direct.h>
146 #include <stdlib.h>
147 #include <stddef.h>
148 #include <fcntl.h>
149 #ifndef EXT
150 #include "EXTERN.h"
151 #endif
152 
153 struct tms {
154         long	tms_utime;
155         long	tms_stime;
156         long	tms_cutime;
157         long	tms_cstime;
158 };
159 
160 #ifndef SYS_NMLN
161 #define SYS_NMLN	257
162 #endif
163 
164 struct utsname {
165     char sysname[SYS_NMLN];
166     char nodename[SYS_NMLN];
167     char release[SYS_NMLN];
168     char version[SYS_NMLN];
169     char machine[SYS_NMLN];
170 };
171 
172 #ifndef START_EXTERN_C
173 #undef EXTERN_C
174 #ifdef __cplusplus
175 #  define START_EXTERN_C extern "C" {
176 #  define END_EXTERN_C }
177 #  define EXTERN_C extern "C"
178 #else
179 #  define START_EXTERN_C
180 #  define END_EXTERN_C
181 #  define EXTERN_C
182 #endif
183 #endif
184 
185 #define  DOSISH		1		/* no escaping our roots */
186 #define  OP_BINARY	O_BINARY	/* mistake in in pp_sys.c? */
187 
188 /* read() and write() aren't transparent for socket handles */
189 #ifndef WIN32_NO_SOCKETS
190 #  define PERL_SOCK_SYSREAD_IS_RECV
191 #  define PERL_SOCK_SYSWRITE_IS_SEND
192 #endif
193 
194 #ifdef WIN32_NO_REGISTRY
195 /* the last _ in WIN32_NO_REGISTRY_M_ is like the _ in aTHX_ */
196 #  define WIN32_NO_REGISTRY_M_(x)
197 #else
198 #  define WIN32_NO_REGISTRY_M_(x) x,
199 #endif
200 
201 #define ENV_IS_CASELESS
202 
203 #define PIPESOCK_MODE	"b"		/* pipes, sockets default to binmode */
204 
205 /* access() mode bits */
206 #ifndef R_OK
207 #  define R_OK  4
208 #  define W_OK  2
209 #  define X_OK  1
210 #  define F_OK  0
211 #endif
212 
213 /* for waitpid() */
214 #ifndef WNOHANG
215 #  define WNOHANG	1
216 #endif
217 
218 #define PERL_GET_CONTEXT_DEFINED
219 
220 /* Compiler-specific stuff. */
221 
222 /* VC uses non-standard way to determine the size and alignment if bit-fields */
223 /* MinGW will compile with -mms-bitfields, so should use the same types */
224 #define PERL_BITFIELD8  U8
225 #define PERL_BITFIELD16 U16
226 #define PERL_BITFIELD32 U32
227 
228 #ifdef _MSC_VER			/* Microsoft Visual C++ */
229 
230 typedef long		uid_t;
231 typedef long		gid_t;
232 typedef unsigned short	mode_t;
233 
234 #define snprintf	_snprintf
235 #define vsnprintf	_vsnprintf
236 
237 MSVC_DIAG_IGNORE(4756 4056)
238 PERL_STATIC_INLINE
S_Infinity()239 double S_Infinity() {
240     /* this is a real C literal which can get further constant folded
241        unlike using HUGE_VAL/_HUGE which are data symbol imports from the CRT
242        and therefore can not by folded by VC, an example of constant
243        folding INF is creating -INF */
244     return (DBL_MAX+DBL_MAX);
245 }
246 MSVC_DIAG_RESTORE
247 
248 #define NV_INF S_Infinity()
249 
250 /* selectany allows duplicate and unused data symbols to be removed by
251    VC linker, if this were static, each translation unit will have its own,
252    usually unused __PL_nan_u, if this were plain extern it will cause link
253    to fail due to multiple definitions, since we dont know if we are being
254    compiled as static or DLL XS, selectany simply always works, the cost of
255    importing __PL_nan_u across DLL boundaries in size in the importing DLL
256    will be more than the 8 bytes it will take up being in each XS DLL if
257    that DLL actually uses __PL_nan_u */
258 union PerlNan { unsigned __int64 __q; double __d; };
259 extern const __declspec(selectany) union PerlNan __PL_nan_u = { 0x7FF8000000000000UI64 };
260 #define NV_NAN ((NV)__PL_nan_u.__d)
261 
262 #endif /* ifdef _MSC_VER */
263 
264 /* The CRT was rewritten in VS2015. */
265 #ifdef _UCRT
266 
267 /* No longer declared in stdio.h */
268 EXTERN_C char *gets(char* buffer);
269 
270 #define tzname _tzname
271 
272 /* From corecrt_internal_stdio.h: */
273 typedef struct
274 {
275     union
276     {
277         FILE  _public_file;
278         char* _ptr;
279     } u;
280 
281     char*            _base;
282     int              _cnt;
283     long             _flags;
284     long             _file;
285     int              _charbuf;
286     int              _bufsiz;
287     char*            _tmpfname;
288     CRITICAL_SECTION _lock;
289 } __crt_stdio_stream_data;
290 
291 #define PERLIO_FILE_flag_RD 0x0001 /* _IOREAD   */
292 #define PERLIO_FILE_flag_WR 0x0002 /* _IOWRITE  */
293 #define PERLIO_FILE_flag_RW 0x0004 /* _IOUPDATE */
294 #define PERLIO_FILE_ptr(f)  (((__crt_stdio_stream_data*)(f))->u._ptr)
295 #define PERLIO_FILE_base(f) (((__crt_stdio_stream_data*)(f))->_base)
296 #define PERLIO_FILE_cnt(f)  (((__crt_stdio_stream_data*)(f))->_cnt)
297 #define PERLIO_FILE_flag(f) ((int)(((__crt_stdio_stream_data*)(f))->_flags))
298 #define PERLIO_FILE_file(f) (*(int*)(&((__crt_stdio_stream_data*)(f))->_file))
299 
300 #else /* ifdef _UCRT */
301 
302 /* Note: PERLIO_FILE_ptr/base/cnt are not actually used for GCC or <VS2015
303  * since FILE_ptr/base/cnt do the same thing anyway but it doesn't hurt to
304  * define them all here for completeness. */
305 #define PERLIO_FILE_flag_RD _IOREAD /* 0x001 */
306 #define PERLIO_FILE_flag_WR _IOWRT  /* 0x002 */
307 #define PERLIO_FILE_flag_RW _IORW   /* 0x080 */
308 #define PERLIO_FILE_ptr(f)  ((f)->_ptr)
309 #define PERLIO_FILE_base(f) ((f)->_base)
310 #define PERLIO_FILE_cnt(f)  ((f)->_cnt)
311 #define PERLIO_FILE_flag(f) ((f)->_flag)
312 #define PERLIO_FILE_file(f) ((f)->_file)
313 
314 #endif
315 
316 #ifdef __MINGW32__		/* Minimal Gnu-Win32 */
317 
318 typedef long		uid_t;
319 typedef long		gid_t;
320 #ifndef _environ
321 #define _environ	environ
322 #endif
323 #define flushall	_flushall
324 #define fcloseall	_fcloseall
325 #ifndef isnan
326 #define isnan		_isnan	/* ...same libraries as MSVC */
327 #endif
328 
329 #ifndef _O_NOINHERIT
330 #  define _O_NOINHERIT	0x0080
331 #  ifndef _NO_OLDNAMES
332 #    define O_NOINHERIT	_O_NOINHERIT
333 #  endif
334 #endif
335 
336 /* <stdint.h>, pulled in by <io.h> as of mingw-runtime-3.3, typedef's
337  * (u)intptr_t but doesn't set the _(U)INTPTR_T_DEFINED defines */
338 #ifdef _STDINT_H
339 #  ifndef _INTPTR_T_DEFINED
340 #    define _INTPTR_T_DEFINED
341 #  endif
342 #  ifndef _UINTPTR_T_DEFINED
343 #    define _UINTPTR_T_DEFINED
344 #  endif
345 #endif
346 
347 #ifndef CP_UTF8
348 #  define CP_UTF8	65001
349 #endif
350 
351 #endif /* __MINGW32__ */
352 
353 #ifndef _INTPTR_T_DEFINED
354 typedef int		intptr_t;
355 #  define _INTPTR_T_DEFINED
356 #endif
357 
358 #ifndef _UINTPTR_T_DEFINED
359 typedef unsigned int	uintptr_t;
360 #  define _UINTPTR_T_DEFINED
361 #endif
362 
363 START_EXTERN_C
364 
365 /* For UNIX compatibility. */
366 
367 #ifdef PERL_CORE
368 extern  uid_t	getuid(void);
369 extern  gid_t	getgid(void);
370 extern  uid_t	geteuid(void);
371 extern  gid_t	getegid(void);
372 extern  int	setuid(uid_t uid);
373 extern  int	setgid(gid_t gid);
374 extern  int	kill(int pid, int sig);
375 #ifndef USE_PERL_SBRK
376 extern  void	*sbrk(ptrdiff_t need);
377 #  define HAS_SBRK_PROTO
378 #endif
379 extern	char *	getlogin(void);
380 extern	int	chown(const char *p, uid_t o, gid_t g);
381 #if((!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 4) && \
382     (!defined(__MINGW32_MAJOR_VERSION) || __MINGW32_MAJOR_VERSION < 3 || \
383      (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION < 21)))
384 extern  int	mkstemp(const char *path);
385 #endif
386 #endif
387 
388 #undef	 Stat
389 #define  Stat		win32_stat
390 
391 #undef   init_os_extras
392 #define  init_os_extras Perl_init_os_extras
393 
394 DllExport void		Perl_win32_init(int *argcp, char ***argvp);
395 DllExport void		Perl_win32_term(void);
396 DllExport void		Perl_init_os_extras(void);
397 DllExport void		win32_str_os_error(void *sv, DWORD err);
398 DllExport int		RunPerl(int argc, char **argv, char **env);
399 
400 typedef struct {
401     HANDLE	childStdIn;
402     HANDLE	childStdOut;
403     HANDLE	childStdErr;
404     /*
405      * the following correspond to the fields of the same name
406      * in the STARTUPINFO structure. Embedders can use these to
407      * control the spawning process' look.
408      * Example - to hide the window of the spawned process:
409      *    dwFlags = STARTF_USESHOWWINDOW;
410      *	  wShowWindow = SW_HIDE;
411      */
412     DWORD	dwFlags;
413     DWORD	dwX;
414     DWORD	dwY;
415     DWORD	dwXSize;
416     DWORD	dwYSize;
417     DWORD	dwXCountChars;
418     DWORD	dwYCountChars;
419     DWORD	dwFillAttribute;
420     WORD	wShowWindow;
421 } child_IO_table;
422 
423 DllExport void		win32_get_child_IO(child_IO_table* ptr);
424 DllExport HWND		win32_create_message_window(void);
425 DllExport int		win32_async_check(pTHX);
426 
427 extern char *		win32_get_privlib(WIN32_NO_REGISTRY_M_(const char *pl) STRLEN *const len);
428 extern char *		win32_get_sitelib(const char *pl, STRLEN *const len);
429 extern char *		win32_get_vendorlib(const char *pl, STRLEN *const len);
430 
431 #ifdef PERL_IMPLICIT_SYS
432 extern void		win32_delete_internal_host(void *h);
433 #endif
434 
435 extern int		win32_get_errno(int err);
436 
437 extern const char * const		staticlinkmodules[];
438 
439 END_EXTERN_C
440 
441 typedef  char *		caddr_t;	/* In malloc.c (core address). */
442 
443 /*
444  * handle socket stuff, assuming socket is always available
445  */
446 #include <sys/socket.h>
447 #include <netdb.h>
448 
449 #ifdef MYMALLOC
450 #define EMBEDMYMALLOC	/**/
451 /* #define USE_PERL_SBRK	/ **/
452 /* #define PERL_SBRK_VIA_MALLOC	/ **/
453 #endif
454 
455 #ifdef PERL_TEXTMODE_SCRIPTS
456 #  define PERL_SCRIPT_MODE		"r"
457 #else
458 #  define PERL_SCRIPT_MODE		"rb"
459 #endif
460 
461 /*
462  * Now Win32 specific per-thread data stuff
463  */
464 
465 /* Leave the first couple ids after WM_USER unused because they
466  * might be used by an embedding application, and on Windows
467  * version before 2000 we might end up eating those messages
468  * if they were not meant for us.
469  */
470 #define WM_USER_MIN     (WM_USER+30)
471 #define WM_USER_MESSAGE (WM_USER_MIN)
472 #define WM_USER_KILL    (WM_USER_MIN+1)
473 #define WM_USER_MAX     (WM_USER_MIN+1)
474 
475 struct thread_intern {
476     /* XXX can probably use one buffer instead of several */
477     char		Wstrerror_buffer[512];
478     struct servent	Wservent;
479     char		Wgetlogin_buffer[128];
480     int			Winit_socktype;
481     char		Wcrypt_buffer[30];
482 #    ifdef USE_RTL_THREAD_API
483     void *		retv;	/* slot for thread return value */
484 #    endif
485     BOOL               Wuse_showwindow;
486     WORD               Wshowwindow;
487 };
488 
489 #define HAVE_INTERP_INTERN
490 typedef struct {
491     long	num;
492     DWORD	pids[MAXIMUM_WAIT_OBJECTS];
493     HANDLE	handles[MAXIMUM_WAIT_OBJECTS];
494 } child_tab;
495 
496 #ifdef USE_ITHREADS
497 typedef struct {
498     long	num;
499     DWORD	pids[MAXIMUM_WAIT_OBJECTS];
500     HANDLE	handles[MAXIMUM_WAIT_OBJECTS];
501     HWND	message_hwnds[MAXIMUM_WAIT_OBJECTS];
502     char        sigterm[MAXIMUM_WAIT_OBJECTS];
503 } pseudo_child_tab;
504 #endif
505 
506 #ifndef Sighandler_t
507 typedef Signal_t (*Sighandler_t) (int);
508 #define Sighandler_t	Sighandler_t
509 #endif
510 
511 struct interp_intern {
512     char *	perlshell_tokens;
513     char **	perlshell_vec;
514     long	perlshell_items;
515     struct av *	fdpid;
516     child_tab *	children;
517 #ifdef USE_ITHREADS
518     DWORD	pseudo_id;
519     pseudo_child_tab * pseudo_children;
520 #endif
521     void *	internal_host;
522     struct thread_intern	thr_intern;
523     HWND        message_hwnd;
524     UINT	timerid;
525     unsigned 	poll_count;
526     Sighandler_t sigtable[SIG_SIZE];
527 };
528 
529 #define WIN32_POLL_INTERVAL 32768
530 #define PERL_ASYNC_CHECK() if (w32_do_async || PL_sig_pending) win32_async_check(aTHX)
531 
532 #define w32_perlshell_tokens	(PL_sys_intern.perlshell_tokens)
533 #define w32_perlshell_vec	(PL_sys_intern.perlshell_vec)
534 #define w32_perlshell_items	(PL_sys_intern.perlshell_items)
535 #define w32_fdpid		(PL_sys_intern.fdpid)
536 #define w32_children		(PL_sys_intern.children)
537 #define w32_num_children	(w32_children->num)
538 #define w32_child_pids		(w32_children->pids)
539 #define w32_child_handles	(w32_children->handles)
540 #define w32_pseudo_id		(PL_sys_intern.pseudo_id)
541 #define w32_pseudo_children	(PL_sys_intern.pseudo_children)
542 #define w32_num_pseudo_children		(w32_pseudo_children->num)
543 #define w32_pseudo_child_pids		(w32_pseudo_children->pids)
544 #define w32_pseudo_child_handles	(w32_pseudo_children->handles)
545 #define w32_pseudo_child_message_hwnds	(w32_pseudo_children->message_hwnds)
546 #define w32_pseudo_child_sigterm	(w32_pseudo_children->sigterm)
547 #define w32_internal_host		(PL_sys_intern.internal_host)
548 #define w32_timerid			(PL_sys_intern.timerid)
549 #define w32_message_hwnd		(PL_sys_intern.message_hwnd)
550 #define w32_sighandler			(PL_sys_intern.sigtable)
551 #define w32_poll_count			(PL_sys_intern.poll_count)
552 #define w32_do_async			(w32_poll_count++ > WIN32_POLL_INTERVAL)
553 #define w32_strerror_buffer	(PL_sys_intern.thr_intern.Wstrerror_buffer)
554 #define w32_getlogin_buffer	(PL_sys_intern.thr_intern.Wgetlogin_buffer)
555 #define w32_crypt_buffer	(PL_sys_intern.thr_intern.Wcrypt_buffer)
556 #define w32_servent		(PL_sys_intern.thr_intern.Wservent)
557 #define w32_init_socktype	(PL_sys_intern.thr_intern.Winit_socktype)
558 #define w32_use_showwindow	(PL_sys_intern.thr_intern.Wuse_showwindow)
559 #define w32_showwindow	(PL_sys_intern.thr_intern.Wshowwindow)
560 
561 #ifdef USE_ITHREADS
562 void win32_wait_for_children(pTHX);
563 #  define PERL_WAIT_FOR_CHILDREN win32_wait_for_children(aTHX)
564 #endif
565 
566 /* IO.xs and POSIX.xs define PERLIO_NOT_STDIO to 1 */
567 #if defined(PERL_EXT_IO) || defined(PERL_EXT_POSIX)
568 #undef  PERLIO_NOT_STDIO
569 #endif
570 #define PERLIO_NOT_STDIO 0
571 
572 #define EXEC_ARGV_CAST(x) ((const char *const *) x)
573 
574 DllExport void *win32_signal_context(void);
575 #define PERL_GET_SIG_CONTEXT win32_signal_context()
576 
577 #define Win_GetModuleHandle   GetModuleHandle
578 #define Win_GetProcAddress    GetProcAddress
579 #define Win_GetModuleFileName GetModuleFileName
580 #define Win_CreateSemaphore   CreateSemaphore
581 
582 #if defined(PERL_CORE) && !defined(O_ACCMODE)
583 #  define O_ACCMODE (O_RDWR | O_WRONLY | O_RDONLY)
584 #endif
585 
586 /* ucrt at least seems to allocate a whole bit per type,
587    just mask off one bit from the mask for our symlink
588    and socket file types.
589 */
590 #define _S_IFLNK ((unsigned)(_S_IFDIR | _S_IFCHR))
591 #define _S_IFSOCK ((unsigned)(_S_IFDIR | _S_IFIFO))
592 /* mingw64 defines _S_IFBLK to 0x3000 which is _S_IFDIR | _S_IFIFO */
593 #ifndef _S_IFBLK
594 #  define _S_IFBLK ((unsigned)(_S_IFCHR | _S_IFIFO))
595 #endif
596 #undef S_ISLNK
597 #define S_ISLNK(mode) (((mode) & _S_IFMT) == _S_IFLNK)
598 #undef S_ISSOCK
599 #define S_ISSOCK(mode) (((mode) & _S_IFMT) == _S_IFSOCK)
600 #undef S_ISBLK
601 #define S_ISBLK(mode) (((mode) & _S_IFMT) == _S_IFBLK)
602 
603 /*
604 
605 The default CRT struct stat uses unsigned short for st_dev and st_ino
606 which obviously isn't enough, so we define our own structure.
607 
608  */
609 
610 typedef DWORD Dev_t;
611 typedef unsigned __int64 Ino_t;
612 
613 struct w32_stat {
614     Dev_t st_dev;
615     Ino_t st_ino;
616     unsigned short st_mode;
617     DWORD st_nlink;
618     short st_uid;
619     short st_gid;
620     Dev_t st_rdev;
621     Off_t st_size;
622     time_t st_atime;
623     time_t st_mtime;
624     time_t st_ctime;
625 };
626 
627 #endif /* _INC_WIN32_PERL5 */
628 
629