blob: 1f3d003d14f98cb25a21006a26c3b2ada20806fd [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 */
Elliott Hughesa9a02ac2013-09-30 14:46:47 -070028
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070029#ifndef _STDINT_H
30#define _STDINT_H
31
32#include <stddef.h>
Elliott Hughes9f87a0b2014-02-07 14:55:58 -080033
34typedef __signed char __int8_t;
35typedef unsigned char __uint8_t;
36typedef short __int16_t;
37typedef unsigned short __uint16_t;
38typedef int __int32_t;
39typedef unsigned int __uint32_t;
40#if __LP64__
41typedef long __int64_t;
42typedef unsigned long __uint64_t;
43#else
44typedef long long __int64_t;
45typedef unsigned long long __uint64_t;
46#endif
47
48#if __LP64__
49typedef long __intptr_t;
50typedef unsigned long __uintptr_t;
51#else
52typedef int __intptr_t;
53typedef unsigned int __uintptr_t;
54#endif
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070055
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070056typedef __int8_t int8_t;
57typedef __uint8_t uint8_t;
Elliott Hughese2a292d2014-01-24 16:37:04 -080058
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070059typedef __int16_t int16_t;
60typedef __uint16_t uint16_t;
Elliott Hughese2a292d2014-01-24 16:37:04 -080061
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070062typedef __int32_t int32_t;
63typedef __uint32_t uint32_t;
Elliott Hughese2a292d2014-01-24 16:37:04 -080064
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070065typedef __int64_t int64_t;
66typedef __uint64_t uint64_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070067
Elliott Hughes9f87a0b2014-02-07 14:55:58 -080068typedef __intptr_t intptr_t;
69typedef __uintptr_t uintptr_t;
70
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070071typedef int8_t int_least8_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070072typedef uint8_t uint_least8_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070073
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070074typedef int16_t int_least16_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070075typedef uint16_t uint_least16_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070076
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070077typedef int32_t int_least32_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070078typedef uint32_t uint_least32_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070079
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070080typedef int64_t int_least64_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070081typedef uint64_t uint_least64_t;
Calin Juravleda030de2014-02-20 13:40:36 +000082
83typedef int8_t int_fast8_t;
84typedef uint8_t uint_fast8_t;
85
86typedef int64_t int_fast64_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070087typedef uint64_t uint_fast64_t;
88
Calin Juravleda030de2014-02-20 13:40:36 +000089#ifdef __LP64__
90typedef int64_t int_fast16_t;
91typedef uint64_t uint_fast16_t;
92typedef int64_t int_fast32_t;
93typedef uint64_t uint_fast32_t;
94#else
95typedef int32_t int_fast16_t;
96typedef uint32_t uint_fast16_t;
97typedef int32_t int_fast32_t;
98typedef uint32_t uint_fast32_t;
99#endif
100
Elliott Hughes9f87a0b2014-02-07 14:55:58 -0800101typedef uint64_t uintmax_t;
102typedef int64_t intmax_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700103
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700104/* Keep the kernel from trying to define these types... */
105#define __BIT_TYPES_DEFINED__
106
Elliott Hughese2a292d2014-01-24 16:37:04 -0800107#define INT8_C(c) c
108#define INT_LEAST8_C(c) INT8_C(c)
109#define INT_FAST8_C(c) INT8_C(c)
110
111#define UINT8_C(c) c
112#define UINT_LEAST8_C(c) UINT8_C(c)
113#define UINT_FAST8_C(c) UINT8_C(c)
114
115#define INT16_C(c) c
116#define INT_LEAST16_C(c) INT16_C(c)
117#define INT_FAST16_C(c) INT32_C(c)
118
119#define UINT16_C(c) c
120#define UINT_LEAST16_C(c) UINT16_C(c)
121#define UINT_FAST16_C(c) UINT32_C(c)
122#define INT32_C(c) c
123#define INT_LEAST32_C(c) INT32_C(c)
124#define INT_FAST32_C(c) INT32_C(c)
125
126#define UINT32_C(c) c ## U
127#define UINT_LEAST32_C(c) UINT32_C(c)
128#define UINT_FAST32_C(c) UINT32_C(c)
129#define INT_LEAST64_C(c) INT64_C(c)
130#define INT_FAST64_C(c) INT64_C(c)
131
132#define UINT_LEAST64_C(c) UINT64_C(c)
133#define UINT_FAST64_C(c) UINT64_C(c)
134
135#define INTMAX_C(c) INT64_C(c)
136#define UINTMAX_C(c) UINT64_C(c)
137
138#ifdef __LP64__
139# define INT64_C(c) c ## L
140# define UINT64_C(c) c ## UL
141# define INTPTR_C(c) INT64_C(c)
142# define UINTPTR_C(c) UINT64_C(c)
143# define PTRDIFF_C(c) INT64_C(c)
144#else
145# define INT64_C(c) c ## LL
146# define UINT64_C(c) c ## ULL
147# define INTPTR_C(c) INT32_C(c)
148# define UINTPTR_C(c) UINT32_C(c)
149# define PTRDIFF_C(c) INT32_C(c)
150#endif
151
152#define INT8_MIN (-128)
153#define INT8_MAX (127)
154#define INT_LEAST8_MIN INT8_MIN
155#define INT_LEAST8_MAX INT8_MAX
156#define INT_FAST8_MIN INT8_MIN
157#define INT_FAST8_MAX INT8_MAX
158
159#define UINT8_MAX (255)
160#define UINT_LEAST8_MAX UINT8_MAX
161#define UINT_FAST8_MAX UINT8_MAX
162
163#define INT16_MIN (-32768)
164#define INT16_MAX (32767)
165#define INT_LEAST16_MIN INT16_MIN
166#define INT_LEAST16_MAX INT16_MAX
167#define INT_FAST16_MIN INT32_MIN
168#define INT_FAST16_MAX INT32_MAX
169
170#define UINT16_MAX (65535)
171#define UINT_LEAST16_MAX UINT16_MAX
172#define UINT_FAST16_MAX UINT32_MAX
173
174#define INT32_MIN (-2147483647-1)
175#define INT32_MAX (2147483647)
176#define INT_LEAST32_MIN INT32_MIN
177#define INT_LEAST32_MAX INT32_MAX
178#define INT_FAST32_MIN INT32_MIN
179#define INT_FAST32_MAX INT32_MAX
180
181#define UINT32_MAX (4294967295U)
182#define UINT_LEAST32_MAX UINT32_MAX
183#define UINT_FAST32_MAX UINT32_MAX
184
185#define INT64_MIN (INT64_C(-9223372036854775807)-1)
186#define INT64_MAX (INT64_C(9223372036854775807))
187#define INT_LEAST64_MIN INT64_MIN
188#define INT_LEAST64_MAX INT64_MAX
189#define INT_FAST64_MIN INT64_MIN
190#define INT_FAST64_MAX INT64_MAX
191#define UINT64_MAX (UINT64_C(18446744073709551615))
192
193#define UINT_LEAST64_MAX UINT64_MAX
194#define UINT_FAST64_MAX UINT64_MAX
195
196#define INTMAX_MIN INT64_MIN
197#define INTMAX_MAX INT64_MAX
198#define UINTMAX_MAX UINT64_MAX
199
200#define SIG_ATOMIC_MAX INT32_MAX
201#define SIG_ATOMIC_MIN INT32_MIN
202
203#ifndef WCHAR_MAX /* These might also have been defined by <wchar.h>. */
204# define WCHAR_MAX INT32_MAX
205# define WCHAR_MIN INT32_MIN
206#endif
207
208#define WINT_MAX INT32_MAX
209#define WINT_MIN INT32_MIN
210
211#ifdef __LP64__
212# define INTPTR_MIN INT64_MIN
213# define INTPTR_MAX INT64_MAX
214# define UINTPTR_MAX UINT64_MAX
215# define PTRDIFF_MIN INT64_MIN
216# define PTRDIFF_MAX INT64_MAX
217# define SIZE_MAX UINT64_MAX
218#else
219# define INTPTR_MIN INT32_MIN
220# define INTPTR_MAX INT32_MAX
221# define UINTPTR_MAX UINT32_MAX
222# define PTRDIFF_MIN INT32_MIN
223# define PTRDIFF_MAX INT32_MAX
224# define SIZE_MAX UINT32_MAX
225#endif
226
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700227#endif /* _STDINT_H */