OSDN Git Service

Add typedef and access support for opaque locale_t objects.
[mingw/mingw-org-wsl.git] / mingwrt / include / stdint.h
1 /*
2  * stdint.h
3  *
4  * Integer type definitions, as prescribed by ISO-C9x Section 7.18
5  * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794)
6  *
7  * $Id$
8  *
9  * Written by Danny Smith <danny_r_smith_2001@yahoo.co.nz>
10  * Copyright (C) 2000-2002, 2004, 2005, 2007, 2009, 2016, 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 _STDINT_H
34 #pragma GCC system_header
35
36 /* To support selective definition of just intptr_t or uintptr_t,
37  * we defer definition of the normal multiple inclusion guard macro,
38  * until we've determined that neither selection is active.
39  */
40 #if ! defined __need_intptr_t && ! defined __need_uintptr_t
41 #define _STDINT_H
42
43 /* We need to duplicate the definitions of wint_t and wchar_t, as
44  * they are defined in <stddef.h>; get them, by selective inclusion
45  * from that header itself.
46  */
47 #define __need_wint_t
48 #define __need_wchar_t
49 #include <stddef.h>
50
51 /* 7.18.1.1  Exact-width integer types.
52  */
53 typedef signed char             int8_t;
54 typedef unsigned char           uint8_t;
55 typedef short                   int16_t;
56 typedef unsigned short          uint16_t;
57 typedef int                     int32_t;
58 typedef unsigned                uint32_t;
59 typedef long long               int64_t;
60 typedef unsigned long long      uint64_t;
61
62 /* 7.18.1.2  Minimum-width integer types.
63  */
64 typedef signed char             int_least8_t;
65 typedef unsigned char           uint_least8_t;
66 typedef short                   int_least16_t;
67 typedef unsigned short          uint_least16_t;
68 typedef int                     int_least32_t;
69 typedef unsigned                uint_least32_t;
70 typedef long long               int_least64_t;
71 typedef unsigned long long      uint_least64_t;
72
73 /*  7.18.1.3  Fastest minimum-width integer types
74  *  Not actually guaranteed to be fastest for all purposes
75  *  Here we use the exact-width types for 8 and 16-bit ints.
76  */
77 typedef signed char             int_fast8_t;
78 typedef unsigned char           uint_fast8_t;
79 typedef short                   int_fast16_t;
80 typedef unsigned short          uint_fast16_t;
81 typedef int                     int_fast32_t;
82 typedef unsigned  int           uint_fast32_t;
83 typedef long long               int_fast64_t;
84 typedef unsigned long long      uint_fast64_t;
85
86 /* We actually DO need both selections, which had to be omitted
87  * to get us into this conditional block; force them!
88  */
89 #define __need_intptr_t
90 #define __need_uintptr_t
91
92 #endif  /* !__need_intptr_t && !__need_uintptr_t */
93
94 /* 7.18.1.4  Integer types capable of holding object pointers.
95  */
96 #if defined __need_intptr_t && ! defined __intptr_t
97 #define __intptr_t __intptr_t
98 #ifdef _WIN64
99  typedef __int64 __intptr_t;
100 #else
101  typedef int __intptr_t;
102 #endif
103 typedef __intptr_t intptr_t;
104
105 #endif  /* __need_intptr_t */
106 #undef __need_intptr_t
107
108 #if defined __need_uintptr_t && ! defined __uintptr_t
109 #define __uintptr_t __uintptr_t
110 #ifdef _WIN64
111  typedef unsigned __int64 __uintptr_t;
112 #else
113  typedef unsigned int __uintptr_t;
114 #endif
115 typedef __uintptr_t uintptr_t;
116
117 #endif  /* __need_uintptr_t */
118 #undef __need_uintptr_t
119
120 #ifdef  _STDINT_H
121 /* 7.18.1.5  Greatest-width integer types.
122  */
123 typedef long long  intmax_t;
124 typedef unsigned long long uintmax_t;
125
126 /* 7.18.2  Limits of specified-width integer types.
127  * (always defined in C, but C++ needs __STDC_LIMIT_MACROS)
128  */
129 #if ! defined __cplusplus || defined __STDC_LIMIT_MACROS
130
131 /* 7.18.2.1  Limits of exact-width integer types.
132  */
133 #define INT8_MIN                (-128)
134 #define INT16_MIN               (-32768)
135 #define INT32_MIN               (-2147483647 - 1)
136 #define INT64_MIN               (-9223372036854775807LL - 1)
137
138 #define INT8_MAX                127
139 #define INT16_MAX               32767
140 #define INT32_MAX               2147483647
141 #define INT64_MAX               9223372036854775807LL
142
143 #define UINT8_MAX               0xffU                   /* 255U */
144 #define UINT16_MAX              0xffffU                 /* 65535U */
145 #define UINT32_MAX              0xffffffffUL            /* 4294967295U */
146 #define UINT64_MAX              0xffffffffffffffffULL   /* 18446744073709551615ULL */
147
148 /* 7.18.2.2  Limits of minimum-width integer types.
149  */
150 #define INT_LEAST8_MIN          INT8_MIN
151 #define INT_LEAST16_MIN         INT16_MIN
152 #define INT_LEAST32_MIN         INT32_MIN
153 #define INT_LEAST64_MIN         INT64_MIN
154
155 #define INT_LEAST8_MAX          INT8_MAX
156 #define INT_LEAST16_MAX         INT16_MAX
157 #define INT_LEAST32_MAX         INT32_MAX
158 #define INT_LEAST64_MAX         INT64_MAX
159
160 #define UINT_LEAST8_MAX         UINT8_MAX
161 #define UINT_LEAST16_MAX        UINT16_MAX
162 #define UINT_LEAST32_MAX        UINT32_MAX
163 #define UINT_LEAST64_MAX        UINT64_MAX
164
165 /* 7.18.2.3  Limits of fastest minimum-width integer types.
166  */
167 #define INT_FAST8_MIN           INT8_MIN
168 #define INT_FAST16_MIN          INT16_MIN
169 #define INT_FAST32_MIN          INT32_MIN
170 #define INT_FAST64_MIN          INT64_MIN
171
172 #define INT_FAST8_MAX           INT8_MAX
173 #define INT_FAST16_MAX          INT16_MAX
174 #define INT_FAST32_MAX          INT32_MAX
175 #define INT_FAST64_MAX          INT64_MAX
176
177 #define UINT_FAST8_MAX          UINT8_MAX
178 #define UINT_FAST16_MAX         UINT16_MAX
179 #define UINT_FAST32_MAX         UINT32_MAX
180 #define UINT_FAST64_MAX         UINT64_MAX
181
182 /* 7.18.2.4  Limits of integer types capable of holding object pointers.
183  */
184 #ifdef _WIN64
185 # define INTPTR_MIN             INT64_MIN
186 # define INTPTR_MAX             INT64_MAX
187 # define UINTPTR_MAX            UINT64_MAX
188 #else
189 # define INTPTR_MIN             INT32_MIN
190 # define INTPTR_MAX             INT32_MAX
191 # define UINTPTR_MAX            UINT32_MAX
192 #endif
193
194 /* 7.18.2.5  Limits of greatest-width integer types.
195  */
196 #define INTMAX_MIN              INT64_MIN
197 #define INTMAX_MAX              INT64_MAX
198 #define UINTMAX_MAX             UINT64_MAX
199
200 /* 7.18.3  Limits of other integer types.
201  */
202 #define PTRDIFF_MIN             INTPTR_MIN
203 #define PTRDIFF_MAX             INTPTR_MAX
204
205 #define SIG_ATOMIC_MIN          INTPTR_MIN
206 #define SIG_ATOMIC_MAX          INTPTR_MAX
207
208 #define SIZE_MAX                UINTPTR_MAX
209
210 /* The following pair are also defined in <wchar.h>, but leave them
211  * unguarded, so that the compiler may check for consistency.
212  */
213 #define WCHAR_MIN               0
214 #define WCHAR_MAX               0xffff /* UINT16_MAX */
215
216 /* wint_t is unsigned short for compatibility with MS runtime
217  */
218 #define WINT_MIN                0
219 #define WINT_MAX                0xffff /* UINT16_MAX */
220
221 #endif  /* !__cplusplus || __STDC_LIMIT_MACROS */
222
223 /* 7.18.4  Macros for integer constants.
224  * (always defined in C, but C++ needs __STDC_CONSTANT_MACROS)
225  */
226 #if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
227
228 /* 7.18.4.1  Macros for minimum-width integer constants
229  *
230  * According to Douglas Gwyn <gwyn@arl.mil>:
231  *  "This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC
232  *  9899:1999 as initially published, the expansion was required
233  *  to be an integer constant of precisely matching type, which
234  *  is impossible to accomplish for the shorter types on most
235  *  platforms, because C99 provides no standard way to designate
236  *  an integer constant with width less than that of type int.
237  *  TC1 changed this to require just an integer constant
238  *  EXPRESSION with PROMOTED type".
239  */
240 #define INT8_C(val)             val
241 #define UINT8_C(val)            val
242 #define INT16_C(val)            val
243 #define UINT16_C(val)           val
244
245 #define INT32_C(val)            val
246 #define UINT32_C(val)           val##U
247 #define INT64_C(val)            val##LL
248 #define UINT64_C(val)           val##ULL
249
250 /* 7.18.4.2  Macros for greatest-width integer constants.
251  */
252 #define INTMAX_C(val)           INT64_C(val)
253 #define UINTMAX_C(val)          UINT64_C(val)
254
255 #endif  /* !__cplusplus || __STDC_CONSTANT_MACROS */
256 #endif  /* _STDINT_H */
257
258 #endif  /* !_STDINT_H: $RCSfile$: end of file */