• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #define __CRT__NO_INLINE
2 #include <sys/stat.h>
3 
4 /* FIXME: Relying on _USE_32BIT_TIME_T, which is a user-macro,
5 during CRT compilation is plainly broken.  Need an appropriate
6 implementation to provide users the ability of compiling the
7 CRT only with 32-bit time_t behavior. */
8 #if defined(_USE_32BIT_TIME_T)
9 int __cdecl
fstat(int _Desc,struct stat * _Stat)10 fstat(int _Desc,struct stat *_Stat)
11 {
12   struct _stat32 st;
13   int ret=_fstat32(_Desc,&st);
14   if (ret == -1) {
15     memset(_Stat,0,sizeof(struct stat));
16     return -1;
17   }
18   /* struct stat and struct _stat32
19      are the same for this case. */
20   memcpy(_Stat, &st, sizeof(struct _stat32));
21   return ret;
22 }
23 #else
24 int __cdecl
fstat(int _Desc,struct stat * _Stat)25 fstat(int _Desc,struct stat *_Stat)
26 {
27   struct _stat64 st;
28   int ret=_fstat64(_Desc,&st);
29   if (ret == -1) {
30     memset(_Stat,0,sizeof(struct stat));
31     return -1;
32   }
33   /* struct stat and struct _stat64i32
34      are the same for this case. */
35   _Stat->st_dev=st.st_dev;
36   _Stat->st_ino=st.st_ino;
37   _Stat->st_mode=st.st_mode;
38   _Stat->st_nlink=st.st_nlink;
39   _Stat->st_uid=st.st_uid;
40   _Stat->st_gid=st.st_gid;
41   _Stat->st_rdev=st.st_rdev;
42   _Stat->st_size=(_off_t) st.st_size;
43   _Stat->st_atime=st.st_atime;
44   _Stat->st_mtime=st.st_mtime;
45   _Stat->st_ctime=st.st_ctime;
46   return ret;
47 }
48 #endif
49 
50 /* Add __imp__fstat and __imp__stat symbols.  */
51 int (*__MINGW_IMP_SYMBOL(fstat))(int, struct stat *) = &fstat;
52 
53