This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Win32: add lstat(), fetch st_dev and st_ino and fetch st_nlink for fstat
[perl5.git] / win32 / win32.h
index 1133c60..171cbfb 100644 (file)
@@ -60,9 +60,6 @@
 #  define prime_env_iter()
 #  define WIN32IO_IS_STDIO             /* don't pull in custom stdio layer */
 #  define WIN32SCK_IS_STDSCK           /* don't pull in custom wsock layer */
-#  ifdef PERL_GLOBAL_STRUCT
-#    error PERL_GLOBAL_STRUCT cannot be defined with PERL_IMPLICIT_SYS
-#  endif
 #endif
 
 #ifdef __GNUC__
 #ifdef _MSC_VER
 #  define PERL_STATIC_NO_RET __declspec(noreturn) static
 #  define PERL_STATIC_INLINE_NO_RET __declspec(noreturn) PERL_STATIC_INLINE
+#  define PERL_STATIC_FORCE_INLINE __forceinline static
+#  define PERL_STATIC_FORCE_INLINE_NO_RET __declspec(noreturn) __forceinline static
 #endif
 
 #define  WIN32_LEAN_AND_MEAN
@@ -229,8 +228,6 @@ struct utsname {
 #  define WIN32_NO_REGISTRY_M_(x) x,
 #endif
 
-#define PERL_NO_FORCE_LINK             /* no need for PL_force_link_funcs */
-
 #define ENV_IS_CASELESS
 
 #define PIPESOCK_MODE  "b"             /* pipes, sockets default to binmode */
@@ -734,5 +731,37 @@ DllExport void *win32_signal_context(void);
 #  define O_ACCMODE (O_RDWR | O_WRONLY | O_RDONLY)
 #endif
 
+/* ucrt at least seems to allocate a whole bit per type,
+   just mask off one bit from the mask for our symlink
+   file type.
+*/
+#define _S_IFLNK ((unsigned)(_S_IFMT ^ (_S_IFMT & -_S_IFMT)))
+#undef S_ISLNK
+#define S_ISLNK(mode) (((mode) & _S_IFMT) == _S_IFLNK)
+
+/*
+
+The default CRT struct stat uses unsigned short for st_dev and st_ino
+which obviously isn't enough, so we define our own structure.
+
+ */
+
+typedef DWORD Dev_t;
+typedef unsigned __int64 Ino_t;
+
+struct w32_stat {
+    Dev_t st_dev;
+    Ino_t st_ino;
+    unsigned short st_mode;
+    DWORD st_nlink;
+    short st_uid;
+    short st_gid;
+    Dev_t st_rdev;
+    Off_t st_size;
+    time_t st_atime;
+    time_t st_mtime;
+    time_t st_ctime;
+};
+
 #endif /* _INC_WIN32_PERL5 */