win64: use new headers from mingw
[tinycc/kirr.git] / win32 / include / sys / stat.h
blob141ac35b66e1617795d93974e142b0a7bca74323
1 /**
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.
5 */
6 #ifndef _INC_STAT
7 #define _INC_STAT
9 #ifndef _WIN32
10 #error Only Win32 target is supported!
11 #endif
13 #include <_mingw.h>
14 #include <io.h>
16 #pragma pack(push,_CRT_PACKING)
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
22 #ifndef _CRTIMP
23 #define _CRTIMP __declspec(dllimport)
24 #endif
26 #include <sys/types.h>
28 #ifdef _USE_32BIT_TIME_T
29 #ifdef _WIN64
30 #undef _USE_32BIT_TIME_T
31 #endif
32 #else
33 #if _INTEGRAL_MAX_BITS < 64
34 #define _USE_32BIT_TIME_T
35 #endif
36 #endif
38 #ifndef _TIME32_T_DEFINED
39 typedef long __time32_t;
40 #define _TIME32_T_DEFINED
41 #endif
43 #ifndef _TIME64_T_DEFINED
44 #if _INTEGRAL_MAX_BITS >= 64
45 typedef __int64 __time64_t;
46 #endif
47 #define _TIME64_T_DEFINED
48 #endif
50 #ifndef _TIME_T_DEFINED
51 #ifdef _USE_32BIT_TIME_T
52 typedef __time32_t time_t;
53 #else
54 typedef __time64_t time_t;
55 #endif
56 #define _TIME_T_DEFINED
57 #endif
59 #ifndef _WCHAR_T_DEFINED
60 typedef unsigned short wchar_t;
61 #define _WCHAR_T_DEFINED
62 #endif
64 #ifndef _STAT_DEFINED
66 #ifdef _USE_32BIT_TIME_T
67 #ifndef _WIN64
68 #define _fstat32 _fstat
69 #define _stat32 _stat
70 #define _wstat32 _wstat
71 #else
72 #define _fstat _fstat32
73 #define _stat _stat32
74 #define _wstat _wstat32
75 #endif
76 #define _fstati64 _fstat32i64
77 #define _stati64 _stat32i64
78 #define _wstati64 _wstat32i64
79 #else
80 #define _fstat _fstat64i32
81 #define _fstati64 _fstat64
82 #define _stat _stat64i32
83 #define _stati64 _stat64
84 #define _wstat _wstat64i32
85 #define _wstati64 _wstat64
86 #endif
88 struct _stat32 {
89 _dev_t st_dev;
90 _ino_t st_ino;
91 unsigned short st_mode;
92 short st_nlink;
93 short st_uid;
94 short st_gid;
95 _dev_t st_rdev;
96 _off_t st_size;
97 __time32_t st_atime;
98 __time32_t st_mtime;
99 __time32_t st_ctime;
102 #ifndef NO_OLDNAMES
103 struct stat {
104 _dev_t st_dev;
105 _ino_t st_ino;
106 unsigned short st_mode;
107 short st_nlink;
108 short st_uid;
109 short st_gid;
110 _dev_t st_rdev;
111 _off_t st_size;
112 time_t st_atime;
113 time_t st_mtime;
114 time_t st_ctime;
116 #endif
118 #if _INTEGRAL_MAX_BITS >= 64
119 struct _stat32i64 {
120 _dev_t st_dev;
121 _ino_t st_ino;
122 unsigned short st_mode;
123 short st_nlink;
124 short st_uid;
125 short st_gid;
126 _dev_t st_rdev;
127 __int64 st_size;
128 __time32_t st_atime;
129 __time32_t st_mtime;
130 __time32_t st_ctime;
133 struct _stat64i32 {
134 _dev_t st_dev;
135 _ino_t st_ino;
136 unsigned short st_mode;
137 short st_nlink;
138 short st_uid;
139 short st_gid;
140 _dev_t st_rdev;
141 _off_t st_size;
142 __time64_t st_atime;
143 __time64_t st_mtime;
144 __time64_t st_ctime;
147 struct _stat64 {
148 _dev_t st_dev;
149 _ino_t st_ino;
150 unsigned short st_mode;
151 short st_nlink;
152 short st_uid;
153 short st_gid;
154 _dev_t st_rdev;
155 __int64 st_size;
156 __time64_t st_atime;
157 __time64_t st_mtime;
158 __time64_t st_ctime;
160 #endif
162 #define __stat64 _stat64
164 #define _STAT_DEFINED
165 #endif
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)
184 struct _stat64 st;
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;
197 return ret;
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)
204 struct _stat64 st;
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;
217 return ret;
219 #endif
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);
228 #endif
229 #endif
231 #ifndef NO_OLDNAMES
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)
260 #endif
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);
273 #else
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);
280 #endif
281 #endif
283 #ifdef __cplusplus
285 #endif
287 #pragma pack(pop)
288 #endif