blob: 222ff1bbd27f706dcf0ada8a031dcae2cffb2c96 [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>
Elliott Hughes9248d3a2013-06-12 22:18:47 +000033#include <machine/limits.h> /* For SIZE_MAX. */
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070034
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070035#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
36# define __STDINT_LIMITS
37#endif
38
39#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
40# define __STDINT_MACROS
41#endif
42
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070043typedef __int8_t int8_t;
44typedef __uint8_t uint8_t;
45typedef __int16_t int16_t;
46typedef __uint16_t uint16_t;
47typedef __int32_t int32_t;
48typedef __uint32_t uint32_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070049typedef __int64_t int64_t;
50typedef __uint64_t uint64_t;
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070051
52/*
53 * int8_t & uint8_t
54 */
55
56typedef int8_t int_least8_t;
57typedef int8_t int_fast8_t;
58
59typedef uint8_t uint_least8_t;
60typedef uint8_t uint_fast8_t;
61
62#ifdef __STDINT_LIMITS
63# define INT8_MIN (-128)
64# define INT8_MAX (127)
65# define INT_LEAST8_MIN INT8_MIN
66# define INT_LEAST8_MAX INT8_MAX
67# define INT_FAST8_MIN INT8_MIN
68# define INT_FAST8_MAX INT8_MAX
69
70# define UINT8_MAX (255U)
71# define UINT_LEAST8_MAX UINT8_MAX
72# define UINT_FAST8_MAX UINT8_MAX
73#endif
74
75#ifdef __STDINT_MACROS
76# define INT8_C(c) c
77# define INT_LEAST8_C(c) INT8_C(c)
78# define INT_FAST8_C(c) INT8_C(c)
79
80# define UINT8_C(c) c ## U
81# define UINT_LEAST8_C(c) UINT8_C(c)
82# define UINT_FAST8_C(c) UINT8_C(c)
83#endif
84
85/*
86 * int16_t & uint16_t
87 */
88
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070089typedef int16_t int_least16_t;
90typedef int32_t int_fast16_t;
91
92typedef uint16_t uint_least16_t;
93typedef uint32_t uint_fast16_t;
94
95#ifdef __STDINT_LIMITS
96# define INT16_MIN (-32768)
97# define INT16_MAX (32767)
98# define INT_LEAST16_MIN INT16_MIN
99# define INT_LEAST16_MAX INT16_MAX
100# define INT_FAST16_MIN INT32_MIN
101# define INT_FAST16_MAX INT32_MAX
102
103# define UINT16_MAX (65535U)
104# define UINT_LEAST16_MAX UINT16_MAX
105# define UINT_FAST16_MAX UINT32_MAX
106#endif
107
108#ifdef __STDINT_MACROS
109# define INT16_C(c) c
110# define INT_LEAST16_C(c) INT16_C(c)
111# define INT_FAST16_C(c) INT32_C(c)
112
113# define UINT16_C(c) c ## U
114# define UINT_LEAST16_C(c) UINT16_C(c)
115# define UINT_FAST16_C(c) UINT32_C(c)
116#endif
117
118/*
119 * int32_t & uint32_t
120 */
121
122typedef int32_t int_least32_t;
123typedef int32_t int_fast32_t;
124
125typedef uint32_t uint_least32_t;
126typedef uint32_t uint_fast32_t;
127
128#ifdef __STDINT_LIMITS
129# define INT32_MIN (-2147483647-1)
130# define INT32_MAX (2147483647)
131# define INT_LEAST32_MIN INT32_MIN
132# define INT_LEAST32_MAX INT32_MAX
133# define INT_FAST32_MIN INT32_MIN
134# define INT_FAST32_MAX INT32_MAX
135
136# define UINT32_MAX (4294967295U)
137# define UINT_LEAST32_MAX UINT32_MAX
138# define UINT_FAST32_MAX UINT32_MAX
139#endif
140
141#ifdef __STDINT_MACROS
142# define INT32_C(c) c
143# define INT_LEAST32_C(c) INT32_C(c)
144# define INT_FAST32_C(c) INT32_C(c)
145
146# define UINT32_C(c) c ## U
147# define UINT_LEAST32_C(c) UINT32_C(c)
148# define UINT_FAST32_C(c) UINT32_C(c)
149#endif
150
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700151/*
152 * int64_t
153 */
Elliott Hughes6d6731a2012-08-17 14:30:06 -0700154
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700155typedef int64_t int_least64_t;
156typedef int64_t int_fast64_t;
157
158typedef uint64_t uint_least64_t;
159typedef uint64_t uint_fast64_t;
160
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700161#ifdef __STDINT_LIMITS
162# define INT64_MIN (__INT64_C(-9223372036854775807)-1)
163# define INT64_MAX (__INT64_C(9223372036854775807))
164# define INT_LEAST64_MIN INT64_MIN
165# define INT_LEAST64_MAX INT64_MAX
166# define INT_FAST64_MIN INT64_MIN
167# define INT_FAST64_MAX INT64_MAX
168# define UINT64_MAX (__UINT64_C(18446744073709551615))
169
170# define UINT_LEAST64_MAX UINT64_MAX
171# define UINT_FAST64_MAX UINT64_MAX
172#endif
173
David 'Digit' Turner8b3cea62011-03-11 14:39:05 +0100174#define __INT64_C(c) c ## LL
175#define __UINT64_C(c) c ## ULL
176
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700177#ifdef __STDINT_MACROS
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700178# define INT64_C(c) __INT64_C(c)
179# define INT_LEAST64_C(c) INT64_C(c)
180# define INT_FAST64_C(c) INT64_C(c)
181
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700182# define UINT64_C(c) __UINT64_C(c)
183# define UINT_LEAST64_C(c) UINT64_C(c)
184# define UINT_FAST64_C(c) UINT64_C(c)
185#endif
186
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700187# define __PRI64_RANK "ll"
188# define __PRIFAST_RANK ""
189# define __PRIPTR_RANK ""
190
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700191/*
192 * intptr_t & uintptr_t
193 */
194
195typedef int intptr_t;
196typedef unsigned int uintptr_t;
197
David 'Digit' Turner08ff1a62011-03-10 18:02:01 +0100198#ifdef __STDINT_LIMITS
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700199# define INTPTR_MIN INT32_MIN
200# define INTPTR_MAX INT32_MAX
201# define UINTPTR_MAX UINT32_MAX
David 'Digit' Turner08ff1a62011-03-10 18:02:01 +0100202# define PTRDIFF_MIN INT32_MIN
203# define PTRDIFF_MAX INT32_MAX
204#endif
205
206#ifdef __STDINT_MACROS
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700207# define INTPTR_C(c) INT32_C(c)
208# define UINTPTR_C(c) UINT32_C(c)
209# define PTRDIFF_C(c) INT32_C(c)
David 'Digit' Turner08ff1a62011-03-10 18:02:01 +0100210#endif
211
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700212/*
213 * intmax_t & uintmax_t
214 */
215
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700216typedef uint64_t uintmax_t;
217typedef int64_t intmax_t;
218
David 'Digit' Turner08ff1a62011-03-10 18:02:01 +0100219#ifdef __STDINT_LIMITS
220# define INTMAX_MIN INT64_MIN
221# define INTMAX_MAX INT64_MAX
222# define UINTMAX_MAX UINT64_MAX
223#endif
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700224
David 'Digit' Turner0e5411b2011-03-10 20:34:23 +0100225#ifdef __STDINT_MACROS
David 'Digit' Turner08ff1a62011-03-10 18:02:01 +0100226# define INTMAX_C(c) INT64_C(c)
227# define UINTMAX_C(c) UINT64_C(c)
228#endif
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700229
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700230#define _BITSIZE 32
231
232/* Keep the kernel from trying to define these types... */
233#define __BIT_TYPES_DEFINED__
234
235#endif /* _STDINT_H */