OSDN Git Service

Make resetting of __need_typedef requests more robust.
[mingw/mingw-org-wsl.git] / mingwrt / include / sys / types.h
1 /*
2  * sys/types.h
3  *
4  * Definitions of (primarily POSIX) system data types.
5  *
6  * $Id$
7  *
8  * Written by Rob Savoye <rob@cygnus.com>
9  * Copyright (C) 1997-1999, 2001, 2003, 2004, 2008, 2011, 2014-2016,
10  *   MinGW.org Project.
11  *
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice, this permission notice, and the following
21  * disclaimer shall be included in all copies or substantial portions of
22  * the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
27  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
30  * DEALINGS IN THE SOFTWARE.
31  *
32  */
33 #ifndef _SYS_TYPES_H
34 #pragma GCC system_header
35
36 /* All the headers include this file.
37  */
38 #include <_mingw.h>
39
40 /* Duplicates of some type definitions from here are also to be
41  * provided by other system headers; use __need_TYPENAME selector
42  * macros to make them selectively visible...
43  */
44 #if ! defined __need_off_t && ! defined __need___off64_t \
45  && ! defined __need_ssize_t && ! defined __need_time_t
46  /*
47   * ...and define the multiple inclusion guard macro for this
48   * header, ONLY IF no such selector macro is defined.
49   */
50 #define _SYS_TYPES_H
51 #endif
52
53 #ifndef RC_INVOKED
54 /* First handle those typedefs which POSIX requires us to be able
55  * to expose selectively, via other system headers.
56  */
57 #if ! defined __have_typedef_off_t \
58  && ( defined _SYS_TYPES_H || defined __need_off_t )
59  /* We base this on an implementation specific private typedef,
60   * analogous to our __off64_t (defined below)...
61   */
62   typedef __int32  __off32_t;
63
64  /* The POSIX off_t typedef is uglified, by Microsoft, as _off_t;
65   * ensure that we provide support for the Microsoft form...
66   */
67   typedef __off32_t  _off_t;
68
69 # if _POSIX_C_SOURCE
70   /* ...but note that this form should ALWAYS be preferred when
71    * compiling POSIX compatible source code.
72    */
73   typedef _off_t  off_t;
74 # endif
75 # if __GNUC__ < 4
76   /* Some compilers, including GCC prior to v4, may get upset
77    * if we try to specifiy these typedefs more than once.
78    */
79 #  define __have_typedef_off_t
80 # endif
81 #endif
82 #undef __need_off_t
83
84 #if ! defined __have_typedef___off64_t \
85  && ( defined _SYS_TYPES_H || defined __need___off64_t )
86  /* This is neither an ISO-C standard type, nor even a POSIX
87   * standard type; keep it runtime implementation specific.
88   */
89   typedef __int64  __off64_t;
90
91 # ifndef __STRICT_ANSI__
92   /* GCC itself, (specifically libgfortran.a), gratuitously
93    * assumes that non-standard type off64_t is defined; make
94    * it so, pending upstream correction.
95    */
96   typedef __off64_t  off64_t;
97 # endif
98
99 # if __GNUC__ < 4
100   /* Some compilers, including GCC prior to v4, may get upset
101    * if we try to specifiy these typedefs more than once.
102    */
103 #  define __have_typedef___off64_t
104 # endif
105 #endif
106 #undef __need___off64_t
107
108 #if ! defined __have_typedef_ssize_t \
109  && ( defined _SYS_TYPES_H || defined __need_ssize_t )
110  /* POSIX ssize_t typedef, uglified by Microsoft as _ssize_t; ensure
111   * that we support the Microsoft form...
112   */
113   typedef int  _ssize_t;
114
115 # if _POSIX_C_SOURCE
116   /* ...but note that this form should ALWAYS be preferred when
117    * compiling POSIX compatible source code.
118    */
119   typedef _ssize_t  ssize_t;
120 # endif
121 # if __GNUC__ < 4
122   /* Some compilers, including GCC prior to v4, may get upset
123    * if we try to specifiy these typedefs more than once.
124    */
125 #  define __have_typedef_ssize_t
126 # endif
127 #endif
128 #undef __need_ssize_t
129
130 #if ! defined __have_typedef_time_t \
131  && ( defined _SYS_TYPES_H || defined __need_time_t )
132  /* Current versions of MSVC define time_t ambiguously, in terms of
133   * one of the following unambiguous internal types:
134   */
135   typedef __int32 __time32_t;   /* unambiguous 32-bit time_t */
136   typedef __int64 __time64_t;   /* unambiguous 64-bit time_t */
137
138 # if __MSVCRT_VERSION__ < __MSVCR80_DLL || defined _USE_32BIT_TIME_T
139   /* From MSVCR80.DLL onwards, Microsoft have royally messed up the
140    * definition of time_t; maintain POSIX consistency, (as MSVCRT.DLL
141    * itself does), unless the user is explicitly using one of these
142    * brain damaged DLL variants, and has not elected to retain the
143    * 32-bit time_t representation.
144    */
145    typedef __time32_t time_t;
146
147 # else
148   /* Microsoft's brain damaged default, from MSVCR80.DLL onwards.
149    */
150    typedef __time64_t time_t;
151 # endif
152 # if __GCC__ < 4
153   /* Assume any compiler which is not GCC-4.x or newer may require
154    * guarding against repeated time_t typedefs.
155    */
156 #  define __have_typedef_time_t  1
157 # endif
158 #endif
159 #undef __need_time_t
160
161 #ifdef _SYS_TYPES_H
162 /* This is normal <sys/types.h> inclusion, i.e. for its own sake.
163  *
164  * A small subset of the required type definitions are actually
165  * furnished by <stddef.h>; get them by selective inclusion...
166  */
167 #define __need_size_t
168 #define __need_ptrdiff_t
169 #define __need_wchar_t
170 #include <stddef.h>
171
172 /* Today, Microsoft generally prefers to prefix POSIX type names
173  * with an ugly initial underscore; ensure that we provide support
174  * for this ungainly practice.
175  */
176 #ifdef __MSVCRT__
177  /* Additionally, note that _dev_t is a special case, requiring
178   * this definition when linking with MSVCRT.DLL...
179   */
180 typedef unsigned int    _dev_t;
181
182 #else
183  /* ...but this alternative, when linking with CRTDLL.DLL
184   */
185 typedef short           _dev_t;
186
187 #endif
188  /* ...while the remaining type names have consistent definitions,
189   * regardless of any particular DLL association.
190   */
191 typedef short           _ino_t;
192 typedef unsigned short  _mode_t;
193 typedef int             _pid_t;
194 typedef int             _sigset_t;
195
196 /* Users who value portability should prefer...
197  */
198 #if _POSIX_C_SOURCE || ! defined _NO_OLDNAMES
199  /* ...the standard POSIX type names, (which are consistent with
200   * earlier Microsoft naming practice, and are also historically
201   * exposed by MinGW, except when _NO_OLDNAMES is defined).
202   */
203 typedef _dev_t           dev_t;
204 typedef _ino_t           ino_t;
205 typedef _mode_t          mode_t;
206 typedef _pid_t           pid_t;
207 typedef _sigset_t        sigset_t;
208 #endif
209
210 typedef __int64          fpos64_t;
211
212 #if _POSIX_C_SOURCE
213 /* useconds_t is an obsolete POSIX data type; we continue to define
214  * it here, for backward compatibility, but we flag it as deprecated,
215  * due to its obsolete status.
216  */
217 typedef unsigned long useconds_t __MINGW_ATTRIB_DEPRECATED;
218 #endif
219 #endif  /* _SYS_TYPES_H normal inclusion */
220
221 #endif  /* ! RC_INVOKED */
222 #endif  /* !_SYS_TYPES_H: $RCSfile$: end of file */