The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame^] | 1 | /* |
| 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> |
| 33 | |
| 34 | |
| 35 | |
| 36 | #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) |
| 37 | # define __STDINT_LIMITS |
| 38 | #endif |
| 39 | |
| 40 | #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) |
| 41 | # define __STDINT_MACROS |
| 42 | #endif |
| 43 | |
| 44 | typedef __int8_t int8_t; |
| 45 | typedef __uint8_t uint8_t; |
| 46 | typedef __int16_t int16_t; |
| 47 | typedef __uint16_t uint16_t; |
| 48 | typedef __int32_t int32_t; |
| 49 | typedef __uint32_t uint32_t; |
| 50 | #if !defined(__STRICT_ANSI__) |
| 51 | typedef __int64_t int64_t; |
| 52 | typedef __uint64_t uint64_t; |
| 53 | #endif |
| 54 | |
| 55 | /* |
| 56 | * int8_t & uint8_t |
| 57 | */ |
| 58 | |
| 59 | typedef int8_t int_least8_t; |
| 60 | typedef int8_t int_fast8_t; |
| 61 | |
| 62 | typedef uint8_t uint_least8_t; |
| 63 | typedef uint8_t uint_fast8_t; |
| 64 | |
| 65 | #ifdef __STDINT_LIMITS |
| 66 | # define INT8_MIN (-128) |
| 67 | # define INT8_MAX (127) |
| 68 | # define INT_LEAST8_MIN INT8_MIN |
| 69 | # define INT_LEAST8_MAX INT8_MAX |
| 70 | # define INT_FAST8_MIN INT8_MIN |
| 71 | # define INT_FAST8_MAX INT8_MAX |
| 72 | |
| 73 | # define UINT8_MAX (255U) |
| 74 | # define UINT_LEAST8_MAX UINT8_MAX |
| 75 | # define UINT_FAST8_MAX UINT8_MAX |
| 76 | #endif |
| 77 | |
| 78 | #ifdef __STDINT_MACROS |
| 79 | # define INT8_C(c) c |
| 80 | # define INT_LEAST8_C(c) INT8_C(c) |
| 81 | # define INT_FAST8_C(c) INT8_C(c) |
| 82 | |
| 83 | # define UINT8_C(c) c ## U |
| 84 | # define UINT_LEAST8_C(c) UINT8_C(c) |
| 85 | # define UINT_FAST8_C(c) UINT8_C(c) |
| 86 | #endif |
| 87 | |
| 88 | /* |
| 89 | * int16_t & uint16_t |
| 90 | */ |
| 91 | |
| 92 | |
| 93 | typedef int16_t int_least16_t; |
| 94 | typedef int32_t int_fast16_t; |
| 95 | |
| 96 | typedef uint16_t uint_least16_t; |
| 97 | typedef uint32_t uint_fast16_t; |
| 98 | |
| 99 | #ifdef __STDINT_LIMITS |
| 100 | # define INT16_MIN (-32768) |
| 101 | # define INT16_MAX (32767) |
| 102 | # define INT_LEAST16_MIN INT16_MIN |
| 103 | # define INT_LEAST16_MAX INT16_MAX |
| 104 | # define INT_FAST16_MIN INT32_MIN |
| 105 | # define INT_FAST16_MAX INT32_MAX |
| 106 | |
| 107 | # define UINT16_MAX (65535U) |
| 108 | # define UINT_LEAST16_MAX UINT16_MAX |
| 109 | # define UINT_FAST16_MAX UINT32_MAX |
| 110 | #endif |
| 111 | |
| 112 | #ifdef __STDINT_MACROS |
| 113 | # define INT16_C(c) c |
| 114 | # define INT_LEAST16_C(c) INT16_C(c) |
| 115 | # define INT_FAST16_C(c) INT32_C(c) |
| 116 | |
| 117 | # define UINT16_C(c) c ## U |
| 118 | # define UINT_LEAST16_C(c) UINT16_C(c) |
| 119 | # define UINT_FAST16_C(c) UINT32_C(c) |
| 120 | #endif |
| 121 | |
| 122 | /* |
| 123 | * int32_t & uint32_t |
| 124 | */ |
| 125 | |
| 126 | typedef int32_t int_least32_t; |
| 127 | typedef int32_t int_fast32_t; |
| 128 | |
| 129 | typedef uint32_t uint_least32_t; |
| 130 | typedef uint32_t uint_fast32_t; |
| 131 | |
| 132 | #ifdef __STDINT_LIMITS |
| 133 | # define INT32_MIN (-2147483647-1) |
| 134 | # define INT32_MAX (2147483647) |
| 135 | # define INT_LEAST32_MIN INT32_MIN |
| 136 | # define INT_LEAST32_MAX INT32_MAX |
| 137 | # define INT_FAST32_MIN INT32_MIN |
| 138 | # define INT_FAST32_MAX INT32_MAX |
| 139 | |
| 140 | # define UINT32_MAX (4294967295U) |
| 141 | # define UINT_LEAST32_MAX UINT32_MAX |
| 142 | # define UINT_FAST32_MAX UINT32_MAX |
| 143 | #endif |
| 144 | |
| 145 | #ifdef __STDINT_MACROS |
| 146 | # define INT32_C(c) c |
| 147 | # define INT_LEAST32_C(c) INT32_C(c) |
| 148 | # define INT_FAST32_C(c) INT32_C(c) |
| 149 | |
| 150 | # define UINT32_C(c) c ## U |
| 151 | # define UINT_LEAST32_C(c) UINT32_C(c) |
| 152 | # define UINT_FAST32_C(c) UINT32_C(c) |
| 153 | #endif |
| 154 | |
| 155 | #if !defined(__STRICT_ANSI__) |
| 156 | /* |
| 157 | * int64_t |
| 158 | */ |
| 159 | typedef int64_t int_least64_t; |
| 160 | typedef int64_t int_fast64_t; |
| 161 | |
| 162 | typedef uint64_t uint_least64_t; |
| 163 | typedef uint64_t uint_fast64_t; |
| 164 | |
| 165 | |
| 166 | #ifdef __STDINT_LIMITS |
| 167 | # define INT64_MIN (__INT64_C(-9223372036854775807)-1) |
| 168 | # define INT64_MAX (__INT64_C(9223372036854775807)) |
| 169 | # define INT_LEAST64_MIN INT64_MIN |
| 170 | # define INT_LEAST64_MAX INT64_MAX |
| 171 | # define INT_FAST64_MIN INT64_MIN |
| 172 | # define INT_FAST64_MAX INT64_MAX |
| 173 | # define UINT64_MAX (__UINT64_C(18446744073709551615)) |
| 174 | |
| 175 | # define UINT_LEAST64_MAX UINT64_MAX |
| 176 | # define UINT_FAST64_MAX UINT64_MAX |
| 177 | #endif |
| 178 | |
| 179 | #ifdef __STDINT_MACROS |
| 180 | # define __INT64_C(c) c ## LL |
| 181 | # define INT64_C(c) __INT64_C(c) |
| 182 | # define INT_LEAST64_C(c) INT64_C(c) |
| 183 | # define INT_FAST64_C(c) INT64_C(c) |
| 184 | |
| 185 | # define __UINT64_C(c) c ## ULL |
| 186 | # define UINT64_C(c) __UINT64_C(c) |
| 187 | # define UINT_LEAST64_C(c) UINT64_C(c) |
| 188 | # define UINT_FAST64_C(c) UINT64_C(c) |
| 189 | #endif |
| 190 | |
| 191 | |
| 192 | # define __PRI64_RANK "ll" |
| 193 | # define __PRIFAST_RANK "" |
| 194 | # define __PRIPTR_RANK "" |
| 195 | |
| 196 | #endif /* !__STRICT_ANSI__ */ |
| 197 | |
| 198 | /* |
| 199 | * intptr_t & uintptr_t |
| 200 | */ |
| 201 | |
| 202 | typedef int intptr_t; |
| 203 | typedef unsigned int uintptr_t; |
| 204 | |
| 205 | # define INTPTR_MIN INT32_MIN |
| 206 | # define INTPTR_MAX INT32_MAX |
| 207 | # define UINTPTR_MAX UINT32_MAX |
| 208 | # define INTPTR_C(c) INT32_C(c) |
| 209 | # define UINTPTR_C(c) UINT32_C(c) |
| 210 | # define PTRDIFF_C(c) INT32_C(c) |
| 211 | # define PTRDIFF_MIN INT32_MIN |
| 212 | # define PTRDIFF_MAX INT32_MAX |
| 213 | |
| 214 | |
| 215 | /* |
| 216 | * intmax_t & uintmax_t |
| 217 | */ |
| 218 | |
| 219 | #if !defined(__STRICT_ANSI__) |
| 220 | |
| 221 | typedef uint64_t uintmax_t; |
| 222 | typedef int64_t intmax_t; |
| 223 | |
| 224 | #define INTMAX_MIN INT64_MIN |
| 225 | #define INTMAX_MAX INT64_MAX |
| 226 | #define UINTMAX_MAX UINT64_MAX |
| 227 | |
| 228 | #define INTMAX_C(c) INT64_C(c) |
| 229 | #define UINTMAX_C(c) UINT64_C(c) |
| 230 | |
| 231 | #else /* __STRICT_ANSI__ */ |
| 232 | |
| 233 | typedef uint32_t uintmax_t; |
| 234 | typedef int32_t intmax_t; |
| 235 | |
| 236 | #define INTMAX_MIN INT32_MIN |
| 237 | #define INTMAX_MAX INT32_MAX |
| 238 | #define UINTMAX_MAX UINT32_MAX |
| 239 | |
| 240 | #define INTMAX_C(c) INT32_C(c) |
| 241 | #define UINTMAX_C(c) UINT32_C(c) |
| 242 | |
| 243 | #endif /* __STRICT_ANSI__ */ |
| 244 | |
| 245 | |
| 246 | /* size_t is defined by the GCC-specific <stddef.h> */ |
| 247 | #ifndef _SSIZE_T_DEFINED_ |
| 248 | #define _SSIZE_T_DEFINED_ |
| 249 | typedef long int ssize_t; |
| 250 | #endif |
| 251 | |
| 252 | #define _BITSIZE 32 |
| 253 | |
| 254 | /* Keep the kernel from trying to define these types... */ |
| 255 | #define __BIT_TYPES_DEFINED__ |
| 256 | |
| 257 | #endif /* _STDINT_H */ |