2009-02-07 06:59:47 +08:00
|
|
|
/*===---- stdint.h - Standard header for sized integer types --------------===*\
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009 Chris Lattner
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*
|
|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
|
2009-05-04 07:00:48 +08:00
|
|
|
#ifndef __CLANG_STDINT_H
|
|
|
|
#define __CLANG_STDINT_H
|
|
|
|
|
|
|
|
/* If we're hosted, fall back to the system's stdint.h, which might have
|
|
|
|
* additional definitions.
|
|
|
|
*/
|
2014-02-20 06:53:42 +08:00
|
|
|
#if __STDC_HOSTED__ && __has_include_next(<stdint.h>)
|
tl;dr: Teach Clang to work around g++ changing its workaround to glibc's
implementation of C99's attempt to control the C++ standard. *sigh*
The C99 standard says that certain macros in <stdint.h>, such as SIZE_MAX,
should not be defined when the header is included in C++ mode, unless
__STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS are defined. The C++11 standard
says "Thanks, but no thanks" and C11 removed this rule, but various C library
implementations (such as glibc) follow C99 anyway.
g++ prior to 4.8 worked around the C99 / glibc behavior by defining
__STDC_*_MACROS in <cstdint>, which was incorrect, because <stdint.h> is
supposed to provide these macros too. g++ 4.8 works around it by defining
__STDC_*_MACROS in its builtin <stdint.h> header.
This change makes Clang act like g++ 4.8 in this regard: our <stdint.h> now
countermands any attempt by the C library to implement the undesired C99 rules,
by defining the __STDC_*_MACROS first. Unlike g++, we do this even in C++98
mode, since that was the intent of the C++ committee, matches the behavior
required in C11, and matches our built-in implementation of <stdint.h>.
llvm-svn: 179419
2013-04-13 06:11:07 +08:00
|
|
|
|
|
|
|
// C99 7.18.3 Limits of other integer types
|
|
|
|
//
|
|
|
|
// Footnote 219, 220: C++ implementations should define these macros only when
|
|
|
|
// __STDC_LIMIT_MACROS is defined before <stdint.h> is included.
|
|
|
|
//
|
|
|
|
// Footnote 222: C++ implementations should define these macros only when
|
|
|
|
// __STDC_CONSTANT_MACROS is defined before <stdint.h> is included.
|
|
|
|
//
|
|
|
|
// C++11 [cstdint.syn]p2:
|
|
|
|
//
|
|
|
|
// The macros defined by <cstdint> are provided unconditionally. In particular,
|
|
|
|
// the symbols __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS (mentioned in
|
|
|
|
// footnotes 219, 220, and 222 in the C standard) play no role in C++.
|
|
|
|
//
|
|
|
|
// C11 removed the problematic footnotes.
|
|
|
|
//
|
|
|
|
// Work around this inconsistency by always defining those macros in C++ mode,
|
|
|
|
// so that a C library implementation which follows the C99 standard can be
|
|
|
|
// used in C++.
|
|
|
|
# ifdef __cplusplus
|
|
|
|
# if !defined(__STDC_LIMIT_MACROS)
|
|
|
|
# define __STDC_LIMIT_MACROS
|
|
|
|
# define __STDC_LIMIT_MACROS_DEFINED_BY_CLANG
|
|
|
|
# endif
|
|
|
|
# if !defined(__STDC_CONSTANT_MACROS)
|
|
|
|
# define __STDC_CONSTANT_MACROS
|
|
|
|
# define __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
|
2009-05-04 07:00:48 +08:00
|
|
|
# include_next <stdint.h>
|
tl;dr: Teach Clang to work around g++ changing its workaround to glibc's
implementation of C99's attempt to control the C++ standard. *sigh*
The C99 standard says that certain macros in <stdint.h>, such as SIZE_MAX,
should not be defined when the header is included in C++ mode, unless
__STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS are defined. The C++11 standard
says "Thanks, but no thanks" and C11 removed this rule, but various C library
implementations (such as glibc) follow C99 anyway.
g++ prior to 4.8 worked around the C99 / glibc behavior by defining
__STDC_*_MACROS in <cstdint>, which was incorrect, because <stdint.h> is
supposed to provide these macros too. g++ 4.8 works around it by defining
__STDC_*_MACROS in its builtin <stdint.h> header.
This change makes Clang act like g++ 4.8 in this regard: our <stdint.h> now
countermands any attempt by the C library to implement the undesired C99 rules,
by defining the __STDC_*_MACROS first. Unlike g++, we do this even in C++98
mode, since that was the intent of the C++ committee, matches the behavior
required in C11, and matches our built-in implementation of <stdint.h>.
llvm-svn: 179419
2013-04-13 06:11:07 +08:00
|
|
|
|
|
|
|
# ifdef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG
|
|
|
|
# undef __STDC_LIMIT_MACROS
|
|
|
|
# undef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG
|
|
|
|
# endif
|
|
|
|
# ifdef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG
|
|
|
|
# undef __STDC_CONSTANT_MACROS
|
|
|
|
# undef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG
|
|
|
|
# endif
|
|
|
|
|
2009-05-04 07:00:48 +08:00
|
|
|
#else
|
2009-02-07 06:59:47 +08:00
|
|
|
|
|
|
|
/* C99 7.18.1.1 Exact-width integer types.
|
|
|
|
* C99 7.18.1.2 Minimum-width integer types.
|
|
|
|
* C99 7.18.1.3 Fastest minimum-width integer types.
|
2009-11-12 16:08:27 +08:00
|
|
|
*
|
2015-09-12 10:55:19 +08:00
|
|
|
* The standard requires that exact-width type be defined for 8-, 16-, 32-, and
|
2009-11-12 16:08:27 +08:00
|
|
|
* 64-bit types if they are implemented. Other exact width types are optional.
|
|
|
|
* This implementation defines an exact-width types for every integer width
|
|
|
|
* that is represented in the standard integer types.
|
|
|
|
*
|
|
|
|
* The standard also requires minimum-width types be defined for 8-, 16-, 32-,
|
|
|
|
* and 64-bit widths regardless of whether there are corresponding exact-width
|
2015-09-12 10:55:19 +08:00
|
|
|
* types.
|
2009-11-12 16:08:27 +08:00
|
|
|
*
|
2011-04-15 13:22:18 +08:00
|
|
|
* To accommodate targets that are missing types that are exactly 8, 16, 32, or
|
2009-11-12 16:08:27 +08:00
|
|
|
* 64 bits wide, this implementation takes an approach of cascading
|
2018-04-06 23:14:32 +08:00
|
|
|
* redefinitions, redefining __int_leastN_t to successively smaller exact-width
|
2009-11-12 16:08:27 +08:00
|
|
|
* types. It is therefore important that the types are defined in order of
|
|
|
|
* descending widths.
|
|
|
|
*
|
|
|
|
* We currently assume that the minimum-width types and the fastest
|
|
|
|
* minimum-width types are the same. This is allowed by the standard, but is
|
|
|
|
* suboptimal.
|
|
|
|
*
|
|
|
|
* In violation of the standard, some targets do not implement a type that is
|
2015-09-12 10:55:19 +08:00
|
|
|
* wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit).
|
2011-04-15 13:22:18 +08:00
|
|
|
* To accommodate these targets, a required minimum-width type is only
|
2009-11-12 16:08:27 +08:00
|
|
|
* defined if there exists an exact-width type of equal or greater width.
|
2009-02-07 06:59:47 +08:00
|
|
|
*/
|
|
|
|
|
2009-04-19 03:11:11 +08:00
|
|
|
#ifdef __INT64_TYPE__
|
2009-11-12 16:08:27 +08:00
|
|
|
# ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/
|
2014-07-29 05:06:22 +08:00
|
|
|
typedef __INT64_TYPE__ int64_t;
|
2009-11-12 16:08:27 +08:00
|
|
|
# endif /* __int8_t_defined */
|
2014-07-29 05:06:22 +08:00
|
|
|
typedef __UINT64_TYPE__ uint64_t;
|
2009-11-12 16:08:27 +08:00
|
|
|
# define __int_least64_t int64_t
|
|
|
|
# define __uint_least64_t uint64_t
|
|
|
|
# define __int_least32_t int64_t
|
|
|
|
# define __uint_least32_t uint64_t
|
|
|
|
# define __int_least16_t int64_t
|
|
|
|
# define __uint_least16_t uint64_t
|
|
|
|
# define __int_least8_t int64_t
|
|
|
|
# define __uint_least8_t uint64_t
|
|
|
|
#endif /* __INT64_TYPE__ */
|
2009-04-19 03:11:11 +08:00
|
|
|
|
2009-11-12 16:08:27 +08:00
|
|
|
#ifdef __int_least64_t
|
|
|
|
typedef __int_least64_t int_least64_t;
|
|
|
|
typedef __uint_least64_t uint_least64_t;
|
|
|
|
typedef __int_least64_t int_fast64_t;
|
|
|
|
typedef __uint_least64_t uint_fast64_t;
|
|
|
|
#endif /* __int_least64_t */
|
|
|
|
|
|
|
|
#ifdef __INT56_TYPE__
|
2014-07-29 05:06:22 +08:00
|
|
|
typedef __INT56_TYPE__ int56_t;
|
|
|
|
typedef __UINT56_TYPE__ uint56_t;
|
2009-11-12 16:08:27 +08:00
|
|
|
typedef int56_t int_least56_t;
|
|
|
|
typedef uint56_t uint_least56_t;
|
|
|
|
typedef int56_t int_fast56_t;
|
|
|
|
typedef uint56_t uint_fast56_t;
|
|
|
|
# define __int_least32_t int56_t
|
|
|
|
# define __uint_least32_t uint56_t
|
|
|
|
# define __int_least16_t int56_t
|
|
|
|
# define __uint_least16_t uint56_t
|
|
|
|
# define __int_least8_t int56_t
|
|
|
|
# define __uint_least8_t uint56_t
|
|
|
|
#endif /* __INT56_TYPE__ */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT48_TYPE__
|
2014-07-29 05:06:22 +08:00
|
|
|
typedef __INT48_TYPE__ int48_t;
|
|
|
|
typedef __UINT48_TYPE__ uint48_t;
|
2009-11-12 16:08:27 +08:00
|
|
|
typedef int48_t int_least48_t;
|
|
|
|
typedef uint48_t uint_least48_t;
|
|
|
|
typedef int48_t int_fast48_t;
|
|
|
|
typedef uint48_t uint_fast48_t;
|
|
|
|
# define __int_least32_t int48_t
|
|
|
|
# define __uint_least32_t uint48_t
|
|
|
|
# define __int_least16_t int48_t
|
|
|
|
# define __uint_least16_t uint48_t
|
|
|
|
# define __int_least8_t int48_t
|
|
|
|
# define __uint_least8_t uint48_t
|
|
|
|
#endif /* __INT48_TYPE__ */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT40_TYPE__
|
2014-07-29 05:06:22 +08:00
|
|
|
typedef __INT40_TYPE__ int40_t;
|
|
|
|
typedef __UINT40_TYPE__ uint40_t;
|
2009-11-12 16:08:27 +08:00
|
|
|
typedef int40_t int_least40_t;
|
|
|
|
typedef uint40_t uint_least40_t;
|
|
|
|
typedef int40_t int_fast40_t;
|
|
|
|
typedef uint40_t uint_fast40_t;
|
|
|
|
# define __int_least32_t int40_t
|
|
|
|
# define __uint_least32_t uint40_t
|
|
|
|
# define __int_least16_t int40_t
|
|
|
|
# define __uint_least16_t uint40_t
|
|
|
|
# define __int_least8_t int40_t
|
|
|
|
# define __uint_least8_t uint40_t
|
|
|
|
#endif /* __INT40_TYPE__ */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT32_TYPE__
|
|
|
|
|
|
|
|
# ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/
|
2014-07-29 05:06:22 +08:00
|
|
|
typedef __INT32_TYPE__ int32_t;
|
2009-11-12 16:08:27 +08:00
|
|
|
# endif /* __int8_t_defined */
|
|
|
|
|
|
|
|
# ifndef __uint32_t_defined /* more glibc compatibility */
|
|
|
|
# define __uint32_t_defined
|
2014-07-29 05:06:22 +08:00
|
|
|
typedef __UINT32_TYPE__ uint32_t;
|
2009-11-12 16:08:27 +08:00
|
|
|
# endif /* __uint32_t_defined */
|
2009-02-07 06:59:47 +08:00
|
|
|
|
2009-11-12 16:08:27 +08:00
|
|
|
# define __int_least32_t int32_t
|
|
|
|
# define __uint_least32_t uint32_t
|
|
|
|
# define __int_least16_t int32_t
|
|
|
|
# define __uint_least16_t uint32_t
|
|
|
|
# define __int_least8_t int32_t
|
|
|
|
# define __uint_least8_t uint32_t
|
|
|
|
#endif /* __INT32_TYPE__ */
|
2009-11-05 07:03:18 +08:00
|
|
|
|
2009-11-12 16:08:27 +08:00
|
|
|
#ifdef __int_least32_t
|
|
|
|
typedef __int_least32_t int_least32_t;
|
|
|
|
typedef __uint_least32_t uint_least32_t;
|
|
|
|
typedef __int_least32_t int_fast32_t;
|
|
|
|
typedef __uint_least32_t uint_fast32_t;
|
|
|
|
#endif /* __int_least32_t */
|
|
|
|
|
|
|
|
#ifdef __INT24_TYPE__
|
2014-07-29 05:06:22 +08:00
|
|
|
typedef __INT24_TYPE__ int24_t;
|
|
|
|
typedef __UINT24_TYPE__ uint24_t;
|
2009-11-12 16:08:27 +08:00
|
|
|
typedef int24_t int_least24_t;
|
|
|
|
typedef uint24_t uint_least24_t;
|
|
|
|
typedef int24_t int_fast24_t;
|
|
|
|
typedef uint24_t uint_fast24_t;
|
|
|
|
# define __int_least16_t int24_t
|
|
|
|
# define __uint_least16_t uint24_t
|
|
|
|
# define __int_least8_t int24_t
|
|
|
|
# define __uint_least8_t uint24_t
|
|
|
|
#endif /* __INT24_TYPE__ */
|
|
|
|
|
|
|
|
#ifdef __INT16_TYPE__
|
|
|
|
#ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/
|
2014-07-29 05:06:22 +08:00
|
|
|
typedef __INT16_TYPE__ int16_t;
|
2009-11-12 16:08:27 +08:00
|
|
|
#endif /* __int8_t_defined */
|
2014-07-29 05:06:22 +08:00
|
|
|
typedef __UINT16_TYPE__ uint16_t;
|
2009-11-12 16:08:27 +08:00
|
|
|
# define __int_least16_t int16_t
|
|
|
|
# define __uint_least16_t uint16_t
|
|
|
|
# define __int_least8_t int16_t
|
|
|
|
# define __uint_least8_t uint16_t
|
|
|
|
#endif /* __INT16_TYPE__ */
|
|
|
|
|
|
|
|
#ifdef __int_least16_t
|
|
|
|
typedef __int_least16_t int_least16_t;
|
|
|
|
typedef __uint_least16_t uint_least16_t;
|
|
|
|
typedef __int_least16_t int_fast16_t;
|
|
|
|
typedef __uint_least16_t uint_fast16_t;
|
|
|
|
#endif /* __int_least16_t */
|
2009-02-07 06:59:47 +08:00
|
|
|
|
|
|
|
|
2009-11-12 16:08:27 +08:00
|
|
|
#ifdef __INT8_TYPE__
|
|
|
|
#ifndef __int8_t_defined /* glibc sys/types.h also defines int8_t*/
|
2014-07-29 05:06:22 +08:00
|
|
|
typedef __INT8_TYPE__ int8_t;
|
2009-11-12 16:08:27 +08:00
|
|
|
#endif /* __int8_t_defined */
|
2014-07-29 05:06:22 +08:00
|
|
|
typedef __UINT8_TYPE__ uint8_t;
|
2009-11-12 16:08:27 +08:00
|
|
|
# define __int_least8_t int8_t
|
|
|
|
# define __uint_least8_t uint8_t
|
|
|
|
#endif /* __INT8_TYPE__ */
|
|
|
|
|
|
|
|
#ifdef __int_least8_t
|
|
|
|
typedef __int_least8_t int_least8_t;
|
|
|
|
typedef __uint_least8_t uint_least8_t;
|
|
|
|
typedef __int_least8_t int_fast8_t;
|
|
|
|
typedef __uint_least8_t uint_fast8_t;
|
|
|
|
#endif /* __int_least8_t */
|
2009-11-05 07:03:18 +08:00
|
|
|
|
|
|
|
/* prevent glibc sys/types.h from defining conflicting types */
|
2015-09-12 10:55:19 +08:00
|
|
|
#ifndef __int8_t_defined
|
2009-11-05 07:03:18 +08:00
|
|
|
# define __int8_t_defined
|
|
|
|
#endif /* __int8_t_defined */
|
|
|
|
|
2009-02-07 06:59:47 +08:00
|
|
|
/* C99 7.18.1.4 Integer types capable of holding object pointers.
|
|
|
|
*/
|
2009-11-19 04:24:13 +08:00
|
|
|
#define __stdint_join3(a,b,c) a ## b ## c
|
|
|
|
|
2010-04-25 04:32:12 +08:00
|
|
|
#ifndef _INTPTR_T
|
2009-02-14 06:43:13 +08:00
|
|
|
#ifndef __intptr_t_defined
|
Headers: Make the type of SIZE_MAX the same as size_t
size_t is usually defined as unsigned long, but on 64-bit platforms,
stdint.h currently defines SIZE_MAX using "ull" (unsigned long long).
Although this is the same width, it doesn't necessarily have the same
alignment or calling convention. It also triggers printf warnings when
using the format flag "%zu" to print SIZE_MAX.
This changes SIZE_MAX to reuse the compiler-provided __SIZE_MAX__, and
provides similar fixes for the other integers:
- INTPTR_MIN
- INTPTR_MAX
- UINTPTR_MAX
- PTRDIFF_MIN
- PTRDIFF_MAX
- INTMAX_MIN
- INTMAX_MAX
- UINTMAX_MAX
- INTMAX_C()
- UINTMAX_C()
... and fixes the typedefs for intptr_t and uintptr_t to use
__INTPTR_TYPE__ and __UINTPTR_TYPE__ instead of int32_t, effectively
reverting r89224, r89226, and r89237 (r89221 already having been
effectively reverted).
We can probably also kill __INTPTR_WIDTH__, __INTMAX_WIDTH__, and
__UINTMAX_WIDTH__ in a follow-up, but I was hesitant to delete all the
per-target CHECK lines in this commit since those might serve their own
purpose.
rdar://problem/11811377
llvm-svn: 301593
2017-04-28 05:49:45 +08:00
|
|
|
typedef __INTPTR_TYPE__ intptr_t;
|
2009-02-14 06:43:13 +08:00
|
|
|
#define __intptr_t_defined
|
2010-04-25 04:32:12 +08:00
|
|
|
#define _INTPTR_T
|
2009-02-14 06:43:13 +08:00
|
|
|
#endif
|
2010-04-25 04:32:12 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _UINTPTR_T
|
Headers: Make the type of SIZE_MAX the same as size_t
size_t is usually defined as unsigned long, but on 64-bit platforms,
stdint.h currently defines SIZE_MAX using "ull" (unsigned long long).
Although this is the same width, it doesn't necessarily have the same
alignment or calling convention. It also triggers printf warnings when
using the format flag "%zu" to print SIZE_MAX.
This changes SIZE_MAX to reuse the compiler-provided __SIZE_MAX__, and
provides similar fixes for the other integers:
- INTPTR_MIN
- INTPTR_MAX
- UINTPTR_MAX
- PTRDIFF_MIN
- PTRDIFF_MAX
- INTMAX_MIN
- INTMAX_MAX
- UINTMAX_MAX
- INTMAX_C()
- UINTMAX_C()
... and fixes the typedefs for intptr_t and uintptr_t to use
__INTPTR_TYPE__ and __UINTPTR_TYPE__ instead of int32_t, effectively
reverting r89224, r89226, and r89237 (r89221 already having been
effectively reverted).
We can probably also kill __INTPTR_WIDTH__, __INTMAX_WIDTH__, and
__UINTMAX_WIDTH__ in a follow-up, but I was hesitant to delete all the
per-target CHECK lines in this commit since those might serve their own
purpose.
rdar://problem/11811377
llvm-svn: 301593
2017-04-28 05:49:45 +08:00
|
|
|
typedef __UINTPTR_TYPE__ uintptr_t;
|
2010-04-25 04:32:12 +08:00
|
|
|
#define _UINTPTR_T
|
|
|
|
#endif
|
2009-02-07 06:59:47 +08:00
|
|
|
|
|
|
|
/* C99 7.18.1.5 Greatest-width integer types.
|
|
|
|
*/
|
2010-06-30 14:30:50 +08:00
|
|
|
typedef __INTMAX_TYPE__ intmax_t;
|
|
|
|
typedef __UINTMAX_TYPE__ uintmax_t;
|
2009-02-07 06:59:47 +08:00
|
|
|
|
2009-11-05 07:03:18 +08:00
|
|
|
/* C99 7.18.4 Macros for minimum-width integer constants.
|
2009-11-12 16:08:27 +08:00
|
|
|
*
|
|
|
|
* The standard requires that integer constant macros be defined for all the
|
|
|
|
* minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width
|
2015-09-12 10:55:19 +08:00
|
|
|
* types are required, the corresponding integer constant macros are defined
|
2009-11-12 16:08:27 +08:00
|
|
|
* here. This implementation also defines minimum-width types for every other
|
2015-09-12 10:55:19 +08:00
|
|
|
* integer width that the target implements, so corresponding macros are
|
2009-11-12 16:08:27 +08:00
|
|
|
* defined below, too.
|
|
|
|
*
|
|
|
|
* These macros are defined using the same successive-shrinking approach as
|
|
|
|
* the type definitions above. It is likewise important that macros are defined
|
|
|
|
* in order of decending width.
|
2009-11-05 07:03:18 +08:00
|
|
|
*
|
|
|
|
* Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the
|
|
|
|
* claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).
|
|
|
|
*/
|
|
|
|
|
2009-11-12 16:08:27 +08:00
|
|
|
#define __int_c_join(a, b) a ## b
|
2009-11-17 21:54:02 +08:00
|
|
|
#define __int_c(v, suffix) __int_c_join(v, suffix)
|
|
|
|
#define __uint_c(v, suffix) __int_c_join(v##U, suffix)
|
2009-11-12 16:08:27 +08:00
|
|
|
|
|
|
|
|
2009-11-05 07:03:18 +08:00
|
|
|
#ifdef __INT64_TYPE__
|
2009-11-12 16:08:27 +08:00
|
|
|
# ifdef __INT64_C_SUFFIX__
|
|
|
|
# define __int64_c_suffix __INT64_C_SUFFIX__
|
|
|
|
# define __int32_c_suffix __INT64_C_SUFFIX__
|
|
|
|
# define __int16_c_suffix __INT64_C_SUFFIX__
|
|
|
|
# define __int8_c_suffix __INT64_C_SUFFIX__
|
|
|
|
# else
|
|
|
|
# undef __int64_c_suffix
|
|
|
|
# undef __int32_c_suffix
|
|
|
|
# undef __int16_c_suffix
|
|
|
|
# undef __int8_c_suffix
|
|
|
|
# endif /* __INT64_C_SUFFIX__ */
|
|
|
|
#endif /* __INT64_TYPE__ */
|
|
|
|
|
|
|
|
#ifdef __int_least64_t
|
|
|
|
# ifdef __int64_c_suffix
|
|
|
|
# define INT64_C(v) __int_c(v, __int64_c_suffix)
|
|
|
|
# define UINT64_C(v) __uint_c(v, __int64_c_suffix)
|
|
|
|
# else
|
2009-11-17 21:54:02 +08:00
|
|
|
# define INT64_C(v) v
|
|
|
|
# define UINT64_C(v) v ## U
|
2009-11-12 16:08:27 +08:00
|
|
|
# endif /* __int64_c_suffix */
|
|
|
|
#endif /* __int_least64_t */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT56_TYPE__
|
|
|
|
# ifdef __INT56_C_SUFFIX__
|
|
|
|
# define INT56_C(v) __int_c(v, __INT56_C_SUFFIX__)
|
|
|
|
# define UINT56_C(v) __uint_c(v, __INT56_C_SUFFIX__)
|
|
|
|
# define __int32_c_suffix __INT56_C_SUFFIX__
|
|
|
|
# define __int16_c_suffix __INT56_C_SUFFIX__
|
|
|
|
# define __int8_c_suffix __INT56_C_SUFFIX__
|
|
|
|
# else
|
2009-11-17 21:54:02 +08:00
|
|
|
# define INT56_C(v) v
|
|
|
|
# define UINT56_C(v) v ## U
|
2009-11-12 16:08:27 +08:00
|
|
|
# undef __int32_c_suffix
|
|
|
|
# undef __int16_c_suffix
|
|
|
|
# undef __int8_c_suffix
|
|
|
|
# endif /* __INT56_C_SUFFIX__ */
|
|
|
|
#endif /* __INT56_TYPE__ */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT48_TYPE__
|
|
|
|
# ifdef __INT48_C_SUFFIX__
|
|
|
|
# define INT48_C(v) __int_c(v, __INT48_C_SUFFIX__)
|
|
|
|
# define UINT48_C(v) __uint_c(v, __INT48_C_SUFFIX__)
|
|
|
|
# define __int32_c_suffix __INT48_C_SUFFIX__
|
|
|
|
# define __int16_c_suffix __INT48_C_SUFFIX__
|
|
|
|
# define __int8_c_suffix __INT48_C_SUFFIX__
|
|
|
|
# else
|
2009-11-17 21:54:02 +08:00
|
|
|
# define INT48_C(v) v
|
|
|
|
# define UINT48_C(v) v ## U
|
2009-11-12 16:08:27 +08:00
|
|
|
# undef __int32_c_suffix
|
|
|
|
# undef __int16_c_suffix
|
|
|
|
# undef __int8_c_suffix
|
|
|
|
# endif /* __INT48_C_SUFFIX__ */
|
|
|
|
#endif /* __INT48_TYPE__ */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT40_TYPE__
|
|
|
|
# ifdef __INT40_C_SUFFIX__
|
|
|
|
# define INT40_C(v) __int_c(v, __INT40_C_SUFFIX__)
|
|
|
|
# define UINT40_C(v) __uint_c(v, __INT40_C_SUFFIX__)
|
|
|
|
# define __int32_c_suffix __INT40_C_SUFFIX__
|
|
|
|
# define __int16_c_suffix __INT40_C_SUFFIX__
|
|
|
|
# define __int8_c_suffix __INT40_C_SUFFIX__
|
|
|
|
# else
|
2009-11-17 21:54:02 +08:00
|
|
|
# define INT40_C(v) v
|
|
|
|
# define UINT40_C(v) v ## U
|
2009-11-12 16:08:27 +08:00
|
|
|
# undef __int32_c_suffix
|
|
|
|
# undef __int16_c_suffix
|
|
|
|
# undef __int8_c_suffix
|
|
|
|
# endif /* __INT40_C_SUFFIX__ */
|
|
|
|
#endif /* __INT40_TYPE__ */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT32_TYPE__
|
|
|
|
# ifdef __INT32_C_SUFFIX__
|
|
|
|
# define __int32_c_suffix __INT32_C_SUFFIX__
|
|
|
|
# define __int16_c_suffix __INT32_C_SUFFIX__
|
|
|
|
# define __int8_c_suffix __INT32_C_SUFFIX__
|
|
|
|
#else
|
|
|
|
# undef __int32_c_suffix
|
|
|
|
# undef __int16_c_suffix
|
|
|
|
# undef __int8_c_suffix
|
|
|
|
# endif /* __INT32_C_SUFFIX__ */
|
|
|
|
#endif /* __INT32_TYPE__ */
|
|
|
|
|
|
|
|
#ifdef __int_least32_t
|
|
|
|
# ifdef __int32_c_suffix
|
|
|
|
# define INT32_C(v) __int_c(v, __int32_c_suffix)
|
|
|
|
# define UINT32_C(v) __uint_c(v, __int32_c_suffix)
|
|
|
|
# else
|
2009-11-17 21:54:02 +08:00
|
|
|
# define INT32_C(v) v
|
|
|
|
# define UINT32_C(v) v ## U
|
2009-11-12 16:08:27 +08:00
|
|
|
# endif /* __int32_c_suffix */
|
|
|
|
#endif /* __int_least32_t */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT24_TYPE__
|
|
|
|
# ifdef __INT24_C_SUFFIX__
|
|
|
|
# define INT24_C(v) __int_c(v, __INT24_C_SUFFIX__)
|
|
|
|
# define UINT24_C(v) __uint_c(v, __INT24_C_SUFFIX__)
|
|
|
|
# define __int16_c_suffix __INT24_C_SUFFIX__
|
|
|
|
# define __int8_c_suffix __INT24_C_SUFFIX__
|
|
|
|
# else
|
2009-11-17 21:54:02 +08:00
|
|
|
# define INT24_C(v) v
|
|
|
|
# define UINT24_C(v) v ## U
|
2009-11-12 16:08:27 +08:00
|
|
|
# undef __int16_c_suffix
|
|
|
|
# undef __int8_c_suffix
|
|
|
|
# endif /* __INT24_C_SUFFIX__ */
|
|
|
|
#endif /* __INT24_TYPE__ */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT16_TYPE__
|
|
|
|
# ifdef __INT16_C_SUFFIX__
|
|
|
|
# define __int16_c_suffix __INT16_C_SUFFIX__
|
|
|
|
# define __int8_c_suffix __INT16_C_SUFFIX__
|
|
|
|
#else
|
|
|
|
# undef __int16_c_suffix
|
|
|
|
# undef __int8_c_suffix
|
|
|
|
# endif /* __INT16_C_SUFFIX__ */
|
|
|
|
#endif /* __INT16_TYPE__ */
|
|
|
|
|
|
|
|
#ifdef __int_least16_t
|
|
|
|
# ifdef __int16_c_suffix
|
|
|
|
# define INT16_C(v) __int_c(v, __int16_c_suffix)
|
|
|
|
# define UINT16_C(v) __uint_c(v, __int16_c_suffix)
|
|
|
|
# else
|
2009-11-17 21:54:02 +08:00
|
|
|
# define INT16_C(v) v
|
|
|
|
# define UINT16_C(v) v ## U
|
2009-11-12 16:08:27 +08:00
|
|
|
# endif /* __int16_c_suffix */
|
|
|
|
#endif /* __int_least16_t */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT8_TYPE__
|
|
|
|
# ifdef __INT8_C_SUFFIX__
|
|
|
|
# define __int8_c_suffix __INT8_C_SUFFIX__
|
|
|
|
#else
|
|
|
|
# undef __int8_c_suffix
|
|
|
|
# endif /* __INT8_C_SUFFIX__ */
|
|
|
|
#endif /* __INT8_TYPE__ */
|
|
|
|
|
|
|
|
#ifdef __int_least8_t
|
|
|
|
# ifdef __int8_c_suffix
|
|
|
|
# define INT8_C(v) __int_c(v, __int8_c_suffix)
|
|
|
|
# define UINT8_C(v) __uint_c(v, __int8_c_suffix)
|
|
|
|
# else
|
2009-11-17 21:54:02 +08:00
|
|
|
# define INT8_C(v) v
|
|
|
|
# define UINT8_C(v) v ## U
|
2009-11-12 16:08:27 +08:00
|
|
|
# endif /* __int8_c_suffix */
|
|
|
|
#endif /* __int_least8_t */
|
2009-11-05 07:03:18 +08:00
|
|
|
|
|
|
|
|
2015-09-12 10:55:19 +08:00
|
|
|
/* C99 7.18.2.1 Limits of exact-width integer types.
|
2009-02-07 06:59:47 +08:00
|
|
|
* C99 7.18.2.2 Limits of minimum-width integer types.
|
|
|
|
* C99 7.18.2.3 Limits of fastest minimum-width integer types.
|
2009-02-08 06:21:31 +08:00
|
|
|
*
|
2009-11-12 16:08:27 +08:00
|
|
|
* The presence of limit macros are completely optional in C99. This
|
|
|
|
* implementation defines limits for all of the types (exact- and
|
|
|
|
* minimum-width) that it defines above, using the limits of the minimum-width
|
|
|
|
* type for any types that do not have exact-width representations.
|
|
|
|
*
|
|
|
|
* As in the type definitions, this section takes an approach of
|
|
|
|
* successive-shrinking to determine which limits to use for the standard (8,
|
|
|
|
* 16, 32, 64) bit widths when they don't have exact representations. It is
|
2018-04-06 23:14:32 +08:00
|
|
|
* therefore important that the definitions be kept in order of decending
|
2009-11-12 16:08:27 +08:00
|
|
|
* widths.
|
|
|
|
*
|
2009-02-08 06:21:31 +08:00
|
|
|
* Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the
|
|
|
|
* claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).
|
2009-02-07 06:59:47 +08:00
|
|
|
*/
|
|
|
|
|
2009-03-01 02:53:33 +08:00
|
|
|
#ifdef __INT64_TYPE__
|
2009-11-18 00:26:27 +08:00
|
|
|
# define INT64_MAX INT64_C( 9223372036854775807)
|
|
|
|
# define INT64_MIN (-INT64_C( 9223372036854775807)-1)
|
|
|
|
# define UINT64_MAX UINT64_C(18446744073709551615)
|
2009-11-12 16:08:27 +08:00
|
|
|
# define __INT_LEAST64_MIN INT64_MIN
|
|
|
|
# define __INT_LEAST64_MAX INT64_MAX
|
|
|
|
# define __UINT_LEAST64_MAX UINT64_MAX
|
|
|
|
# define __INT_LEAST32_MIN INT64_MIN
|
|
|
|
# define __INT_LEAST32_MAX INT64_MAX
|
|
|
|
# define __UINT_LEAST32_MAX UINT64_MAX
|
|
|
|
# define __INT_LEAST16_MIN INT64_MIN
|
|
|
|
# define __INT_LEAST16_MAX INT64_MAX
|
|
|
|
# define __UINT_LEAST16_MAX UINT64_MAX
|
|
|
|
# define __INT_LEAST8_MIN INT64_MIN
|
|
|
|
# define __INT_LEAST8_MAX INT64_MAX
|
|
|
|
# define __UINT_LEAST8_MAX UINT64_MAX
|
|
|
|
#endif /* __INT64_TYPE__ */
|
|
|
|
|
|
|
|
#ifdef __INT_LEAST64_MIN
|
|
|
|
# define INT_LEAST64_MIN __INT_LEAST64_MIN
|
|
|
|
# define INT_LEAST64_MAX __INT_LEAST64_MAX
|
|
|
|
# define UINT_LEAST64_MAX __UINT_LEAST64_MAX
|
|
|
|
# define INT_FAST64_MIN __INT_LEAST64_MIN
|
|
|
|
# define INT_FAST64_MAX __INT_LEAST64_MAX
|
|
|
|
# define UINT_FAST64_MAX __UINT_LEAST64_MAX
|
|
|
|
#endif /* __INT_LEAST64_MIN */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT56_TYPE__
|
2009-11-18 00:26:27 +08:00
|
|
|
# define INT56_MAX INT56_C(36028797018963967)
|
|
|
|
# define INT56_MIN (-INT56_C(36028797018963967)-1)
|
|
|
|
# define UINT56_MAX UINT56_C(72057594037927935)
|
2009-11-12 16:08:27 +08:00
|
|
|
# define INT_LEAST56_MIN INT56_MIN
|
|
|
|
# define INT_LEAST56_MAX INT56_MAX
|
|
|
|
# define UINT_LEAST56_MAX UINT56_MAX
|
|
|
|
# define INT_FAST56_MIN INT56_MIN
|
|
|
|
# define INT_FAST56_MAX INT56_MAX
|
|
|
|
# define UINT_FAST56_MAX UINT56_MAX
|
|
|
|
# define __INT_LEAST32_MIN INT56_MIN
|
|
|
|
# define __INT_LEAST32_MAX INT56_MAX
|
|
|
|
# define __UINT_LEAST32_MAX UINT56_MAX
|
|
|
|
# define __INT_LEAST16_MIN INT56_MIN
|
|
|
|
# define __INT_LEAST16_MAX INT56_MAX
|
|
|
|
# define __UINT_LEAST16_MAX UINT56_MAX
|
|
|
|
# define __INT_LEAST8_MIN INT56_MIN
|
|
|
|
# define __INT_LEAST8_MAX INT56_MAX
|
|
|
|
# define __UINT_LEAST8_MAX UINT56_MAX
|
|
|
|
#endif /* __INT56_TYPE__ */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT48_TYPE__
|
2009-11-18 00:26:27 +08:00
|
|
|
# define INT48_MAX INT48_C(140737488355327)
|
|
|
|
# define INT48_MIN (-INT48_C(140737488355327)-1)
|
|
|
|
# define UINT48_MAX UINT48_C(281474976710655)
|
2009-11-12 16:08:27 +08:00
|
|
|
# define INT_LEAST48_MIN INT48_MIN
|
|
|
|
# define INT_LEAST48_MAX INT48_MAX
|
|
|
|
# define UINT_LEAST48_MAX UINT48_MAX
|
|
|
|
# define INT_FAST48_MIN INT48_MIN
|
|
|
|
# define INT_FAST48_MAX INT48_MAX
|
|
|
|
# define UINT_FAST48_MAX UINT48_MAX
|
|
|
|
# define __INT_LEAST32_MIN INT48_MIN
|
|
|
|
# define __INT_LEAST32_MAX INT48_MAX
|
|
|
|
# define __UINT_LEAST32_MAX UINT48_MAX
|
|
|
|
# define __INT_LEAST16_MIN INT48_MIN
|
|
|
|
# define __INT_LEAST16_MAX INT48_MAX
|
|
|
|
# define __UINT_LEAST16_MAX UINT48_MAX
|
|
|
|
# define __INT_LEAST8_MIN INT48_MIN
|
|
|
|
# define __INT_LEAST8_MAX INT48_MAX
|
|
|
|
# define __UINT_LEAST8_MAX UINT48_MAX
|
|
|
|
#endif /* __INT48_TYPE__ */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT40_TYPE__
|
2009-11-18 00:26:27 +08:00
|
|
|
# define INT40_MAX INT40_C(549755813887)
|
|
|
|
# define INT40_MIN (-INT40_C(549755813887)-1)
|
|
|
|
# define UINT40_MAX UINT40_C(1099511627775)
|
2009-11-12 16:08:27 +08:00
|
|
|
# define INT_LEAST40_MIN INT40_MIN
|
|
|
|
# define INT_LEAST40_MAX INT40_MAX
|
|
|
|
# define UINT_LEAST40_MAX UINT40_MAX
|
|
|
|
# define INT_FAST40_MIN INT40_MIN
|
|
|
|
# define INT_FAST40_MAX INT40_MAX
|
|
|
|
# define UINT_FAST40_MAX UINT40_MAX
|
|
|
|
# define __INT_LEAST32_MIN INT40_MIN
|
|
|
|
# define __INT_LEAST32_MAX INT40_MAX
|
|
|
|
# define __UINT_LEAST32_MAX UINT40_MAX
|
|
|
|
# define __INT_LEAST16_MIN INT40_MIN
|
|
|
|
# define __INT_LEAST16_MAX INT40_MAX
|
|
|
|
# define __UINT_LEAST16_MAX UINT40_MAX
|
|
|
|
# define __INT_LEAST8_MIN INT40_MIN
|
|
|
|
# define __INT_LEAST8_MAX INT40_MAX
|
|
|
|
# define __UINT_LEAST8_MAX UINT40_MAX
|
|
|
|
#endif /* __INT40_TYPE__ */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT32_TYPE__
|
2009-11-18 00:26:27 +08:00
|
|
|
# define INT32_MAX INT32_C(2147483647)
|
|
|
|
# define INT32_MIN (-INT32_C(2147483647)-1)
|
|
|
|
# define UINT32_MAX UINT32_C(4294967295)
|
2009-11-12 16:08:27 +08:00
|
|
|
# define __INT_LEAST32_MIN INT32_MIN
|
|
|
|
# define __INT_LEAST32_MAX INT32_MAX
|
|
|
|
# define __UINT_LEAST32_MAX UINT32_MAX
|
|
|
|
# define __INT_LEAST16_MIN INT32_MIN
|
|
|
|
# define __INT_LEAST16_MAX INT32_MAX
|
|
|
|
# define __UINT_LEAST16_MAX UINT32_MAX
|
|
|
|
# define __INT_LEAST8_MIN INT32_MIN
|
|
|
|
# define __INT_LEAST8_MAX INT32_MAX
|
|
|
|
# define __UINT_LEAST8_MAX UINT32_MAX
|
|
|
|
#endif /* __INT32_TYPE__ */
|
|
|
|
|
|
|
|
#ifdef __INT_LEAST32_MIN
|
|
|
|
# define INT_LEAST32_MIN __INT_LEAST32_MIN
|
|
|
|
# define INT_LEAST32_MAX __INT_LEAST32_MAX
|
|
|
|
# define UINT_LEAST32_MAX __UINT_LEAST32_MAX
|
|
|
|
# define INT_FAST32_MIN __INT_LEAST32_MIN
|
|
|
|
# define INT_FAST32_MAX __INT_LEAST32_MAX
|
|
|
|
# define UINT_FAST32_MAX __UINT_LEAST32_MAX
|
|
|
|
#endif /* __INT_LEAST32_MIN */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT24_TYPE__
|
2009-11-18 00:26:27 +08:00
|
|
|
# define INT24_MAX INT24_C(8388607)
|
2009-11-18 02:29:12 +08:00
|
|
|
# define INT24_MIN (-INT24_C(8388607)-1)
|
2009-11-18 00:26:27 +08:00
|
|
|
# define UINT24_MAX UINT24_C(16777215)
|
2009-11-12 16:08:27 +08:00
|
|
|
# define INT_LEAST24_MIN INT24_MIN
|
|
|
|
# define INT_LEAST24_MAX INT24_MAX
|
|
|
|
# define UINT_LEAST24_MAX UINT24_MAX
|
|
|
|
# define INT_FAST24_MIN INT24_MIN
|
|
|
|
# define INT_FAST24_MAX INT24_MAX
|
|
|
|
# define UINT_FAST24_MAX UINT24_MAX
|
|
|
|
# define __INT_LEAST16_MIN INT24_MIN
|
|
|
|
# define __INT_LEAST16_MAX INT24_MAX
|
|
|
|
# define __UINT_LEAST16_MAX UINT24_MAX
|
|
|
|
# define __INT_LEAST8_MIN INT24_MIN
|
|
|
|
# define __INT_LEAST8_MAX INT24_MAX
|
|
|
|
# define __UINT_LEAST8_MAX UINT24_MAX
|
|
|
|
#endif /* __INT24_TYPE__ */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT16_TYPE__
|
2009-11-18 00:26:27 +08:00
|
|
|
#define INT16_MAX INT16_C(32767)
|
2009-11-18 02:29:12 +08:00
|
|
|
#define INT16_MIN (-INT16_C(32767)-1)
|
2009-11-18 00:26:27 +08:00
|
|
|
#define UINT16_MAX UINT16_C(65535)
|
2009-11-12 16:08:27 +08:00
|
|
|
# define __INT_LEAST16_MIN INT16_MIN
|
|
|
|
# define __INT_LEAST16_MAX INT16_MAX
|
|
|
|
# define __UINT_LEAST16_MAX UINT16_MAX
|
|
|
|
# define __INT_LEAST8_MIN INT16_MIN
|
|
|
|
# define __INT_LEAST8_MAX INT16_MAX
|
|
|
|
# define __UINT_LEAST8_MAX UINT16_MAX
|
|
|
|
#endif /* __INT16_TYPE__ */
|
|
|
|
|
|
|
|
#ifdef __INT_LEAST16_MIN
|
|
|
|
# define INT_LEAST16_MIN __INT_LEAST16_MIN
|
|
|
|
# define INT_LEAST16_MAX __INT_LEAST16_MAX
|
|
|
|
# define UINT_LEAST16_MAX __UINT_LEAST16_MAX
|
|
|
|
# define INT_FAST16_MIN __INT_LEAST16_MIN
|
|
|
|
# define INT_FAST16_MAX __INT_LEAST16_MAX
|
|
|
|
# define UINT_FAST16_MAX __UINT_LEAST16_MAX
|
|
|
|
#endif /* __INT_LEAST16_MIN */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __INT8_TYPE__
|
2009-11-18 00:26:27 +08:00
|
|
|
# define INT8_MAX INT8_C(127)
|
2009-11-18 02:29:12 +08:00
|
|
|
# define INT8_MIN (-INT8_C(127)-1)
|
2009-11-18 00:26:27 +08:00
|
|
|
# define UINT8_MAX UINT8_C(255)
|
2009-11-12 16:08:27 +08:00
|
|
|
# define __INT_LEAST8_MIN INT8_MIN
|
|
|
|
# define __INT_LEAST8_MAX INT8_MAX
|
|
|
|
# define __UINT_LEAST8_MAX UINT8_MAX
|
|
|
|
#endif /* __INT8_TYPE__ */
|
2009-02-07 06:59:47 +08:00
|
|
|
|
2009-11-12 16:08:27 +08:00
|
|
|
#ifdef __INT_LEAST8_MIN
|
|
|
|
# define INT_LEAST8_MIN __INT_LEAST8_MIN
|
|
|
|
# define INT_LEAST8_MAX __INT_LEAST8_MAX
|
|
|
|
# define UINT_LEAST8_MAX __UINT_LEAST8_MAX
|
|
|
|
# define INT_FAST8_MIN __INT_LEAST8_MIN
|
|
|
|
# define INT_FAST8_MAX __INT_LEAST8_MAX
|
|
|
|
# define UINT_FAST8_MAX __UINT_LEAST8_MAX
|
|
|
|
#endif /* __INT_LEAST8_MIN */
|
2009-11-05 07:03:18 +08:00
|
|
|
|
2011-05-01 03:02:59 +08:00
|
|
|
/* Some utility macros */
|
|
|
|
#define __INTN_MIN(n) __stdint_join3( INT, n, _MIN)
|
|
|
|
#define __INTN_MAX(n) __stdint_join3( INT, n, _MAX)
|
|
|
|
#define __UINTN_MAX(n) __stdint_join3(UINT, n, _MAX)
|
|
|
|
#define __INTN_C(n, v) __stdint_join3( INT, n, _C(v))
|
|
|
|
#define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v))
|
|
|
|
|
2009-02-07 06:59:47 +08:00
|
|
|
/* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */
|
|
|
|
/* C99 7.18.3 Limits of other integer types. */
|
|
|
|
|
Headers: Make the type of SIZE_MAX the same as size_t
size_t is usually defined as unsigned long, but on 64-bit platforms,
stdint.h currently defines SIZE_MAX using "ull" (unsigned long long).
Although this is the same width, it doesn't necessarily have the same
alignment or calling convention. It also triggers printf warnings when
using the format flag "%zu" to print SIZE_MAX.
This changes SIZE_MAX to reuse the compiler-provided __SIZE_MAX__, and
provides similar fixes for the other integers:
- INTPTR_MIN
- INTPTR_MAX
- UINTPTR_MAX
- PTRDIFF_MIN
- PTRDIFF_MAX
- INTMAX_MIN
- INTMAX_MAX
- UINTMAX_MAX
- INTMAX_C()
- UINTMAX_C()
... and fixes the typedefs for intptr_t and uintptr_t to use
__INTPTR_TYPE__ and __UINTPTR_TYPE__ instead of int32_t, effectively
reverting r89224, r89226, and r89237 (r89221 already having been
effectively reverted).
We can probably also kill __INTPTR_WIDTH__, __INTMAX_WIDTH__, and
__UINTMAX_WIDTH__ in a follow-up, but I was hesitant to delete all the
per-target CHECK lines in this commit since those might serve their own
purpose.
rdar://problem/11811377
llvm-svn: 301593
2017-04-28 05:49:45 +08:00
|
|
|
#define INTPTR_MIN (-__INTPTR_MAX__-1)
|
|
|
|
#define INTPTR_MAX __INTPTR_MAX__
|
|
|
|
#define UINTPTR_MAX __UINTPTR_MAX__
|
|
|
|
#define PTRDIFF_MIN (-__PTRDIFF_MAX__-1)
|
|
|
|
#define PTRDIFF_MAX __PTRDIFF_MAX__
|
|
|
|
#define SIZE_MAX __SIZE_MAX__
|
2009-02-07 06:59:47 +08:00
|
|
|
|
2013-04-13 07:24:56 +08:00
|
|
|
/* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__
|
|
|
|
* is enabled. */
|
|
|
|
#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
|
|
|
|
#define RSIZE_MAX (SIZE_MAX >> 1)
|
|
|
|
#endif
|
|
|
|
|
2009-02-07 06:59:47 +08:00
|
|
|
/* C99 7.18.2.5 Limits of greatest-width integer types. */
|
Headers: Make the type of SIZE_MAX the same as size_t
size_t is usually defined as unsigned long, but on 64-bit platforms,
stdint.h currently defines SIZE_MAX using "ull" (unsigned long long).
Although this is the same width, it doesn't necessarily have the same
alignment or calling convention. It also triggers printf warnings when
using the format flag "%zu" to print SIZE_MAX.
This changes SIZE_MAX to reuse the compiler-provided __SIZE_MAX__, and
provides similar fixes for the other integers:
- INTPTR_MIN
- INTPTR_MAX
- UINTPTR_MAX
- PTRDIFF_MIN
- PTRDIFF_MAX
- INTMAX_MIN
- INTMAX_MAX
- UINTMAX_MAX
- INTMAX_C()
- UINTMAX_C()
... and fixes the typedefs for intptr_t and uintptr_t to use
__INTPTR_TYPE__ and __UINTPTR_TYPE__ instead of int32_t, effectively
reverting r89224, r89226, and r89237 (r89221 already having been
effectively reverted).
We can probably also kill __INTPTR_WIDTH__, __INTMAX_WIDTH__, and
__UINTMAX_WIDTH__ in a follow-up, but I was hesitant to delete all the
per-target CHECK lines in this commit since those might serve their own
purpose.
rdar://problem/11811377
llvm-svn: 301593
2017-04-28 05:49:45 +08:00
|
|
|
#define INTMAX_MIN (-__INTMAX_MAX__-1)
|
|
|
|
#define INTMAX_MAX __INTMAX_MAX__
|
|
|
|
#define UINTMAX_MAX __UINTMAX_MAX__
|
2009-02-07 06:59:47 +08:00
|
|
|
|
|
|
|
/* C99 7.18.3 Limits of other integer types. */
|
2009-11-22 23:47:12 +08:00
|
|
|
#define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__)
|
|
|
|
#define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__)
|
2011-04-21 13:45:45 +08:00
|
|
|
#ifdef __WINT_UNSIGNED__
|
2011-05-01 03:02:59 +08:00
|
|
|
# define WINT_MIN __UINTN_C(__WINT_WIDTH__, 0)
|
2011-04-21 13:45:45 +08:00
|
|
|
# define WINT_MAX __UINTN_MAX(__WINT_WIDTH__)
|
|
|
|
#else
|
|
|
|
# define WINT_MIN __INTN_MIN(__WINT_WIDTH__)
|
|
|
|
# define WINT_MAX __INTN_MAX(__WINT_WIDTH__)
|
|
|
|
#endif
|
2009-02-07 06:59:47 +08:00
|
|
|
|
|
|
|
#ifndef WCHAR_MAX
|
2011-05-01 03:02:59 +08:00
|
|
|
# define WCHAR_MAX __WCHAR_MAX__
|
2009-02-07 06:59:47 +08:00
|
|
|
#endif
|
|
|
|
#ifndef WCHAR_MIN
|
2011-05-01 03:02:59 +08:00
|
|
|
# if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__)
|
|
|
|
# define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__)
|
|
|
|
# else
|
|
|
|
# define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0)
|
|
|
|
# endif
|
2009-02-07 06:59:47 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* 7.18.4.2 Macros for greatest-width integer constants. */
|
Headers: Make the type of SIZE_MAX the same as size_t
size_t is usually defined as unsigned long, but on 64-bit platforms,
stdint.h currently defines SIZE_MAX using "ull" (unsigned long long).
Although this is the same width, it doesn't necessarily have the same
alignment or calling convention. It also triggers printf warnings when
using the format flag "%zu" to print SIZE_MAX.
This changes SIZE_MAX to reuse the compiler-provided __SIZE_MAX__, and
provides similar fixes for the other integers:
- INTPTR_MIN
- INTPTR_MAX
- UINTPTR_MAX
- PTRDIFF_MIN
- PTRDIFF_MAX
- INTMAX_MIN
- INTMAX_MAX
- UINTMAX_MAX
- INTMAX_C()
- UINTMAX_C()
... and fixes the typedefs for intptr_t and uintptr_t to use
__INTPTR_TYPE__ and __UINTPTR_TYPE__ instead of int32_t, effectively
reverting r89224, r89226, and r89237 (r89221 already having been
effectively reverted).
We can probably also kill __INTPTR_WIDTH__, __INTMAX_WIDTH__, and
__UINTMAX_WIDTH__ in a follow-up, but I was hesitant to delete all the
per-target CHECK lines in this commit since those might serve their own
purpose.
rdar://problem/11811377
llvm-svn: 301593
2017-04-28 05:49:45 +08:00
|
|
|
#define INTMAX_C(v) __int_c(v, __INTMAX_C_SUFFIX__)
|
|
|
|
#define UINTMAX_C(v) __int_c(v, __UINTMAX_C_SUFFIX__)
|
2009-02-07 06:59:47 +08:00
|
|
|
|
2009-05-04 07:00:48 +08:00
|
|
|
#endif /* __STDC_HOSTED__ */
|
|
|
|
#endif /* __CLANG_STDINT_H */
|