blob: 1cedca1a324457174b78ad494392059cb89d1531 [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
Elliott Hughes5704c422016-01-25 18:06:24 -080032#include <bits/wchar_limits.h>
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070033#include <stddef.h>
Elliott Hughes203e13d2016-07-22 14:56:18 -070034#include <sys/cdefs.h>
Elliott Hughes9f87a0b2014-02-07 14:55:58 -080035
Elliott Hughes5470c182016-07-22 11:36:17 -070036typedef signed char __int8_t;
Elliott Hughes9f87a0b2014-02-07 14:55:58 -080037typedef unsigned char __uint8_t;
38typedef short __int16_t;
39typedef unsigned short __uint16_t;
40typedef int __int32_t;
41typedef unsigned int __uint32_t;
42#if __LP64__
43typedef long __int64_t;
44typedef unsigned long __uint64_t;
45#else
46typedef long long __int64_t;
47typedef unsigned long long __uint64_t;
48#endif
49
50#if __LP64__
51typedef long __intptr_t;
52typedef unsigned long __uintptr_t;
53#else
54typedef int __intptr_t;
55typedef unsigned int __uintptr_t;
56#endif
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070057
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070058typedef __int8_t int8_t;
59typedef __uint8_t uint8_t;
Elliott Hughese2a292d2014-01-24 16:37:04 -080060
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070061typedef __int16_t int16_t;
62typedef __uint16_t uint16_t;
Elliott Hughese2a292d2014-01-24 16:37:04 -080063
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070064typedef __int32_t int32_t;
65typedef __uint32_t uint32_t;
Elliott Hughese2a292d2014-01-24 16:37:04 -080066
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070067typedef __int64_t int64_t;
68typedef __uint64_t uint64_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070069
Elliott Hughes9f87a0b2014-02-07 14:55:58 -080070typedef __intptr_t intptr_t;
71typedef __uintptr_t uintptr_t;
72
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070073typedef int8_t int_least8_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070074typedef uint8_t uint_least8_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070075
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070076typedef int16_t int_least16_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070077typedef uint16_t uint_least16_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070078
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070079typedef int32_t int_least32_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070080typedef uint32_t uint_least32_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070081
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070082typedef int64_t int_least64_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070083typedef uint64_t uint_least64_t;
Calin Juravleda030de2014-02-20 13:40:36 +000084
85typedef int8_t int_fast8_t;
86typedef uint8_t uint_fast8_t;
87
88typedef int64_t int_fast64_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070089typedef uint64_t uint_fast64_t;
90
Elliott Hughes83c07b52014-04-21 18:09:46 -070091#if defined(__LP64__)
Calin Juravleda030de2014-02-20 13:40:36 +000092typedef int64_t int_fast16_t;
93typedef uint64_t uint_fast16_t;
94typedef int64_t int_fast32_t;
95typedef uint64_t uint_fast32_t;
96#else
97typedef int32_t int_fast16_t;
98typedef uint32_t uint_fast16_t;
99typedef int32_t int_fast32_t;
100typedef uint32_t uint_fast32_t;
101#endif
102
Elliott Hughes9f87a0b2014-02-07 14:55:58 -0800103typedef uint64_t uintmax_t;
104typedef int64_t intmax_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700105
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700106/* Keep the kernel from trying to define these types... */
107#define __BIT_TYPES_DEFINED__
108
Elliott Hughese2a292d2014-01-24 16:37:04 -0800109#define INT8_C(c) c
110#define INT_LEAST8_C(c) INT8_C(c)
111#define INT_FAST8_C(c) INT8_C(c)
112
113#define UINT8_C(c) c
114#define UINT_LEAST8_C(c) UINT8_C(c)
115#define UINT_FAST8_C(c) UINT8_C(c)
116
117#define INT16_C(c) c
118#define INT_LEAST16_C(c) INT16_C(c)
119#define INT_FAST16_C(c) INT32_C(c)
120
121#define UINT16_C(c) c
122#define UINT_LEAST16_C(c) UINT16_C(c)
123#define UINT_FAST16_C(c) UINT32_C(c)
124#define INT32_C(c) c
125#define INT_LEAST32_C(c) INT32_C(c)
126#define INT_FAST32_C(c) INT32_C(c)
127
128#define UINT32_C(c) c ## U
129#define UINT_LEAST32_C(c) UINT32_C(c)
130#define UINT_FAST32_C(c) UINT32_C(c)
131#define INT_LEAST64_C(c) INT64_C(c)
132#define INT_FAST64_C(c) INT64_C(c)
133
134#define UINT_LEAST64_C(c) UINT64_C(c)
135#define UINT_FAST64_C(c) UINT64_C(c)
136
137#define INTMAX_C(c) INT64_C(c)
138#define UINTMAX_C(c) UINT64_C(c)
139
Elliott Hughes83c07b52014-04-21 18:09:46 -0700140#if defined(__LP64__)
Elliott Hughese2a292d2014-01-24 16:37:04 -0800141# define INT64_C(c) c ## L
142# define UINT64_C(c) c ## UL
143# define INTPTR_C(c) INT64_C(c)
144# define UINTPTR_C(c) UINT64_C(c)
145# define PTRDIFF_C(c) INT64_C(c)
146#else
147# define INT64_C(c) c ## LL
148# define UINT64_C(c) c ## ULL
149# define INTPTR_C(c) INT32_C(c)
150# define UINTPTR_C(c) UINT32_C(c)
151# define PTRDIFF_C(c) INT32_C(c)
152#endif
153
154#define INT8_MIN (-128)
155#define INT8_MAX (127)
156#define INT_LEAST8_MIN INT8_MIN
157#define INT_LEAST8_MAX INT8_MAX
158#define INT_FAST8_MIN INT8_MIN
159#define INT_FAST8_MAX INT8_MAX
160
161#define UINT8_MAX (255)
162#define UINT_LEAST8_MAX UINT8_MAX
163#define UINT_FAST8_MAX UINT8_MAX
164
165#define INT16_MIN (-32768)
166#define INT16_MAX (32767)
167#define INT_LEAST16_MIN INT16_MIN
168#define INT_LEAST16_MAX INT16_MAX
169#define INT_FAST16_MIN INT32_MIN
170#define INT_FAST16_MAX INT32_MAX
171
172#define UINT16_MAX (65535)
173#define UINT_LEAST16_MAX UINT16_MAX
174#define UINT_FAST16_MAX UINT32_MAX
175
176#define INT32_MIN (-2147483647-1)
177#define INT32_MAX (2147483647)
178#define INT_LEAST32_MIN INT32_MIN
179#define INT_LEAST32_MAX INT32_MAX
180#define INT_FAST32_MIN INT32_MIN
181#define INT_FAST32_MAX INT32_MAX
182
183#define UINT32_MAX (4294967295U)
184#define UINT_LEAST32_MAX UINT32_MAX
185#define UINT_FAST32_MAX UINT32_MAX
186
187#define INT64_MIN (INT64_C(-9223372036854775807)-1)
188#define INT64_MAX (INT64_C(9223372036854775807))
189#define INT_LEAST64_MIN INT64_MIN
190#define INT_LEAST64_MAX INT64_MAX
191#define INT_FAST64_MIN INT64_MIN
192#define INT_FAST64_MAX INT64_MAX
193#define UINT64_MAX (UINT64_C(18446744073709551615))
194
195#define UINT_LEAST64_MAX UINT64_MAX
196#define UINT_FAST64_MAX UINT64_MAX
197
198#define INTMAX_MIN INT64_MIN
199#define INTMAX_MAX INT64_MAX
200#define UINTMAX_MAX UINT64_MAX
201
202#define SIG_ATOMIC_MAX INT32_MAX
203#define SIG_ATOMIC_MIN INT32_MIN
204
Elliott Hughes83c07b52014-04-21 18:09:46 -0700205#if defined(__WINT_UNSIGNED__)
206# define WINT_MAX UINT32_MAX
Dan Albertee7f1b52014-07-21 17:16:30 -0700207# define WINT_MIN 0
Elliott Hughes83c07b52014-04-21 18:09:46 -0700208#else
209# define WINT_MAX INT32_MAX
210# define WINT_MIN INT32_MIN
Elliott Hughese2a292d2014-01-24 16:37:04 -0800211#endif
212
Elliott Hughes83c07b52014-04-21 18:09:46 -0700213#if defined(__LP64__)
Elliott Hughese2a292d2014-01-24 16:37:04 -0800214# define INTPTR_MIN INT64_MIN
215# define INTPTR_MAX INT64_MAX
216# define UINTPTR_MAX UINT64_MAX
217# define PTRDIFF_MIN INT64_MIN
218# define PTRDIFF_MAX INT64_MAX
219# define SIZE_MAX UINT64_MAX
220#else
221# define INTPTR_MIN INT32_MIN
222# define INTPTR_MAX INT32_MAX
223# define UINTPTR_MAX UINT32_MAX
224# define PTRDIFF_MIN INT32_MIN
225# define PTRDIFF_MAX INT32_MAX
226# define SIZE_MAX UINT32_MAX
227#endif
228
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700229#endif /* _STDINT_H */