blob: 39a8ab8ddcda028b8d3e97f2b5ea0c178f0a38b3 [file] [log] [blame]
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28#ifndef _STDINT_H
29#define _STDINT_H
30
31#include <stddef.h>
32#include <sys/_types.h>
33
34
35
36#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
37# define __STDINT_LIMITS
38#endif
39
40#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
41# define __STDINT_MACROS
42#endif
43
The Android Open Source Project4e468ed2008-12-17 18:03:48 -080044/* the definitions of STDINT_LIMITS depend on those of STDINT_MACROS */
45#if defined __STDINT_LIMITS && !defined __STDINT_MACROS
46# define __STDINT_MACROS
47#endif
48
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070049typedef __int8_t int8_t;
50typedef __uint8_t uint8_t;
51typedef __int16_t int16_t;
52typedef __uint16_t uint16_t;
53typedef __int32_t int32_t;
54typedef __uint32_t uint32_t;
55#if !defined(__STRICT_ANSI__)
56typedef __int64_t int64_t;
57typedef __uint64_t uint64_t;
58#endif
59
60/*
61 * int8_t & uint8_t
62 */
63
64typedef int8_t int_least8_t;
65typedef int8_t int_fast8_t;
66
67typedef uint8_t uint_least8_t;
68typedef uint8_t uint_fast8_t;
69
70#ifdef __STDINT_LIMITS
71# define INT8_MIN (-128)
72# define INT8_MAX (127)
73# define INT_LEAST8_MIN INT8_MIN
74# define INT_LEAST8_MAX INT8_MAX
75# define INT_FAST8_MIN INT8_MIN
76# define INT_FAST8_MAX INT8_MAX
77
78# define UINT8_MAX (255U)
79# define UINT_LEAST8_MAX UINT8_MAX
80# define UINT_FAST8_MAX UINT8_MAX
81#endif
82
83#ifdef __STDINT_MACROS
84# define INT8_C(c) c
85# define INT_LEAST8_C(c) INT8_C(c)
86# define INT_FAST8_C(c) INT8_C(c)
87
88# define UINT8_C(c) c ## U
89# define UINT_LEAST8_C(c) UINT8_C(c)
90# define UINT_FAST8_C(c) UINT8_C(c)
91#endif
92
93/*
94 * int16_t & uint16_t
95 */
96
97
98typedef int16_t int_least16_t;
99typedef int32_t int_fast16_t;
100
101typedef uint16_t uint_least16_t;
102typedef uint32_t uint_fast16_t;
103
104#ifdef __STDINT_LIMITS
105# define INT16_MIN (-32768)
106# define INT16_MAX (32767)
107# define INT_LEAST16_MIN INT16_MIN
108# define INT_LEAST16_MAX INT16_MAX
109# define INT_FAST16_MIN INT32_MIN
110# define INT_FAST16_MAX INT32_MAX
111
112# define UINT16_MAX (65535U)
113# define UINT_LEAST16_MAX UINT16_MAX
114# define UINT_FAST16_MAX UINT32_MAX
115#endif
116
117#ifdef __STDINT_MACROS
118# define INT16_C(c) c
119# define INT_LEAST16_C(c) INT16_C(c)
120# define INT_FAST16_C(c) INT32_C(c)
121
122# define UINT16_C(c) c ## U
123# define UINT_LEAST16_C(c) UINT16_C(c)
124# define UINT_FAST16_C(c) UINT32_C(c)
125#endif
126
127/*
128 * int32_t & uint32_t
129 */
130
131typedef int32_t int_least32_t;
132typedef int32_t int_fast32_t;
133
134typedef uint32_t uint_least32_t;
135typedef uint32_t uint_fast32_t;
136
137#ifdef __STDINT_LIMITS
138# define INT32_MIN (-2147483647-1)
139# define INT32_MAX (2147483647)
140# define INT_LEAST32_MIN INT32_MIN
141# define INT_LEAST32_MAX INT32_MAX
142# define INT_FAST32_MIN INT32_MIN
143# define INT_FAST32_MAX INT32_MAX
144
145# define UINT32_MAX (4294967295U)
146# define UINT_LEAST32_MAX UINT32_MAX
147# define UINT_FAST32_MAX UINT32_MAX
148#endif
149
150#ifdef __STDINT_MACROS
151# define INT32_C(c) c
152# define INT_LEAST32_C(c) INT32_C(c)
153# define INT_FAST32_C(c) INT32_C(c)
154
155# define UINT32_C(c) c ## U
156# define UINT_LEAST32_C(c) UINT32_C(c)
157# define UINT_FAST32_C(c) UINT32_C(c)
158#endif
159
160#if !defined(__STRICT_ANSI__)
161/*
162 * int64_t
163 */
164typedef int64_t int_least64_t;
165typedef int64_t int_fast64_t;
166
167typedef uint64_t uint_least64_t;
168typedef uint64_t uint_fast64_t;
169
170
171#ifdef __STDINT_LIMITS
172# define INT64_MIN (__INT64_C(-9223372036854775807)-1)
173# define INT64_MAX (__INT64_C(9223372036854775807))
174# define INT_LEAST64_MIN INT64_MIN
175# define INT_LEAST64_MAX INT64_MAX
176# define INT_FAST64_MIN INT64_MIN
177# define INT_FAST64_MAX INT64_MAX
178# define UINT64_MAX (__UINT64_C(18446744073709551615))
179
180# define UINT_LEAST64_MAX UINT64_MAX
181# define UINT_FAST64_MAX UINT64_MAX
182#endif
183
184#ifdef __STDINT_MACROS
185# define __INT64_C(c) c ## LL
186# define INT64_C(c) __INT64_C(c)
187# define INT_LEAST64_C(c) INT64_C(c)
188# define INT_FAST64_C(c) INT64_C(c)
189
190# define __UINT64_C(c) c ## ULL
191# define UINT64_C(c) __UINT64_C(c)
192# define UINT_LEAST64_C(c) UINT64_C(c)
193# define UINT_FAST64_C(c) UINT64_C(c)
194#endif
195
196
197# define __PRI64_RANK "ll"
198# define __PRIFAST_RANK ""
199# define __PRIPTR_RANK ""
200
201#endif /* !__STRICT_ANSI__ */
202
203/*
204 * intptr_t & uintptr_t
205 */
206
207typedef int intptr_t;
208typedef unsigned int uintptr_t;
209
210# define INTPTR_MIN INT32_MIN
211# define INTPTR_MAX INT32_MAX
212# define UINTPTR_MAX UINT32_MAX
213# define INTPTR_C(c) INT32_C(c)
214# define UINTPTR_C(c) UINT32_C(c)
215# define PTRDIFF_C(c) INT32_C(c)
216# define PTRDIFF_MIN INT32_MIN
217# define PTRDIFF_MAX INT32_MAX
218
219
220/*
221 * intmax_t & uintmax_t
222 */
223
224#if !defined(__STRICT_ANSI__)
225
226typedef uint64_t uintmax_t;
227typedef int64_t intmax_t;
228
229#define INTMAX_MIN INT64_MIN
230#define INTMAX_MAX INT64_MAX
231#define UINTMAX_MAX UINT64_MAX
232
233#define INTMAX_C(c) INT64_C(c)
234#define UINTMAX_C(c) UINT64_C(c)
235
236#else /* __STRICT_ANSI__ */
237
238typedef uint32_t uintmax_t;
239typedef int32_t intmax_t;
240
241#define INTMAX_MIN INT32_MIN
242#define INTMAX_MAX INT32_MAX
243#define UINTMAX_MAX UINT32_MAX
244
245#define INTMAX_C(c) INT32_C(c)
246#define UINTMAX_C(c) UINT32_C(c)
247
248#endif /* __STRICT_ANSI__ */
249
250
251/* size_t is defined by the GCC-specific <stddef.h> */
252#ifndef _SSIZE_T_DEFINED_
253#define _SSIZE_T_DEFINED_
254typedef long int ssize_t;
255#endif
256
257#define _BITSIZE 32
258
259/* Keep the kernel from trying to define these types... */
260#define __BIT_TYPES_DEFINED__
261
262#endif /* _STDINT_H */