source: Daodan/MinGW/include/stdint.h@ 1054

Last change on this file since 1054 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

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