| 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 |  */ | 
| Elliott Hughes | a9a02ac | 2013-09-30 14:46:47 -0700 | [diff] [blame] | 28 |  | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 29 | #ifndef _STDINT_H | 
 | 30 | #define _STDINT_H | 
 | 31 |  | 
| Elliott Hughes | 5704c42 | 2016-01-25 18:06:24 -0800 | [diff] [blame] | 32 | #include <bits/wchar_limits.h> | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 33 | #include <stddef.h> | 
| Elliott Hughes | 203e13d | 2016-07-22 14:56:18 -0700 | [diff] [blame] | 34 | #include <sys/cdefs.h> | 
| Elliott Hughes | 9f87a0b | 2014-02-07 14:55:58 -0800 | [diff] [blame] | 35 |  | 
| Elliott Hughes | 5470c18 | 2016-07-22 11:36:17 -0700 | [diff] [blame] | 36 | typedef signed char __int8_t; | 
| Elliott Hughes | 9f87a0b | 2014-02-07 14:55:58 -0800 | [diff] [blame] | 37 | typedef unsigned char __uint8_t; | 
 | 38 | typedef short __int16_t; | 
 | 39 | typedef unsigned short __uint16_t; | 
 | 40 | typedef int __int32_t; | 
 | 41 | typedef unsigned int __uint32_t; | 
| Josh Gao | b36efa4 | 2016-09-15 13:55:41 -0700 | [diff] [blame] | 42 | #if defined(__LP64__) | 
| Elliott Hughes | 9f87a0b | 2014-02-07 14:55:58 -0800 | [diff] [blame] | 43 | typedef long __int64_t; | 
 | 44 | typedef unsigned long __uint64_t; | 
 | 45 | #else | 
 | 46 | typedef long long __int64_t; | 
 | 47 | typedef unsigned long long __uint64_t; | 
 | 48 | #endif | 
 | 49 |  | 
| Josh Gao | b36efa4 | 2016-09-15 13:55:41 -0700 | [diff] [blame] | 50 | #if defined(__LP64__) | 
| Elliott Hughes | 9f87a0b | 2014-02-07 14:55:58 -0800 | [diff] [blame] | 51 | typedef long __intptr_t; | 
 | 52 | typedef unsigned long __uintptr_t; | 
 | 53 | #else | 
 | 54 | typedef int __intptr_t; | 
 | 55 | typedef unsigned int __uintptr_t; | 
 | 56 | #endif | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 57 |  | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 58 | typedef __int8_t      int8_t; | 
 | 59 | typedef __uint8_t     uint8_t; | 
| Elliott Hughes | e2a292d | 2014-01-24 16:37:04 -0800 | [diff] [blame] | 60 |  | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 61 | typedef __int16_t     int16_t; | 
 | 62 | typedef __uint16_t    uint16_t; | 
| Elliott Hughes | e2a292d | 2014-01-24 16:37:04 -0800 | [diff] [blame] | 63 |  | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 64 | typedef __int32_t     int32_t; | 
 | 65 | typedef __uint32_t    uint32_t; | 
| Elliott Hughes | e2a292d | 2014-01-24 16:37:04 -0800 | [diff] [blame] | 66 |  | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 67 | typedef __int64_t     int64_t; | 
 | 68 | typedef __uint64_t    uint64_t; | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 69 |  | 
| Elliott Hughes | 9f87a0b | 2014-02-07 14:55:58 -0800 | [diff] [blame] | 70 | typedef __intptr_t    intptr_t; | 
 | 71 | typedef __uintptr_t   uintptr_t; | 
 | 72 |  | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 73 | typedef int8_t        int_least8_t; | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 74 | typedef uint8_t       uint_least8_t; | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 75 |  | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 76 | typedef int16_t       int_least16_t; | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 77 | typedef uint16_t      uint_least16_t; | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 78 |  | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 79 | typedef int32_t       int_least32_t; | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 80 | typedef uint32_t      uint_least32_t; | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 81 |  | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 82 | typedef int64_t       int_least64_t; | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 83 | typedef uint64_t      uint_least64_t; | 
| Calin Juravle | da030de | 2014-02-20 13:40:36 +0000 | [diff] [blame] | 84 |  | 
 | 85 | typedef int8_t        int_fast8_t; | 
 | 86 | typedef uint8_t       uint_fast8_t; | 
 | 87 |  | 
 | 88 | typedef int64_t       int_fast64_t; | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 89 | typedef uint64_t      uint_fast64_t; | 
 | 90 |  | 
| Elliott Hughes | 83c07b5 | 2014-04-21 18:09:46 -0700 | [diff] [blame] | 91 | #if defined(__LP64__) | 
| Calin Juravle | da030de | 2014-02-20 13:40:36 +0000 | [diff] [blame] | 92 | typedef int64_t       int_fast16_t; | 
 | 93 | typedef uint64_t      uint_fast16_t; | 
 | 94 | typedef int64_t       int_fast32_t; | 
 | 95 | typedef uint64_t      uint_fast32_t; | 
 | 96 | #else | 
 | 97 | typedef int32_t       int_fast16_t; | 
 | 98 | typedef uint32_t      uint_fast16_t; | 
 | 99 | typedef int32_t       int_fast32_t; | 
 | 100 | typedef uint32_t      uint_fast32_t; | 
 | 101 | #endif | 
 | 102 |  | 
| Elliott Hughes | 9f87a0b | 2014-02-07 14:55:58 -0800 | [diff] [blame] | 103 | typedef uint64_t      uintmax_t; | 
 | 104 | typedef int64_t       intmax_t; | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 105 |  | 
| The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 106 | /* Keep the kernel from trying to define these types... */ | 
 | 107 | #define __BIT_TYPES_DEFINED__ | 
 | 108 |  | 
| Elliott Hughes | e2a292d | 2014-01-24 16:37:04 -0800 | [diff] [blame] | 109 | #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 Hughes | 83c07b5 | 2014-04-21 18:09:46 -0700 | [diff] [blame] | 140 | #if defined(__LP64__) | 
| Elliott Hughes | e2a292d | 2014-01-24 16:37:04 -0800 | [diff] [blame] | 141 | #  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 Hughes | 83c07b5 | 2014-04-21 18:09:46 -0700 | [diff] [blame] | 205 | #if defined(__WINT_UNSIGNED__) | 
 | 206 | #  define WINT_MAX       UINT32_MAX | 
| Dan Albert | ee7f1b5 | 2014-07-21 17:16:30 -0700 | [diff] [blame] | 207 | #  define WINT_MIN       0 | 
| Elliott Hughes | 83c07b5 | 2014-04-21 18:09:46 -0700 | [diff] [blame] | 208 | #else | 
 | 209 | #  define WINT_MAX       INT32_MAX | 
 | 210 | #  define WINT_MIN       INT32_MIN | 
| Elliott Hughes | e2a292d | 2014-01-24 16:37:04 -0800 | [diff] [blame] | 211 | #endif | 
 | 212 |  | 
| Elliott Hughes | 83c07b5 | 2014-04-21 18:09:46 -0700 | [diff] [blame] | 213 | #if defined(__LP64__) | 
| Elliott Hughes | e2a292d | 2014-01-24 16:37:04 -0800 | [diff] [blame] | 214 | #  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 Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 229 | #endif /* _STDINT_H */ |