ntdll: Fix compilation on systems that don't support nameless unions.
[wine] / include / msvcrt / sys / stat.h
1 /*
2  * _stat() definitions
3  *
4  * Derived from the mingw header written by Colin Peters.
5  * Modified for Wine use by Jon Griffiths and Francois Gouget.
6  * This file is in the public domain.
7  */
8 #ifndef __WINE_SYS_STAT_H
9 #define __WINE_SYS_STAT_H
10 #ifndef __WINE_USE_MSVCRT
11 #define __WINE_USE_MSVCRT
12 #endif
13
14 #include <pshpack8.h>
15
16 #include <sys/types.h>
17
18 #ifndef _WCHAR_T_DEFINED
19 #define _WCHAR_T_DEFINED
20 #ifndef __cplusplus
21 typedef unsigned short wchar_t;
22 #endif
23 #endif
24
25 #ifndef _MSC_VER
26 # ifndef __int64
27 #  define __int64 long long
28 # endif
29 #endif
30
31 #ifndef _DEV_T_DEFINED
32 typedef unsigned int _dev_t;
33 #define _DEV_T_DEFINED
34 #endif
35
36 #ifndef _INO_T_DEFINED
37 typedef unsigned short _ino_t;
38 #define _INO_T_DEFINED
39 #endif
40
41 #ifndef _TIME_T_DEFINED
42 typedef long time_t;
43 #define _TIME_T_DEFINED
44 #endif
45
46 #ifndef _OFF_T_DEFINED
47 typedef int _off_t;
48 #define _OFF_T_DEFINED
49 #endif
50
51 #ifndef DECLSPEC_ALIGN
52 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
53 #  define DECLSPEC_ALIGN(x) __declspec(align(x))
54 # elif defined(__GNUC__)
55 #  define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
56 # else
57 #  define DECLSPEC_ALIGN(x)
58 # endif
59 #endif
60
61 #define _S_IEXEC  0x0040
62 #define _S_IWRITE 0x0080
63 #define _S_IREAD  0x0100
64 #define _S_IFIFO  0x1000
65 #define _S_IFCHR  0x2000
66 #define _S_IFDIR  0x4000
67 #define _S_IFREG  0x8000
68 #define _S_IFMT   0xF000
69
70 /* for FreeBSD */
71 #undef st_atime
72 #undef st_ctime
73 #undef st_mtime
74
75 #ifndef _STAT_DEFINED
76 #define _STAT_DEFINED
77
78 struct _stat {
79   _dev_t st_dev;
80   _ino_t st_ino;
81   unsigned short st_mode;
82   short          st_nlink;
83   short          st_uid;
84   short          st_gid;
85   _dev_t st_rdev;
86   _off_t st_size;
87   time_t st_atime;
88   time_t st_mtime;
89   time_t st_ctime;
90 };
91
92 struct stat {
93   _dev_t st_dev;
94   _ino_t st_ino;
95   unsigned short st_mode;
96   short          st_nlink;
97   short          st_uid;
98   short          st_gid;
99   _dev_t st_rdev;
100   _off_t st_size;
101   time_t st_atime;
102   time_t st_mtime;
103   time_t st_ctime;
104 };
105
106 struct _stati64 {
107   _dev_t st_dev;
108   _ino_t st_ino;
109   unsigned short st_mode;
110   short          st_nlink;
111   short          st_uid;
112   short          st_gid;
113   _dev_t st_rdev;
114   __int64 DECLSPEC_ALIGN(8) st_size;
115   time_t st_atime;
116   time_t st_mtime;
117   time_t st_ctime;
118 };
119
120 struct _stat64 {
121   _dev_t st_dev;
122   _ino_t st_ino;
123   unsigned short st_mode;
124   short          st_nlink;
125   short          st_uid;
126   short          st_gid;
127   _dev_t st_rdev;
128   __int64 DECLSPEC_ALIGN(8) st_size;
129   __time64_t     st_atime;
130   __time64_t     st_mtime;
131   __time64_t     st_ctime;
132 };
133 #endif /* _STAT_DEFINED */
134
135 #ifdef __cplusplus
136 extern "C" {
137 #endif
138
139 int _fstat(int,struct _stat*);
140 int _stat(const char*,struct _stat*);
141 int _fstati64(int,struct _stati64*);
142 int _stati64(const char*,struct _stati64*);
143 int _fstat64(int,struct _stat64*);
144 int _stat64(const char*,struct _stat64*);
145 int _umask(int);
146
147 #ifndef _WSTAT_DEFINED
148 #define _WSTAT_DEFINED
149 int _wstat(const wchar_t*,struct _stat*);
150 int _wstati64(const wchar_t*,struct _stati64*);
151 int _wstat64(const wchar_t*,struct _stat64*);
152 #endif /* _WSTAT_DEFINED */
153
154 #ifdef __cplusplus
155 }
156 #endif
157
158
159 #define S_IFMT   _S_IFMT
160 #define S_IFDIR  _S_IFDIR
161 #define S_IFCHR  _S_IFCHR
162 #define S_IFREG  _S_IFREG
163 #define S_IREAD  _S_IREAD
164 #define S_IWRITE _S_IWRITE
165 #define S_IEXEC  _S_IEXEC
166
167 #define S_ISCHR(m)      (((m)&_S_IFMT) == _S_IFCHR)
168 #define S_ISDIR(m)      (((m)&_S_IFMT) == _S_IFDIR)
169 #define S_ISFIFO(m)     (((m)&_S_IFMT) == _S_IFIFO)
170 #define S_ISREG(m)      (((m)&_S_IFMT) == _S_IFREG)
171
172 static inline int fstat(int fd, struct stat* ptr) { return _fstat(fd, (struct _stat*)ptr); }
173 static inline int stat(const char* path, struct stat* ptr) { return _stat(path, (struct _stat*)ptr); }
174 #ifndef _UMASK_DEFINED
175 static inline int umask(int fd) { return _umask(fd); }
176 #define _UMASK_DEFINED
177 #endif
178
179 #include <poppack.h>
180
181 #endif /* __WINE_SYS_STAT_H */