OSDN Git Service

Correct mistyped __MINGW_NOTHROW macro.
[mingw/mingw-org-wsl.git] / include / stdint.h
1 /**
2  * @file stdint.h
3  * Copyright 2012, 2013 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 /* Created by Danny Smith <danny_r_smith_2001@yahoo.co.nz> */
25 #ifndef _STDINT_H
26 #define _STDINT_H
27 #pragma GCC system_header
28 #include <_mingw.h>
29
30 /* ISO C9x  7.18  Integer types <stdint.h>
31  * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794)
32  */
33
34 #define __need_wint_t
35 #define __need_wchar_t
36 #include <stddef.h>
37
38 /* 7.18.1.1  Exact-width integer types */
39 typedef signed char int8_t;
40 typedef unsigned char   uint8_t;
41 typedef short  int16_t;
42 typedef unsigned short  uint16_t;
43 typedef int  int32_t;
44 typedef unsigned   uint32_t;
45 typedef long long  int64_t;
46 typedef unsigned long long   uint64_t;
47
48 /* 7.18.1.2  Minimum-width integer types */
49 typedef signed char int_least8_t;
50 typedef unsigned char   uint_least8_t;
51 typedef short  int_least16_t;
52 typedef unsigned short  uint_least16_t;
53 typedef int  int_least32_t;
54 typedef unsigned   uint_least32_t;
55 typedef long long  int_least64_t;
56 typedef unsigned long long   uint_least64_t;
57
58 /*  7.18.1.3  Fastest minimum-width integer types 
59  *  Not actually guaranteed to be fastest for all purposes
60  *  Here we use the exact-width types for 8 and 16-bit ints. 
61  */
62 typedef signed char int_fast8_t;
63 typedef unsigned char uint_fast8_t;
64 typedef short  int_fast16_t;
65 typedef unsigned short  uint_fast16_t;
66 typedef int  int_fast32_t;
67 typedef unsigned  int  uint_fast32_t;
68 typedef long long  int_fast64_t;
69 typedef unsigned long long   uint_fast64_t;
70
71 /* 7.18.1.4  Integer types capable of holding object pointers */
72
73 #ifndef _INTPTR_T_DEFINED
74 #define _INTPTR_T_DEFINED
75 #ifdef _WIN64
76   typedef __int64 intptr_t;
77 #else
78   typedef int intptr_t;
79 #endif
80 #endif
81
82 #ifndef _UINTPTR_T_DEFINED
83 #define _UINTPTR_T_DEFINED
84 #ifdef _WIN64
85   typedef unsigned __int64 uintptr_t;
86 #else
87   typedef unsigned int uintptr_t;
88 #endif
89 #endif
90
91 /* 7.18.1.5  Greatest-width integer types */
92 typedef long long  intmax_t;
93 typedef unsigned long long uintmax_t;
94
95 /* 7.18.2  Limits of specified-width integer types */
96 #if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS)
97
98 /* 7.18.2.1  Limits of exact-width integer types */
99 #define INT8_MIN (-128) 
100 #define INT16_MIN (-32768)
101 #define INT32_MIN (-2147483647 - 1)
102 #define INT64_MIN  (-9223372036854775807LL - 1)
103
104 #define INT8_MAX 127
105 #define INT16_MAX 32767
106 #define INT32_MAX 2147483647
107 #define INT64_MAX 9223372036854775807LL
108
109 #define UINT8_MAX 0xff /* 255U */
110 #define UINT16_MAX 0xffff /* 65535U */
111 #define UINT32_MAX 0xffffffff  /* 4294967295U */
112 #define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
113
114 /* 7.18.2.2  Limits of minimum-width integer types */
115 #define INT_LEAST8_MIN INT8_MIN
116 #define INT_LEAST16_MIN INT16_MIN
117 #define INT_LEAST32_MIN INT32_MIN
118 #define INT_LEAST64_MIN INT64_MIN
119
120 #define INT_LEAST8_MAX INT8_MAX
121 #define INT_LEAST16_MAX INT16_MAX
122 #define INT_LEAST32_MAX INT32_MAX
123 #define INT_LEAST64_MAX INT64_MAX
124
125 #define UINT_LEAST8_MAX UINT8_MAX
126 #define UINT_LEAST16_MAX UINT16_MAX
127 #define UINT_LEAST32_MAX UINT32_MAX
128 #define UINT_LEAST64_MAX UINT64_MAX
129
130 /* 7.18.2.3  Limits of fastest minimum-width integer types */
131 #define INT_FAST8_MIN INT8_MIN
132 #define INT_FAST16_MIN INT16_MIN
133 #define INT_FAST32_MIN INT32_MIN
134 #define INT_FAST64_MIN INT64_MIN
135
136 #define INT_FAST8_MAX INT8_MAX
137 #define INT_FAST16_MAX INT16_MAX
138 #define INT_FAST32_MAX INT32_MAX
139 #define INT_FAST64_MAX INT64_MAX
140
141 #define UINT_FAST8_MAX UINT8_MAX
142 #define UINT_FAST16_MAX UINT16_MAX
143 #define UINT_FAST32_MAX UINT32_MAX
144 #define UINT_FAST64_MAX UINT64_MAX
145
146 /* 7.18.2.4  Limits of integer types capable of holding
147     object pointers */
148 #ifdef _WIN64
149 #define INTPTR_MIN INT64_MIN
150 #define INTPTR_MAX INT64_MAX
151 #define UINTPTR_MAX UINT64_MAX
152 #else
153 #define INTPTR_MIN INT32_MIN
154 #define INTPTR_MAX INT32_MAX
155 #define UINTPTR_MAX UINT32_MAX
156 #endif
157
158 /* 7.18.2.5  Limits of greatest-width integer types */
159 #define INTMAX_MIN INT64_MIN
160 #define INTMAX_MAX INT64_MAX
161 #define UINTMAX_MAX UINT64_MAX
162
163 /* 7.18.3  Limits of other integer types */
164 #define PTRDIFF_MIN INTPTR_MIN
165 #define PTRDIFF_MAX INTPTR_MAX
166
167 #define SIG_ATOMIC_MIN INTPTR_MIN
168 #define SIG_ATOMIC_MAX INTPTR_MAX
169
170 #define SIZE_MAX UINTPTR_MAX
171
172 #ifndef WCHAR_MIN  /* also in wchar.h */ 
173 #define WCHAR_MIN 0
174 #define WCHAR_MAX 0xffff /* UINT16_MAX */
175 #endif
176
177 /*
178  * wint_t is unsigned short for compatibility with MS runtime
179  */
180 #define WINT_MIN 0
181 #define WINT_MAX 0xffff /* UINT16_MAX */
182
183 #endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */
184
185
186 /* 7.18.4  Macros for integer constants */
187 #if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS)
188
189 /* 7.18.4.1  Macros for minimum-width integer constants
190
191     Accoding to Douglas Gwyn <gwyn@arl.mil>:
192         "This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC
193         9899:1999 as initially published, the expansion was required
194         to be an integer constant of precisely matching type, which
195         is impossible to accomplish for the shorter types on most
196         platforms, because C99 provides no standard way to designate
197         an integer constant with width less than that of type int.
198         TC1 changed this to require just an integer constant
199         *expression* with *promoted* type."
200 */
201
202 #define INT8_C(val) val
203 #define UINT8_C(val) val
204 #define INT16_C(val) val
205 #define UINT16_C(val) val
206
207 #define INT32_C(val) val
208 #define UINT32_C(val) val##U
209 #define INT64_C(val) val##LL
210 #define UINT64_C(val) val##ULL
211
212 /* 7.18.4.2  Macros for greatest-width integer constants */
213 #define INTMAX_C(val)  INT64_C(val)
214 #define UINTMAX_C(val) UINT64_C(val)
215
216 #endif  /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */
217
218 #endif