2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the w64 mingw-runtime package.
4 * No warranty is given; refer to the file DISCLAIMER within this package.
10 #error Only Win32 target is supported!
16 #pragma pack(push,_CRT_PACKING)
23 #define _CRTIMP __declspec(dllimport)
26 #include <sys/types.h>
28 #ifdef _USE_32BIT_TIME_T
30 #undef _USE_32BIT_TIME_T
33 #if _INTEGRAL_MAX_BITS < 64
34 #define _USE_32BIT_TIME_T
38 #ifndef _TIME32_T_DEFINED
39 typedef long __time32_t
;
40 #define _TIME32_T_DEFINED
43 #ifndef _TIME64_T_DEFINED
44 #if _INTEGRAL_MAX_BITS >= 64
45 typedef __int64 __time64_t
;
47 #define _TIME64_T_DEFINED
50 #ifndef _TIME_T_DEFINED
51 #ifdef _USE_32BIT_TIME_T
52 typedef __time32_t
time_t;
54 typedef __time64_t
time_t;
56 #define _TIME_T_DEFINED
59 #ifndef _WCHAR_T_DEFINED
60 typedef unsigned short wchar_t;
61 #define _WCHAR_T_DEFINED
66 #ifdef _USE_32BIT_TIME_T
68 #define _fstat32 _fstat
70 #define _wstat32 _wstat
72 #define _fstat _fstat32
74 #define _wstat _wstat32
76 #define _fstati64 _fstat32i64
77 #define _stati64 _stat32i64
78 #define _wstati64 _wstat32i64
80 #define _fstat _fstat64i32
81 #define _fstati64 _fstat64
82 #define _stat _stat64i32
83 #define _stati64 _stat64
84 #define _wstat _wstat64i32
85 #define _wstati64 _wstat64
91 unsigned short st_mode
;
106 unsigned short st_mode
;
118 #if _INTEGRAL_MAX_BITS >= 64
122 unsigned short st_mode
;
136 unsigned short st_mode
;
150 unsigned short st_mode
;
162 #define __stat64 _stat64
164 #define _STAT_DEFINED
167 #define _S_IFMT 0xF000
168 #define _S_IFDIR 0x4000
169 #define _S_IFCHR 0x2000
170 #define _S_IFIFO 0x1000
171 #define _S_IFREG 0x8000
172 #define _S_IREAD 0x0100
173 #define _S_IWRITE 0x0080
174 #define _S_IEXEC 0x0040
176 _CRTIMP
int __cdecl
_fstat32(int _FileDes
,struct _stat32
*_Stat
);
177 _CRTIMP
int __cdecl
_stat32(const char *_Name
,struct _stat32
*_Stat
);
178 #if _INTEGRAL_MAX_BITS >= 64
179 _CRTIMP
int __cdecl
_fstat64(int _FileDes
,struct _stat64
*_Stat
);
180 _CRTIMP
int __cdecl
_fstat32i64(int _FileDes
,struct _stat32i64
*_Stat
);
181 int __cdecl
_fstat64i32(int _FileDes
,struct _stat64i32
*_Stat
);
182 __CRT_INLINE
int __cdecl
_fstat64i32(int _FileDes
,struct _stat64i32
*_Stat
)
185 int ret
=_fstat64(_FileDes
,&st
);
186 _Stat
->st_dev
=st
.st_dev
;
187 _Stat
->st_ino
=st
.st_ino
;
188 _Stat
->st_mode
=st
.st_mode
;
189 _Stat
->st_nlink
=st
.st_nlink
;
190 _Stat
->st_uid
=st
.st_uid
;
191 _Stat
->st_gid
=st
.st_gid
;
192 _Stat
->st_rdev
=st
.st_rdev
;
193 _Stat
->st_size
=(_off_t
) st
.st_size
;
194 _Stat
->st_atime
=st
.st_atime
;
195 _Stat
->st_mtime
=st
.st_mtime
;
196 _Stat
->st_ctime
=st
.st_ctime
;
199 _CRTIMP
int __cdecl
_stat64(const char *_Name
,struct _stat64
*_Stat
);
200 _CRTIMP
int __cdecl
_stat32i64(const char *_Name
,struct _stat32i64
*_Stat
);
201 int __cdecl
_stat64i32(const char *_Name
,struct _stat64i32
*_Stat
);
202 __CRT_INLINE
int __cdecl
_stat64i32(const char *_Name
,struct _stat64i32
*_Stat
)
205 int ret
=_stat64(_Name
,&st
);
206 _Stat
->st_dev
=st
.st_dev
;
207 _Stat
->st_ino
=st
.st_ino
;
208 _Stat
->st_mode
=st
.st_mode
;
209 _Stat
->st_nlink
=st
.st_nlink
;
210 _Stat
->st_uid
=st
.st_uid
;
211 _Stat
->st_gid
=st
.st_gid
;
212 _Stat
->st_rdev
=st
.st_rdev
;
213 _Stat
->st_size
=(_off_t
) st
.st_size
;
214 _Stat
->st_atime
=st
.st_atime
;
215 _Stat
->st_mtime
=st
.st_mtime
;
216 _Stat
->st_ctime
=st
.st_ctime
;
221 #ifndef _WSTAT_DEFINED
222 #define _WSTAT_DEFINED
223 _CRTIMP
int __cdecl
_wstat32(const wchar_t *_Name
,struct _stat32
*_Stat
);
224 #if _INTEGRAL_MAX_BITS >= 64
225 _CRTIMP
int __cdecl
_wstat32i64(const wchar_t *_Name
,struct _stat32i64
*_Stat
);
226 int __cdecl
_wstat64i32(const wchar_t *_Name
,struct _stat64i32
*_Stat
);
227 _CRTIMP
int __cdecl
_wstat64(const wchar_t *_Name
,struct _stat64
*_Stat
);
232 #define _S_IFBLK 0x3000 /* Block: Is this ever set under w32? */
234 #define S_IFMT _S_IFMT
235 #define S_IFDIR _S_IFDIR
236 #define S_IFCHR _S_IFCHR
237 #define S_IFREG _S_IFREG
238 #define S_IREAD _S_IREAD
239 #define S_IWRITE _S_IWRITE
240 #define S_IEXEC _S_IEXEC
241 #define S_IFIFO _S_IFIFO
242 #define S_IFBLK _S_IFBLK
244 #define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
245 #define _S_IXUSR _S_IEXEC
246 #define _S_IWUSR _S_IWRITE
248 #define S_IRWXU _S_IRWXU
249 #define S_IXUSR _S_IXUSR
250 #define S_IWUSR _S_IWUSR
251 #define S_IRUSR _S_IRUSR
252 #define _S_IRUSR _S_IREAD
254 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
255 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
256 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
257 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
258 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
262 #if !defined (RC_INVOKED) && !defined (NO_OLDNAMES)
263 int __cdecl
stat(const char *_Filename
,struct stat
*_Stat
);
264 int __cdecl
fstat(int _Desc
,struct stat
*_Stat
);
265 int __cdecl
wstat(const wchar_t *_Filename
,struct stat
*_Stat
);
266 #ifdef _USE_32BIT_TIME_T
267 __CRT_INLINE
int __cdecl
fstat(int _Desc
,struct stat
*_Stat
) {
268 return _fstat32(_Desc
,(struct _stat32
*)_Stat
);
270 __CRT_INLINE
int __cdecl
stat(const char *_Filename
,struct stat
*_Stat
) {
271 return _stat32(_Filename
,(struct _stat32
*)_Stat
);
274 __CRT_INLINE
int __cdecl
fstat(int _Desc
,struct stat
*_Stat
) {
275 return _fstat64i32(_Desc
,(struct _stat64i32
*)_Stat
);
277 __CRT_INLINE
int __cdecl
stat(const char *_Filename
,struct stat
*_Stat
) {
278 return _stat64i32(_Filename
,(struct _stat64i32
*)_Stat
);