blob: be49485f42a48b61430e53585cfd03cad0779cc6 [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>
33#include <sys/_types.h>
34
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070035typedef __int8_t int8_t;
36typedef __uint8_t uint8_t;
Elliott Hughese2a292d2014-01-24 16:37:04 -080037
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070038typedef __int16_t int16_t;
39typedef __uint16_t uint16_t;
Elliott Hughese2a292d2014-01-24 16:37:04 -080040
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070041typedef __int32_t int32_t;
42typedef __uint32_t uint32_t;
Elliott Hughese2a292d2014-01-24 16:37:04 -080043
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070044typedef __int64_t int64_t;
45typedef __uint64_t uint64_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070046
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070047typedef int8_t int_least8_t;
48typedef int8_t int_fast8_t;
49
50typedef uint8_t uint_least8_t;
51typedef uint8_t uint_fast8_t;
52
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070053typedef int16_t int_least16_t;
54typedef int32_t int_fast16_t;
55
56typedef uint16_t uint_least16_t;
57typedef uint32_t uint_fast16_t;
58
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070059typedef int32_t int_least32_t;
60typedef int32_t int_fast32_t;
61
62typedef uint32_t uint_least32_t;
63typedef uint32_t uint_fast32_t;
64
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070065typedef int64_t int_least64_t;
66typedef int64_t int_fast64_t;
67
68typedef uint64_t uint_least64_t;
69typedef uint64_t uint_fast64_t;
70
Pavel Chupin0a9c6152012-12-18 17:25:01 +040071#ifdef __LP64__
Elliott Hughese2a292d2014-01-24 16:37:04 -080072typedef long intptr_t;
73typedef unsigned long uintptr_t;
Pavel Chupin0a9c6152012-12-18 17:25:01 +040074#else
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070075typedef int intptr_t;
76typedef unsigned int uintptr_t;
David 'Digit' Turner08ff1a62011-03-10 18:02:01 +010077#endif
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070078
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070079typedef uint64_t uintmax_t;
80typedef int64_t intmax_t;
81
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070082/* Keep the kernel from trying to define these types... */
83#define __BIT_TYPES_DEFINED__
84
Elliott Hughese2a292d2014-01-24 16:37:04 -080085#define INT8_C(c) c
86#define INT_LEAST8_C(c) INT8_C(c)
87#define INT_FAST8_C(c) INT8_C(c)
88
89#define UINT8_C(c) c
90#define UINT_LEAST8_C(c) UINT8_C(c)
91#define UINT_FAST8_C(c) UINT8_C(c)
92
93#define INT16_C(c) c
94#define INT_LEAST16_C(c) INT16_C(c)
95#define INT_FAST16_C(c) INT32_C(c)
96
97#define UINT16_C(c) c
98#define UINT_LEAST16_C(c) UINT16_C(c)
99#define UINT_FAST16_C(c) UINT32_C(c)
100#define INT32_C(c) c
101#define INT_LEAST32_C(c) INT32_C(c)
102#define INT_FAST32_C(c) INT32_C(c)
103
104#define UINT32_C(c) c ## U
105#define UINT_LEAST32_C(c) UINT32_C(c)
106#define UINT_FAST32_C(c) UINT32_C(c)
107#define INT_LEAST64_C(c) INT64_C(c)
108#define INT_FAST64_C(c) INT64_C(c)
109
110#define UINT_LEAST64_C(c) UINT64_C(c)
111#define UINT_FAST64_C(c) UINT64_C(c)
112
113#define INTMAX_C(c) INT64_C(c)
114#define UINTMAX_C(c) UINT64_C(c)
115
116#ifdef __LP64__
117# define INT64_C(c) c ## L
118# define UINT64_C(c) c ## UL
119# define INTPTR_C(c) INT64_C(c)
120# define UINTPTR_C(c) UINT64_C(c)
121# define PTRDIFF_C(c) INT64_C(c)
122#else
123# define INT64_C(c) c ## LL
124# define UINT64_C(c) c ## ULL
125# define INTPTR_C(c) INT32_C(c)
126# define UINTPTR_C(c) UINT32_C(c)
127# define PTRDIFF_C(c) INT32_C(c)
128#endif
129
130#define INT8_MIN (-128)
131#define INT8_MAX (127)
132#define INT_LEAST8_MIN INT8_MIN
133#define INT_LEAST8_MAX INT8_MAX
134#define INT_FAST8_MIN INT8_MIN
135#define INT_FAST8_MAX INT8_MAX
136
137#define UINT8_MAX (255)
138#define UINT_LEAST8_MAX UINT8_MAX
139#define UINT_FAST8_MAX UINT8_MAX
140
141#define INT16_MIN (-32768)
142#define INT16_MAX (32767)
143#define INT_LEAST16_MIN INT16_MIN
144#define INT_LEAST16_MAX INT16_MAX
145#define INT_FAST16_MIN INT32_MIN
146#define INT_FAST16_MAX INT32_MAX
147
148#define UINT16_MAX (65535)
149#define UINT_LEAST16_MAX UINT16_MAX
150#define UINT_FAST16_MAX UINT32_MAX
151
152#define INT32_MIN (-2147483647-1)
153#define INT32_MAX (2147483647)
154#define INT_LEAST32_MIN INT32_MIN
155#define INT_LEAST32_MAX INT32_MAX
156#define INT_FAST32_MIN INT32_MIN
157#define INT_FAST32_MAX INT32_MAX
158
159#define UINT32_MAX (4294967295U)
160#define UINT_LEAST32_MAX UINT32_MAX
161#define UINT_FAST32_MAX UINT32_MAX
162
163#define INT64_MIN (INT64_C(-9223372036854775807)-1)
164#define INT64_MAX (INT64_C(9223372036854775807))
165#define INT_LEAST64_MIN INT64_MIN
166#define INT_LEAST64_MAX INT64_MAX
167#define INT_FAST64_MIN INT64_MIN
168#define INT_FAST64_MAX INT64_MAX
169#define UINT64_MAX (UINT64_C(18446744073709551615))
170
171#define UINT_LEAST64_MAX UINT64_MAX
172#define UINT_FAST64_MAX UINT64_MAX
173
174#define INTMAX_MIN INT64_MIN
175#define INTMAX_MAX INT64_MAX
176#define UINTMAX_MAX UINT64_MAX
177
178#define SIG_ATOMIC_MAX INT32_MAX
179#define SIG_ATOMIC_MIN INT32_MIN
180
181#ifndef WCHAR_MAX /* These might also have been defined by <wchar.h>. */
182# define WCHAR_MAX INT32_MAX
183# define WCHAR_MIN INT32_MIN
184#endif
185
186#define WINT_MAX INT32_MAX
187#define WINT_MIN INT32_MIN
188
189#ifdef __LP64__
190# define INTPTR_MIN INT64_MIN
191# define INTPTR_MAX INT64_MAX
192# define UINTPTR_MAX UINT64_MAX
193# define PTRDIFF_MIN INT64_MIN
194# define PTRDIFF_MAX INT64_MAX
195# define SIZE_MAX UINT64_MAX
196#else
197# define INTPTR_MIN INT32_MIN
198# define INTPTR_MAX INT32_MAX
199# define UINTPTR_MAX UINT32_MAX
200# define PTRDIFF_MIN INT32_MIN
201# define PTRDIFF_MAX INT32_MAX
202# define SIZE_MAX UINT32_MAX
203#endif
204
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700205#endif /* _STDINT_H */