blob: 772fe8b6033767cd03bdc96e8682f9a85e4f2bcd [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 Hughes414dd2d2024-10-16 14:48:30 +000032#include <sys/cdefs.h>
33
Elliott Hughes5704c422016-01-25 18:06:24 -080034#include <bits/wchar_limits.h>
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070035#include <stddef.h>
Elliott Hughes9f87a0b2014-02-07 14:55:58 -080036
Elliott Hughes5470c182016-07-22 11:36:17 -070037typedef signed char __int8_t;
Elliott Hughes9f87a0b2014-02-07 14:55:58 -080038typedef unsigned char __uint8_t;
39typedef short __int16_t;
40typedef unsigned short __uint16_t;
41typedef int __int32_t;
42typedef unsigned int __uint32_t;
Josh Gaob36efa42016-09-15 13:55:41 -070043#if defined(__LP64__)
Elliott Hughes9f87a0b2014-02-07 14:55:58 -080044typedef long __int64_t;
45typedef unsigned long __uint64_t;
46#else
47typedef long long __int64_t;
48typedef unsigned long long __uint64_t;
49#endif
50
Josh Gaob36efa42016-09-15 13:55:41 -070051#if defined(__LP64__)
Elliott Hughes9f87a0b2014-02-07 14:55:58 -080052typedef long __intptr_t;
53typedef unsigned long __uintptr_t;
54#else
55typedef int __intptr_t;
56typedef unsigned int __uintptr_t;
57#endif
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070058
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070059typedef __int8_t int8_t;
60typedef __uint8_t uint8_t;
Elliott Hughese2a292d2014-01-24 16:37:04 -080061
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070062typedef __int16_t int16_t;
63typedef __uint16_t uint16_t;
Elliott Hughese2a292d2014-01-24 16:37:04 -080064
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070065typedef __int32_t int32_t;
66typedef __uint32_t uint32_t;
Elliott Hughese2a292d2014-01-24 16:37:04 -080067
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070068typedef __int64_t int64_t;
69typedef __uint64_t uint64_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070070
Elliott Hughes9f87a0b2014-02-07 14:55:58 -080071typedef __intptr_t intptr_t;
72typedef __uintptr_t uintptr_t;
73
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070074typedef int8_t int_least8_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070075typedef uint8_t uint_least8_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070076
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070077typedef int16_t int_least16_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070078typedef uint16_t uint_least16_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070079
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070080typedef int32_t int_least32_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070081typedef uint32_t uint_least32_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070082
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070083typedef int64_t int_least64_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070084typedef uint64_t uint_least64_t;
Calin Juravleda030de2014-02-20 13:40:36 +000085
86typedef int8_t int_fast8_t;
87typedef uint8_t uint_fast8_t;
88
89typedef int64_t int_fast64_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070090typedef uint64_t uint_fast64_t;
91
Elliott Hughes83c07b52014-04-21 18:09:46 -070092#if defined(__LP64__)
Calin Juravleda030de2014-02-20 13:40:36 +000093typedef int64_t int_fast16_t;
94typedef uint64_t uint_fast16_t;
95typedef int64_t int_fast32_t;
96typedef uint64_t uint_fast32_t;
97#else
98typedef int32_t int_fast16_t;
99typedef uint32_t uint_fast16_t;
100typedef int32_t int_fast32_t;
101typedef uint32_t uint_fast32_t;
102#endif
103
Elliott Hughes9f87a0b2014-02-07 14:55:58 -0800104typedef uint64_t uintmax_t;
105typedef int64_t intmax_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700106
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700107/* Keep the kernel from trying to define these types... */
108#define __BIT_TYPES_DEFINED__
109
Elliott Hughese2a292d2014-01-24 16:37:04 -0800110#define INT8_C(c) c
111#define INT_LEAST8_C(c) INT8_C(c)
112#define INT_FAST8_C(c) INT8_C(c)
113
114#define UINT8_C(c) c
115#define UINT_LEAST8_C(c) UINT8_C(c)
116#define UINT_FAST8_C(c) UINT8_C(c)
117
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
123#define UINT_LEAST16_C(c) UINT16_C(c)
124#define UINT_FAST16_C(c) UINT32_C(c)
125#define INT32_C(c) c
126#define INT_LEAST32_C(c) INT32_C(c)
127#define INT_FAST32_C(c) INT32_C(c)
128
129#define UINT32_C(c) c ## U
130#define UINT_LEAST32_C(c) UINT32_C(c)
131#define UINT_FAST32_C(c) UINT32_C(c)
132#define INT_LEAST64_C(c) INT64_C(c)
133#define INT_FAST64_C(c) INT64_C(c)
134
135#define UINT_LEAST64_C(c) UINT64_C(c)
136#define UINT_FAST64_C(c) UINT64_C(c)
137
138#define INTMAX_C(c) INT64_C(c)
139#define UINTMAX_C(c) UINT64_C(c)
140
Elliott Hughes83c07b52014-04-21 18:09:46 -0700141#if defined(__LP64__)
Elliott Hughese2a292d2014-01-24 16:37:04 -0800142# define INT64_C(c) c ## L
143# define UINT64_C(c) c ## UL
144# define INTPTR_C(c) INT64_C(c)
145# define UINTPTR_C(c) UINT64_C(c)
146# define PTRDIFF_C(c) INT64_C(c)
147#else
148# define INT64_C(c) c ## LL
149# define UINT64_C(c) c ## ULL
150# define INTPTR_C(c) INT32_C(c)
151# define UINTPTR_C(c) UINT32_C(c)
152# define PTRDIFF_C(c) INT32_C(c)
153#endif
154
155#define INT8_MIN (-128)
156#define INT8_MAX (127)
157#define INT_LEAST8_MIN INT8_MIN
158#define INT_LEAST8_MAX INT8_MAX
159#define INT_FAST8_MIN INT8_MIN
160#define INT_FAST8_MAX INT8_MAX
161
162#define UINT8_MAX (255)
163#define UINT_LEAST8_MAX UINT8_MAX
164#define UINT_FAST8_MAX UINT8_MAX
165
166#define INT16_MIN (-32768)
167#define INT16_MAX (32767)
168#define INT_LEAST16_MIN INT16_MIN
169#define INT_LEAST16_MAX INT16_MAX
170#define INT_FAST16_MIN INT32_MIN
171#define INT_FAST16_MAX INT32_MAX
172
173#define UINT16_MAX (65535)
174#define UINT_LEAST16_MAX UINT16_MAX
175#define UINT_FAST16_MAX UINT32_MAX
176
177#define INT32_MIN (-2147483647-1)
178#define INT32_MAX (2147483647)
179#define INT_LEAST32_MIN INT32_MIN
180#define INT_LEAST32_MAX INT32_MAX
181#define INT_FAST32_MIN INT32_MIN
182#define INT_FAST32_MAX INT32_MAX
183
184#define UINT32_MAX (4294967295U)
185#define UINT_LEAST32_MAX UINT32_MAX
186#define UINT_FAST32_MAX UINT32_MAX
187
188#define INT64_MIN (INT64_C(-9223372036854775807)-1)
189#define INT64_MAX (INT64_C(9223372036854775807))
190#define INT_LEAST64_MIN INT64_MIN
191#define INT_LEAST64_MAX INT64_MAX
192#define INT_FAST64_MIN INT64_MIN
193#define INT_FAST64_MAX INT64_MAX
194#define UINT64_MAX (UINT64_C(18446744073709551615))
195
196#define UINT_LEAST64_MAX UINT64_MAX
197#define UINT_FAST64_MAX UINT64_MAX
198
199#define INTMAX_MIN INT64_MIN
200#define INTMAX_MAX INT64_MAX
201#define UINTMAX_MAX UINT64_MAX
202
203#define SIG_ATOMIC_MAX INT32_MAX
204#define SIG_ATOMIC_MIN INT32_MIN
205
Elliott Hughes83c07b52014-04-21 18:09:46 -0700206#if defined(__WINT_UNSIGNED__)
207# define WINT_MAX UINT32_MAX
Dan Albertee7f1b52014-07-21 17:16:30 -0700208# define WINT_MIN 0
Elliott Hughes83c07b52014-04-21 18:09:46 -0700209#else
210# define WINT_MAX INT32_MAX
211# define WINT_MIN INT32_MIN
Elliott Hughese2a292d2014-01-24 16:37:04 -0800212#endif
213
Elliott Hughes83c07b52014-04-21 18:09:46 -0700214#if defined(__LP64__)
Elliott Hughese2a292d2014-01-24 16:37:04 -0800215# define INTPTR_MIN INT64_MIN
216# define INTPTR_MAX INT64_MAX
217# define UINTPTR_MAX UINT64_MAX
218# define PTRDIFF_MIN INT64_MIN
219# define PTRDIFF_MAX INT64_MAX
220# define SIZE_MAX UINT64_MAX
221#else
222# define INTPTR_MIN INT32_MIN
223# define INTPTR_MAX INT32_MAX
224# define UINTPTR_MAX UINT32_MAX
225# define PTRDIFF_MIN INT32_MIN
226# define PTRDIFF_MAX INT32_MAX
227# define SIZE_MAX UINT32_MAX
228#endif
229
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700230#endif /* _STDINT_H */