sync to trunk r38300
[reactos.git] / reactos / include / crt / sys / stat.h
index f8f280c..22bfb0f 100644 (file)
@@ -10,8 +10,7 @@
 #error Only Win32 target is supported!
 #endif
 
-#include <_mingw.h>
-#include <io.h>
+#include <crtdefs.h>
 
 #pragma pack(push,_CRT_PACKING)
 
 extern "C" {
 #endif
 
-#ifndef _CRTIMP
-#define _CRTIMP __declspec(dllimport)
-#endif
-
 #include <sys/types.h>
 
-#ifdef _USE_32BIT_TIME_T
-#ifdef _WIN64
-#undef _USE_32BIT_TIME_T
-#endif
-#else
-#if _INTEGRAL_MAX_BITS < 64
-#define _USE_32BIT_TIME_T
-#endif
-#endif
-
-#ifndef _TIME32_T_DEFINED
-  typedef long __time32_t;
-#define _TIME32_T_DEFINED
-#endif
-
-#ifndef _TIME64_T_DEFINED
-#if _INTEGRAL_MAX_BITS >= 64
-  typedef __int64 __time64_t;
-#endif
-#define _TIME64_T_DEFINED
-#endif
-
-#ifndef _TIME_T_DEFINED
-#ifdef _USE_32BIT_TIME_T
-  typedef __time32_t time_t;
-#else
-  typedef __time64_t time_t;
-#endif
-#define _TIME_T_DEFINED
-#endif
-
-#ifndef _WCHAR_T_DEFINED
-  typedef unsigned short wchar_t;
-#define _WCHAR_T_DEFINED
-#endif
-
 #ifndef _STAT_DEFINED
+#define _STAT_DEFINED
 
   struct _stat32 {
     _dev_t st_dev;
@@ -107,8 +67,7 @@ extern "C" {
   };
 #endif
 
-/* #if _INTEGRAL_MAX_BITS >= 64 */
-
+#if _INTEGRAL_MAX_BITS >= 64
   struct _stat32i64 {
     _dev_t st_dev;
     _ino_t st_ino;
@@ -165,11 +124,10 @@ extern "C" {
     time_t st_ctime;
   };
 
-/* #endif */
+#endif /* _INTEGRAL_MAX_BITS >= 64 */
 
 #define __stat64 _stat64
 
-#define _STAT_DEFINED
 #endif /* !_STAT_DEFINED */
 
 #define _S_IFMT 0xF000
@@ -189,52 +147,16 @@ extern "C" {
 #if _INTEGRAL_MAX_BITS >= 64
   _CRTIMP int __cdecl _fstat64(int _FileDes,struct _stat64 *_Stat);
   _CRTIMP int __cdecl _fstat32i64(int _FileDes,struct _stat32i64 *_Stat);
-  int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat);
-  __CRT_INLINE int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat)
-  {
-    struct _stat64 st;
-    int ret=_fstat64(_FileDes,&st);
-    _Stat->st_dev=st.st_dev;
-    _Stat->st_ino=st.st_ino;
-    _Stat->st_mode=st.st_mode;
-    _Stat->st_nlink=st.st_nlink;
-    _Stat->st_uid=st.st_uid;
-    _Stat->st_gid=st.st_gid;
-    _Stat->st_rdev=st.st_rdev;
-    _Stat->st_size=(_off_t) st.st_size;
-    _Stat->st_atime=st.st_atime;
-    _Stat->st_mtime=st.st_mtime;
-    _Stat->st_ctime=st.st_ctime;
-    return ret;
-  }
-
+  _CRTIMP int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat);
   _CRTIMP int __cdecl _stat64(const char *_Name,struct _stat64 *_Stat);
   _CRTIMP int __cdecl _stat32i64(const char *_Name,struct _stat32i64 *_Stat);
-  int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat);
-  __CRT_INLINE int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat)
-  {
-    struct _stat64 st;
-    int ret=_stat64(_Name,&st);
-    _Stat->st_dev=st.st_dev;
-    _Stat->st_ino=st.st_ino;
-    _Stat->st_mode=st.st_mode;
-    _Stat->st_nlink=st.st_nlink;
-    _Stat->st_uid=st.st_uid;
-    _Stat->st_gid=st.st_gid;
-    _Stat->st_rdev=st.st_rdev;
-    _Stat->st_size=(_off_t) st.st_size;
-    _Stat->st_atime=st.st_atime;
-    _Stat->st_mtime=st.st_mtime;
-    _Stat->st_ctime=st.st_ctime;
-    return ret;
-  }
-#endif
+  _CRTIMP int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat);
+#endif /* _INTEGRAL_MAX_BITS >= 64 */
 
 #ifndef _WSTAT_DEFINED
 #define _WSTAT_DEFINED
   _CRTIMP int __cdecl _wstat(const wchar_t *_Name,struct _stat *_Stat);
   _CRTIMP int __cdecl _wstat32(const wchar_t *_Name,struct _stat32 *_Stat);
-  _CRTIMP int __cdecl _wstati64(const wchar_t *_Name,struct _stati64 *_Stat);
 #if _INTEGRAL_MAX_BITS >= 64
   _CRTIMP int __cdecl _wstat32i64(const wchar_t *_Name,struct _stat32i64 *_Stat);
   _CRTIMP int __cdecl _wstat64i32(const wchar_t *_Name,struct _stat64i32 *_Stat);
@@ -242,6 +164,55 @@ extern "C" {
 #endif
 #endif
 
+
+/** Compatibility definitons *************************************************/
+
+#if !defined(RC_INVOKED)
+
+#ifdef _USE_32BIT_TIME_T
+ #define _fstat32 _fstat
+ #define _fstat32i64 _fstati64
+ #define _fstat64i32 _fstat64
+#else
+ #define _fstat64i32 _fstat
+  __CRT_INLINE int __cdecl _fstat32(int _FileDes, struct _stat32 *_Stat)
+  {
+    struct _stat _Stat64;
+    int ret = _fstat(_FileDes, &_Stat64);
+    _Stat->st_dev = _Stat64.st_dev;
+    _Stat->st_ino = _Stat64.st_ino;
+    _Stat->st_mode = _Stat64.st_mode;
+    _Stat->st_nlink = _Stat64.st_nlink;
+    _Stat->st_uid = _Stat64.st_uid;
+    _Stat->st_gid = _Stat64.st_gid;
+    _Stat->st_rdev = _Stat64.st_rdev;
+    _Stat->st_size = _Stat64.st_size;
+    _Stat->st_atime = _Stat64.st_atime;
+    _Stat->st_mtime = _Stat64.st_mtime;
+    _Stat->st_ctime = _Stat64.st_ctime;
+    return ret;
+  }
+  __CRT_INLINE int __cdecl _fstat32i64(int _FileDes, struct _stat32i64 *_Stat)
+  {
+    struct _stat64 _Stat64;
+    int ret = _fstat64(_FileDes, &_Stat64);
+    _Stat->st_dev = _Stat64.st_dev;
+    _Stat->st_ino = _Stat64.st_ino;
+    _Stat->st_mode = _Stat64.st_mode;
+    _Stat->st_nlink = _Stat64.st_nlink;
+    _Stat->st_uid = _Stat64.st_uid;
+    _Stat->st_gid = _Stat64.st_gid;
+    _Stat->st_rdev = _Stat64.st_rdev;
+    _Stat->st_size = _Stat64.st_size;
+    _Stat->st_atime = _Stat64.st_atime;
+    _Stat->st_mtime = _Stat64.st_mtime;
+    _Stat->st_ctime = _Stat64.st_ctime;
+    return ret;
+  }
+#endif /* _USE_32BIT_TIME_T */
+
+#endif /* !defined(RC_INVOKED) */
+
 #ifndef        NO_OLDNAMES
 #define        _S_IFBLK        0x3000  /* Block: Is this ever set under w32? */
 
@@ -271,13 +242,10 @@ extern "C" {
 #define        S_ISBLK(m)      (((m) & S_IFMT) == S_IFBLK)
 #define        S_ISREG(m)      (((m) & S_IFMT) == S_IFREG)
 
-#endif
-
-#if !defined (RC_INVOKED) && !defined (NO_OLDNAMES)
-int __cdecl stat(const char *_Filename,struct stat *_Stat);
-int __cdecl fstat(int _Desc,struct stat *_Stat);
-int __cdecl wstat(const wchar_t *_Filename,struct stat *_Stat);
-
+#if !defined (RC_INVOKED)
+  _CRTIMP int __cdecl stat(const char *_Filename,struct stat *_Stat);
+  _CRTIMP int __cdecl fstat(int _Desc,struct stat *_Stat);
+  _CRTIMP int __cdecl wstat(const wchar_t *_Filename,struct stat *_Stat);
 __CRT_INLINE int __cdecl fstat(int _Desc,struct stat *_Stat) {
   return _fstat(_Desc,(struct _stat *)_Stat);
 }
@@ -292,6 +260,9 @@ __CRT_INLINE int __cdecl wstat(const wchar_t *_Filename,struct stat *_Stat) {
 
 #endif
 
+#endif /* !NO_OLDNAMES */
+
+
 #ifdef __cplusplus
 }
 #endif