1c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/*===---- stdint.h - Standard header for sized integer types --------------===*\ 2c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 3c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * Copyright (c) 2009 Chris Lattner 4c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 5c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * Permission is hereby granted, free of charge, to any person obtaining a copy 6c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * of this software and associated documentation files (the "Software"), to deal 7c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * in the Software without restriction, including without limitation the rights 8c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * copies of the Software, and to permit persons to whom the Software is 10c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * furnished to do so, subject to the following conditions: 11c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 12c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * The above copyright notice and this permission notice shall be included in 13c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * all copies or substantial portions of the Software. 14c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 15c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * THE SOFTWARE. 22c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 23c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao\*===----------------------------------------------------------------------===*/ 24c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 25c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifndef __CLANG_STDINT_H 26c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __CLANG_STDINT_H 27c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 28c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* If we're hosted, fall back to the system's stdint.h, which might have 29c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * additional definitions. 30c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao */ 31c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#if __STDC_HOSTED__ && __has_include_next(<stdint.h>) 32c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 33c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// C99 7.18.3 Limits of other integer types 34c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// 35c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// Footnote 219, 220: C++ implementations should define these macros only when 36c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// __STDC_LIMIT_MACROS is defined before <stdint.h> is included. 37c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// 38c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// Footnote 222: C++ implementations should define these macros only when 39c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// __STDC_CONSTANT_MACROS is defined before <stdint.h> is included. 40c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// 41c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// C++11 [cstdint.syn]p2: 42c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// 43c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// The macros defined by <cstdint> are provided unconditionally. In particular, 44c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// the symbols __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS (mentioned in 45c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// footnotes 219, 220, and 222 in the C standard) play no role in C++. 46c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// 47c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// C11 removed the problematic footnotes. 48c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// 49c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// Work around this inconsistency by always defining those macros in C++ mode, 50c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// so that a C library implementation which follows the C99 standard can be 51c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao// used in C++. 52c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __cplusplus 53c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# if !defined(__STDC_LIMIT_MACROS) 54c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __STDC_LIMIT_MACROS 55c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __STDC_LIMIT_MACROS_DEFINED_BY_CLANG 56c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif 57c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# if !defined(__STDC_CONSTANT_MACROS) 58c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __STDC_CONSTANT_MACROS 59c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG 60c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif 61c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif 62c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 63c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# include_next <stdint.h> 64c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 65c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG 66c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __STDC_LIMIT_MACROS 67c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG 68c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif 69c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG 70c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __STDC_CONSTANT_MACROS 71c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG 72c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif 73c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 74c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#else 75c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 76c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* C99 7.18.1.1 Exact-width integer types. 77c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * C99 7.18.1.2 Minimum-width integer types. 78c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * C99 7.18.1.3 Fastest minimum-width integer types. 79c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 80c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * The standard requires that exact-width type be defined for 8-, 16-, 32-, and 81c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 64-bit types if they are implemented. Other exact width types are optional. 82c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * This implementation defines an exact-width types for every integer width 83c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * that is represented in the standard integer types. 84c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 85c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * The standard also requires minimum-width types be defined for 8-, 16-, 32-, 86c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * and 64-bit widths regardless of whether there are corresponding exact-width 87c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * types. 88c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 89c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * To accommodate targets that are missing types that are exactly 8, 16, 32, or 90c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 64 bits wide, this implementation takes an approach of cascading 91c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * redefintions, redefining __int_leastN_t to successively smaller exact-width 92c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * types. It is therefore important that the types are defined in order of 93c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * descending widths. 94c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 95c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * We currently assume that the minimum-width types and the fastest 96c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * minimum-width types are the same. This is allowed by the standard, but is 97c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * suboptimal. 98c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 99c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * In violation of the standard, some targets do not implement a type that is 100c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit). 101c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * To accommodate these targets, a required minimum-width type is only 102c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * defined if there exists an exact-width type of equal or greater width. 103c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao */ 104c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 105c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT64_TYPE__ 106c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/ 107c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef signed __INT64_TYPE__ int64_t; 108c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __int8_t_defined */ 109c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef unsigned __INT64_TYPE__ uint64_t; 110c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least64_t int64_t 111c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least64_t uint64_t 112c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least32_t int64_t 113c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least32_t uint64_t 114c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least16_t int64_t 115c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least16_t uint64_t 116c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least8_t int64_t 117c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least8_t uint64_t 118c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT64_TYPE__ */ 119c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 120c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __int_least64_t 121c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __int_least64_t int_least64_t; 122c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __uint_least64_t uint_least64_t; 123c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __int_least64_t int_fast64_t; 124c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __uint_least64_t uint_fast64_t; 125c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __int_least64_t */ 126c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 127c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT56_TYPE__ 128c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef signed __INT56_TYPE__ int56_t; 129c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef unsigned __INT56_TYPE__ uint56_t; 130c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef int56_t int_least56_t; 131c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef uint56_t uint_least56_t; 132c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef int56_t int_fast56_t; 133c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef uint56_t uint_fast56_t; 134c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least32_t int56_t 135c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least32_t uint56_t 136c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least16_t int56_t 137c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least16_t uint56_t 138c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least8_t int56_t 139c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least8_t uint56_t 140c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT56_TYPE__ */ 141c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 142c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 143c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT48_TYPE__ 144c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef signed __INT48_TYPE__ int48_t; 145c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef unsigned __INT48_TYPE__ uint48_t; 146c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef int48_t int_least48_t; 147c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef uint48_t uint_least48_t; 148c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef int48_t int_fast48_t; 149c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef uint48_t uint_fast48_t; 150c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least32_t int48_t 151c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least32_t uint48_t 152c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least16_t int48_t 153c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least16_t uint48_t 154c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least8_t int48_t 155c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least8_t uint48_t 156c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT48_TYPE__ */ 157c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 158c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 159c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT40_TYPE__ 160c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef signed __INT40_TYPE__ int40_t; 161c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef unsigned __INT40_TYPE__ uint40_t; 162c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef int40_t int_least40_t; 163c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef uint40_t uint_least40_t; 164c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef int40_t int_fast40_t; 165c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef uint40_t uint_fast40_t; 166c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least32_t int40_t 167c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least32_t uint40_t 168c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least16_t int40_t 169c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least16_t uint40_t 170c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least8_t int40_t 171c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least8_t uint40_t 172c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT40_TYPE__ */ 173c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 174c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 175c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT32_TYPE__ 176c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 177c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/ 178c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef signed __INT32_TYPE__ int32_t; 179c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __int8_t_defined */ 180c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 181c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifndef __uint32_t_defined /* more glibc compatibility */ 182c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint32_t_defined 183c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef unsigned __INT32_TYPE__ uint32_t; 184c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __uint32_t_defined */ 185c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 186c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least32_t int32_t 187c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least32_t uint32_t 188c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least16_t int32_t 189c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least16_t uint32_t 190c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least8_t int32_t 191c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least8_t uint32_t 192c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT32_TYPE__ */ 193c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 194c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __int_least32_t 195c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __int_least32_t int_least32_t; 196c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __uint_least32_t uint_least32_t; 197c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __int_least32_t int_fast32_t; 198c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __uint_least32_t uint_fast32_t; 199c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __int_least32_t */ 200c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 201c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT24_TYPE__ 202c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef signed __INT24_TYPE__ int24_t; 203c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef unsigned __INT24_TYPE__ uint24_t; 204c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef int24_t int_least24_t; 205c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef uint24_t uint_least24_t; 206c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef int24_t int_fast24_t; 207c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef uint24_t uint_fast24_t; 208c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least16_t int24_t 209c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least16_t uint24_t 210c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least8_t int24_t 211c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least8_t uint24_t 212c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT24_TYPE__ */ 213c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 214c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT16_TYPE__ 215c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/ 216c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef signed __INT16_TYPE__ int16_t; 217c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __int8_t_defined */ 218c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef unsigned __INT16_TYPE__ uint16_t; 219c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least16_t int16_t 220c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least16_t uint16_t 221c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least8_t int16_t 222c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least8_t uint16_t 223c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT16_TYPE__ */ 224c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 225c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __int_least16_t 226c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __int_least16_t int_least16_t; 227c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __uint_least16_t uint_least16_t; 228c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __int_least16_t int_fast16_t; 229c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __uint_least16_t uint_fast16_t; 230c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __int_least16_t */ 231c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 232c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 233c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT8_TYPE__ 234c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifndef __int8_t_defined /* glibc sys/types.h also defines int8_t*/ 235c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef signed __INT8_TYPE__ int8_t; 236c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __int8_t_defined */ 237c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef unsigned __INT8_TYPE__ uint8_t; 238c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int_least8_t int8_t 239c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __uint_least8_t uint8_t 240c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT8_TYPE__ */ 241c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 242c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __int_least8_t 243c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __int_least8_t int_least8_t; 244c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __uint_least8_t uint_least8_t; 245c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __int_least8_t int_fast8_t; 246c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __uint_least8_t uint_fast8_t; 247c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __int_least8_t */ 248c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 249c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* prevent glibc sys/types.h from defining conflicting types */ 250c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifndef __int8_t_defined 251c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int8_t_defined 252c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __int8_t_defined */ 253c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 254c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* C99 7.18.1.4 Integer types capable of holding object pointers. 255c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao */ 256c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __stdint_join3(a,b,c) a ## b ## c 257c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 258c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __intn_t(n) __stdint_join3( int, n, _t) 259c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __uintn_t(n) __stdint_join3(uint, n, _t) 260c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 261c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifndef _INTPTR_T 262c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifndef __intptr_t_defined 263c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __intn_t(__INTPTR_WIDTH__) intptr_t; 264c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __intptr_t_defined 265c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define _INTPTR_T 266c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif 267c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif 268c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 269c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifndef _UINTPTR_T 270c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __uintn_t(__INTPTR_WIDTH__) uintptr_t; 271c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define _UINTPTR_T 272c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif 273c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 274c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* C99 7.18.1.5 Greatest-width integer types. 275c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao */ 276c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __INTMAX_TYPE__ intmax_t; 277c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhaotypedef __UINTMAX_TYPE__ uintmax_t; 278c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 279c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* C99 7.18.4 Macros for minimum-width integer constants. 280c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 281c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * The standard requires that integer constant macros be defined for all the 282c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width 283c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * types are required, the corresponding integer constant macros are defined 284c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * here. This implementation also defines minimum-width types for every other 285c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * integer width that the target implements, so corresponding macros are 286c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * defined below, too. 287c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 288c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * These macros are defined using the same successive-shrinking approach as 289c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * the type definitions above. It is likewise important that macros are defined 290c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * in order of decending width. 291c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 292c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the 293c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). 294c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao */ 295c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 296c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __int_c_join(a, b) a ## b 297c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __int_c(v, suffix) __int_c_join(v, suffix) 298c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __uint_c(v, suffix) __int_c_join(v##U, suffix) 299c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 300c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 301c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT64_TYPE__ 302c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __INT64_C_SUFFIX__ 303c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int64_c_suffix __INT64_C_SUFFIX__ 304c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int32_c_suffix __INT64_C_SUFFIX__ 305c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int16_c_suffix __INT64_C_SUFFIX__ 306c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int8_c_suffix __INT64_C_SUFFIX__ 307c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# else 308c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int64_c_suffix 309c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int32_c_suffix 310c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int16_c_suffix 311c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int8_c_suffix 312c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __INT64_C_SUFFIX__ */ 313c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT64_TYPE__ */ 314c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 315c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __int_least64_t 316c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __int64_c_suffix 317c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT64_C(v) __int_c(v, __int64_c_suffix) 318c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT64_C(v) __uint_c(v, __int64_c_suffix) 319c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# else 320c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT64_C(v) v 321c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT64_C(v) v ## U 322c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __int64_c_suffix */ 323c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __int_least64_t */ 324c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 325c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 326c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT56_TYPE__ 327c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __INT56_C_SUFFIX__ 328c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT56_C(v) __int_c(v, __INT56_C_SUFFIX__) 329c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT56_C(v) __uint_c(v, __INT56_C_SUFFIX__) 330c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int32_c_suffix __INT56_C_SUFFIX__ 331c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int16_c_suffix __INT56_C_SUFFIX__ 332c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int8_c_suffix __INT56_C_SUFFIX__ 333c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# else 334c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT56_C(v) v 335c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT56_C(v) v ## U 336c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int32_c_suffix 337c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int16_c_suffix 338c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int8_c_suffix 339c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __INT56_C_SUFFIX__ */ 340c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT56_TYPE__ */ 341c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 342c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 343c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT48_TYPE__ 344c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __INT48_C_SUFFIX__ 345c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT48_C(v) __int_c(v, __INT48_C_SUFFIX__) 346c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT48_C(v) __uint_c(v, __INT48_C_SUFFIX__) 347c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int32_c_suffix __INT48_C_SUFFIX__ 348c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int16_c_suffix __INT48_C_SUFFIX__ 349c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int8_c_suffix __INT48_C_SUFFIX__ 350c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# else 351c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT48_C(v) v 352c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT48_C(v) v ## U 353c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int32_c_suffix 354c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int16_c_suffix 355c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int8_c_suffix 356c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __INT48_C_SUFFIX__ */ 357c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT48_TYPE__ */ 358c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 359c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 360c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT40_TYPE__ 361c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __INT40_C_SUFFIX__ 362c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT40_C(v) __int_c(v, __INT40_C_SUFFIX__) 363c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT40_C(v) __uint_c(v, __INT40_C_SUFFIX__) 364c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int32_c_suffix __INT40_C_SUFFIX__ 365c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int16_c_suffix __INT40_C_SUFFIX__ 366c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int8_c_suffix __INT40_C_SUFFIX__ 367c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# else 368c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT40_C(v) v 369c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT40_C(v) v ## U 370c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int32_c_suffix 371c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int16_c_suffix 372c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int8_c_suffix 373c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __INT40_C_SUFFIX__ */ 374c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT40_TYPE__ */ 375c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 376c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 377c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT32_TYPE__ 378c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __INT32_C_SUFFIX__ 379c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int32_c_suffix __INT32_C_SUFFIX__ 380c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int16_c_suffix __INT32_C_SUFFIX__ 381c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int8_c_suffix __INT32_C_SUFFIX__ 382c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#else 383c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int32_c_suffix 384c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int16_c_suffix 385c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int8_c_suffix 386c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __INT32_C_SUFFIX__ */ 387c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT32_TYPE__ */ 388c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 389c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __int_least32_t 390c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __int32_c_suffix 391c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT32_C(v) __int_c(v, __int32_c_suffix) 392c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT32_C(v) __uint_c(v, __int32_c_suffix) 393c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# else 394c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT32_C(v) v 395c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT32_C(v) v ## U 396c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __int32_c_suffix */ 397c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __int_least32_t */ 398c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 399c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 400c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT24_TYPE__ 401c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __INT24_C_SUFFIX__ 402c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT24_C(v) __int_c(v, __INT24_C_SUFFIX__) 403c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT24_C(v) __uint_c(v, __INT24_C_SUFFIX__) 404c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int16_c_suffix __INT24_C_SUFFIX__ 405c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int8_c_suffix __INT24_C_SUFFIX__ 406c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# else 407c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT24_C(v) v 408c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT24_C(v) v ## U 409c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int16_c_suffix 410c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int8_c_suffix 411c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __INT24_C_SUFFIX__ */ 412c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT24_TYPE__ */ 413c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 414c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 415c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT16_TYPE__ 416c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __INT16_C_SUFFIX__ 417c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int16_c_suffix __INT16_C_SUFFIX__ 418c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int8_c_suffix __INT16_C_SUFFIX__ 419c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#else 420c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int16_c_suffix 421c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int8_c_suffix 422c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __INT16_C_SUFFIX__ */ 423c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT16_TYPE__ */ 424c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 425c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __int_least16_t 426c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __int16_c_suffix 427c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT16_C(v) __int_c(v, __int16_c_suffix) 428c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT16_C(v) __uint_c(v, __int16_c_suffix) 429c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# else 430c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT16_C(v) v 431c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT16_C(v) v ## U 432c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __int16_c_suffix */ 433c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __int_least16_t */ 434c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 435c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 436c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT8_TYPE__ 437c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __INT8_C_SUFFIX__ 438c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __int8_c_suffix __INT8_C_SUFFIX__ 439c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#else 440c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# undef __int8_c_suffix 441c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __INT8_C_SUFFIX__ */ 442c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT8_TYPE__ */ 443c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 444c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __int_least8_t 445c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# ifdef __int8_c_suffix 446c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT8_C(v) __int_c(v, __int8_c_suffix) 447c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT8_C(v) __uint_c(v, __int8_c_suffix) 448c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# else 449c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT8_C(v) v 450c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT8_C(v) v ## U 451c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif /* __int8_c_suffix */ 452c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __int_least8_t */ 453c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 454c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 455c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* C99 7.18.2.1 Limits of exact-width integer types. 456c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * C99 7.18.2.2 Limits of minimum-width integer types. 457c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * C99 7.18.2.3 Limits of fastest minimum-width integer types. 458c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 459c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * The presence of limit macros are completely optional in C99. This 460c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * implementation defines limits for all of the types (exact- and 461c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * minimum-width) that it defines above, using the limits of the minimum-width 462c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * type for any types that do not have exact-width representations. 463c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 464c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * As in the type definitions, this section takes an approach of 465c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * successive-shrinking to determine which limits to use for the standard (8, 466c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 16, 32, 64) bit widths when they don't have exact representations. It is 467c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * therefore important that the defintions be kept in order of decending 468c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * widths. 469c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * 470c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the 471c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). 472c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao */ 473c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 474c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT64_TYPE__ 475c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT64_MAX INT64_C( 9223372036854775807) 476c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT64_MIN (-INT64_C( 9223372036854775807)-1) 477c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT64_MAX UINT64_C(18446744073709551615) 478c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST64_MIN INT64_MIN 479c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST64_MAX INT64_MAX 480c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST64_MAX UINT64_MAX 481c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST32_MIN INT64_MIN 482c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST32_MAX INT64_MAX 483c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST32_MAX UINT64_MAX 484c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MIN INT64_MIN 485c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MAX INT64_MAX 486c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST16_MAX UINT64_MAX 487c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MIN INT64_MIN 488c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MAX INT64_MAX 489c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST8_MAX UINT64_MAX 490c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT64_TYPE__ */ 491c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 492c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT_LEAST64_MIN 493c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST64_MIN __INT_LEAST64_MIN 494c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST64_MAX __INT_LEAST64_MAX 495c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_LEAST64_MAX __UINT_LEAST64_MAX 496c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST64_MIN __INT_LEAST64_MIN 497c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST64_MAX __INT_LEAST64_MAX 498c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_FAST64_MAX __UINT_LEAST64_MAX 499c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT_LEAST64_MIN */ 500c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 501c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 502c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT56_TYPE__ 503c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT56_MAX INT56_C(36028797018963967) 504c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT56_MIN (-INT56_C(36028797018963967)-1) 505c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT56_MAX UINT56_C(72057594037927935) 506c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST56_MIN INT56_MIN 507c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST56_MAX INT56_MAX 508c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_LEAST56_MAX UINT56_MAX 509c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST56_MIN INT56_MIN 510c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST56_MAX INT56_MAX 511c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_FAST56_MAX UINT56_MAX 512c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST32_MIN INT56_MIN 513c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST32_MAX INT56_MAX 514c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST32_MAX UINT56_MAX 515c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MIN INT56_MIN 516c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MAX INT56_MAX 517c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST16_MAX UINT56_MAX 518c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MIN INT56_MIN 519c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MAX INT56_MAX 520c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST8_MAX UINT56_MAX 521c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT56_TYPE__ */ 522c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 523c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 524c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT48_TYPE__ 525c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT48_MAX INT48_C(140737488355327) 526c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT48_MIN (-INT48_C(140737488355327)-1) 527c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT48_MAX UINT48_C(281474976710655) 528c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST48_MIN INT48_MIN 529c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST48_MAX INT48_MAX 530c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_LEAST48_MAX UINT48_MAX 531c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST48_MIN INT48_MIN 532c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST48_MAX INT48_MAX 533c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_FAST48_MAX UINT48_MAX 534c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST32_MIN INT48_MIN 535c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST32_MAX INT48_MAX 536c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST32_MAX UINT48_MAX 537c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MIN INT48_MIN 538c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MAX INT48_MAX 539c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST16_MAX UINT48_MAX 540c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MIN INT48_MIN 541c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MAX INT48_MAX 542c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST8_MAX UINT48_MAX 543c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT48_TYPE__ */ 544c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 545c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 546c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT40_TYPE__ 547c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT40_MAX INT40_C(549755813887) 548c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT40_MIN (-INT40_C(549755813887)-1) 549c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT40_MAX UINT40_C(1099511627775) 550c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST40_MIN INT40_MIN 551c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST40_MAX INT40_MAX 552c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_LEAST40_MAX UINT40_MAX 553c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST40_MIN INT40_MIN 554c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST40_MAX INT40_MAX 555c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_FAST40_MAX UINT40_MAX 556c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST32_MIN INT40_MIN 557c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST32_MAX INT40_MAX 558c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST32_MAX UINT40_MAX 559c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MIN INT40_MIN 560c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MAX INT40_MAX 561c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST16_MAX UINT40_MAX 562c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MIN INT40_MIN 563c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MAX INT40_MAX 564c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST8_MAX UINT40_MAX 565c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT40_TYPE__ */ 566c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 567c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 568c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT32_TYPE__ 569c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT32_MAX INT32_C(2147483647) 570c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT32_MIN (-INT32_C(2147483647)-1) 571c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT32_MAX UINT32_C(4294967295) 572c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST32_MIN INT32_MIN 573c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST32_MAX INT32_MAX 574c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST32_MAX UINT32_MAX 575c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MIN INT32_MIN 576c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MAX INT32_MAX 577c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST16_MAX UINT32_MAX 578c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MIN INT32_MIN 579c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MAX INT32_MAX 580c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST8_MAX UINT32_MAX 581c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT32_TYPE__ */ 582c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 583c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT_LEAST32_MIN 584c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST32_MIN __INT_LEAST32_MIN 585c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST32_MAX __INT_LEAST32_MAX 586c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_LEAST32_MAX __UINT_LEAST32_MAX 587c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST32_MIN __INT_LEAST32_MIN 588c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST32_MAX __INT_LEAST32_MAX 589c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_FAST32_MAX __UINT_LEAST32_MAX 590c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT_LEAST32_MIN */ 591c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 592c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 593c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT24_TYPE__ 594c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT24_MAX INT24_C(8388607) 595c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT24_MIN (-INT24_C(8388607)-1) 596c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT24_MAX UINT24_C(16777215) 597c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST24_MIN INT24_MIN 598c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST24_MAX INT24_MAX 599c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_LEAST24_MAX UINT24_MAX 600c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST24_MIN INT24_MIN 601c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST24_MAX INT24_MAX 602c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_FAST24_MAX UINT24_MAX 603c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MIN INT24_MIN 604c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MAX INT24_MAX 605c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST16_MAX UINT24_MAX 606c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MIN INT24_MIN 607c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MAX INT24_MAX 608c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST8_MAX UINT24_MAX 609c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT24_TYPE__ */ 610c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 611c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 612c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT16_TYPE__ 613c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define INT16_MAX INT16_C(32767) 614c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define INT16_MIN (-INT16_C(32767)-1) 615c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define UINT16_MAX UINT16_C(65535) 616c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MIN INT16_MIN 617c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST16_MAX INT16_MAX 618c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST16_MAX UINT16_MAX 619c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MIN INT16_MIN 620c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MAX INT16_MAX 621c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST8_MAX UINT16_MAX 622c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT16_TYPE__ */ 623c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 624c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT_LEAST16_MIN 625c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST16_MIN __INT_LEAST16_MIN 626c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST16_MAX __INT_LEAST16_MAX 627c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_LEAST16_MAX __UINT_LEAST16_MAX 628c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST16_MIN __INT_LEAST16_MIN 629c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST16_MAX __INT_LEAST16_MAX 630c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_FAST16_MAX __UINT_LEAST16_MAX 631c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT_LEAST16_MIN */ 632c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 633c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 634c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT8_TYPE__ 635c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT8_MAX INT8_C(127) 636c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT8_MIN (-INT8_C(127)-1) 637c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT8_MAX UINT8_C(255) 638c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MIN INT8_MIN 639c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __INT_LEAST8_MAX INT8_MAX 640c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define __UINT_LEAST8_MAX UINT8_MAX 641c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT8_TYPE__ */ 642c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 643c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __INT_LEAST8_MIN 644c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST8_MIN __INT_LEAST8_MIN 645c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_LEAST8_MAX __INT_LEAST8_MAX 646c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_LEAST8_MAX __UINT_LEAST8_MAX 647c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST8_MIN __INT_LEAST8_MIN 648c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define INT_FAST8_MAX __INT_LEAST8_MAX 649c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define UINT_FAST8_MAX __UINT_LEAST8_MAX 650c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __INT_LEAST8_MIN */ 651c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 652c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* Some utility macros */ 653c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __INTN_MIN(n) __stdint_join3( INT, n, _MIN) 654c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __INTN_MAX(n) __stdint_join3( INT, n, _MAX) 655c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __UINTN_MAX(n) __stdint_join3(UINT, n, _MAX) 656c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __INTN_C(n, v) __stdint_join3( INT, n, _C(v)) 657c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v)) 658c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 659c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */ 660c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* C99 7.18.3 Limits of other integer types. */ 661c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 662c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define INTPTR_MIN __INTN_MIN(__INTPTR_WIDTH__) 663c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define INTPTR_MAX __INTN_MAX(__INTPTR_WIDTH__) 664c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define UINTPTR_MAX __UINTN_MAX(__INTPTR_WIDTH__) 665c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define PTRDIFF_MIN __INTN_MIN(__PTRDIFF_WIDTH__) 666c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define PTRDIFF_MAX __INTN_MAX(__PTRDIFF_WIDTH__) 667c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define SIZE_MAX __UINTN_MAX(__SIZE_WIDTH__) 668c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 669c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__ 670c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao * is enabled. */ 671c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 672c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define RSIZE_MAX (SIZE_MAX >> 1) 673c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif 674c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 675c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* C99 7.18.2.5 Limits of greatest-width integer types. */ 676c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define INTMAX_MIN __INTN_MIN(__INTMAX_WIDTH__) 677c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define INTMAX_MAX __INTN_MAX(__INTMAX_WIDTH__) 678c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define UINTMAX_MAX __UINTN_MAX(__INTMAX_WIDTH__) 679c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 680c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* C99 7.18.3 Limits of other integer types. */ 681c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__) 682c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__) 683c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifdef __WINT_UNSIGNED__ 684c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define WINT_MIN __UINTN_C(__WINT_WIDTH__, 0) 685c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define WINT_MAX __UINTN_MAX(__WINT_WIDTH__) 686c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#else 687c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define WINT_MIN __INTN_MIN(__WINT_WIDTH__) 688c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define WINT_MAX __INTN_MAX(__WINT_WIDTH__) 689c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif 690c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 691c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifndef WCHAR_MAX 692c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define WCHAR_MAX __WCHAR_MAX__ 693c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif 694c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#ifndef WCHAR_MIN 695c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__) 696c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__) 697c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# else 698c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0) 699c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao# endif 700c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif 701c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 702c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao/* 7.18.4.2 Macros for greatest-width integer constants. */ 703c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define INTMAX_C(v) __INTN_C(__INTMAX_WIDTH__, v) 704c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#define UINTMAX_C(v) __UINTN_C(__INTMAX_WIDTH__, v) 705c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao 706c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __STDC_HOSTED__ */ 707c26fdd1c7de95ebc5d823d56ef4e6e7b52231633Qiwen Zhao#endif /* __CLANG_STDINT_H */ 708