2009-02-07 02:45:59 +08:00
|
|
|
/*===---- limits.h - Standard header for integer sizes --------------------===*\
|
2009-02-07 02:34:27 +08:00
|
|
|
*
|
2019-04-09 04:51:30 +08:00
|
|
|
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
* See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2009-02-07 02:34:27 +08:00
|
|
|
*
|
2009-02-07 06:59:47 +08:00
|
|
|
\*===----------------------------------------------------------------------===*/
|
2009-02-07 02:34:27 +08:00
|
|
|
|
2009-02-13 07:06:31 +08:00
|
|
|
#ifndef __CLANG_LIMITS_H
|
|
|
|
#define __CLANG_LIMITS_H
|
|
|
|
|
|
|
|
/* The system's limits.h may, in turn, try to #include_next GCC's limits.h.
|
|
|
|
Avert this #include_next madness. */
|
|
|
|
#if defined __GNUC__ && !defined _GCC_LIMITS_H_
|
|
|
|
#define _GCC_LIMITS_H_
|
|
|
|
#endif
|
2009-02-07 02:34:27 +08:00
|
|
|
|
2010-11-16 18:07:43 +08:00
|
|
|
/* System headers include a number of constants from POSIX in <limits.h>.
|
|
|
|
Include it if we're hosted. */
|
2014-02-20 06:53:42 +08:00
|
|
|
#if __STDC_HOSTED__ && __has_include_next(<limits.h>)
|
2009-02-07 02:34:27 +08:00
|
|
|
#include_next <limits.h>
|
2010-11-16 18:07:43 +08:00
|
|
|
#endif
|
2009-02-07 02:34:27 +08:00
|
|
|
|
|
|
|
/* Many system headers try to "help us out" by defining these. No really, we
|
|
|
|
know how big each datatype is. */
|
|
|
|
#undef SCHAR_MIN
|
|
|
|
#undef SCHAR_MAX
|
|
|
|
#undef UCHAR_MAX
|
|
|
|
#undef SHRT_MIN
|
|
|
|
#undef SHRT_MAX
|
|
|
|
#undef USHRT_MAX
|
|
|
|
#undef INT_MIN
|
|
|
|
#undef INT_MAX
|
|
|
|
#undef UINT_MAX
|
|
|
|
#undef LONG_MIN
|
|
|
|
#undef LONG_MAX
|
|
|
|
#undef ULONG_MAX
|
|
|
|
|
|
|
|
#undef CHAR_BIT
|
|
|
|
#undef CHAR_MIN
|
|
|
|
#undef CHAR_MAX
|
|
|
|
|
|
|
|
/* C90/99 5.2.4.2.1 */
|
|
|
|
#define SCHAR_MAX __SCHAR_MAX__
|
|
|
|
#define SHRT_MAX __SHRT_MAX__
|
|
|
|
#define INT_MAX __INT_MAX__
|
|
|
|
#define LONG_MAX __LONG_MAX__
|
|
|
|
|
|
|
|
#define SCHAR_MIN (-__SCHAR_MAX__-1)
|
|
|
|
#define SHRT_MIN (-__SHRT_MAX__ -1)
|
|
|
|
#define INT_MIN (-__INT_MAX__ -1)
|
|
|
|
#define LONG_MIN (-__LONG_MAX__ -1L)
|
|
|
|
|
|
|
|
#define UCHAR_MAX (__SCHAR_MAX__*2 +1)
|
|
|
|
#define USHRT_MAX (__SHRT_MAX__ *2 +1)
|
|
|
|
#define UINT_MAX (__INT_MAX__ *2U +1U)
|
|
|
|
#define ULONG_MAX (__LONG_MAX__ *2UL+1UL)
|
|
|
|
|
2009-02-07 07:29:39 +08:00
|
|
|
#ifndef MB_LEN_MAX
|
2009-02-07 02:34:27 +08:00
|
|
|
#define MB_LEN_MAX 1
|
2009-02-07 07:29:39 +08:00
|
|
|
#endif
|
|
|
|
|
2009-02-07 02:34:27 +08:00
|
|
|
#define CHAR_BIT __CHAR_BIT__
|
|
|
|
|
|
|
|
#ifdef __CHAR_UNSIGNED__ /* -funsigned-char */
|
2009-02-07 07:29:39 +08:00
|
|
|
#define CHAR_MIN 0
|
2009-02-07 02:34:27 +08:00
|
|
|
#define CHAR_MAX UCHAR_MAX
|
|
|
|
#else
|
|
|
|
#define CHAR_MIN SCHAR_MIN
|
|
|
|
#define CHAR_MAX __SCHAR_MAX__
|
|
|
|
#endif
|
|
|
|
|
2013-10-28 03:00:49 +08:00
|
|
|
/* C99 5.2.4.2.1: Added long long.
|
|
|
|
C++11 18.3.3.2: same contents as the Standard C Library header <limits.h>.
|
|
|
|
*/
|
2014-02-20 07:38:18 +08:00
|
|
|
#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
|
2009-02-07 02:34:27 +08:00
|
|
|
|
|
|
|
#undef LLONG_MIN
|
|
|
|
#undef LLONG_MAX
|
|
|
|
#undef ULLONG_MAX
|
|
|
|
|
|
|
|
#define LLONG_MAX __LONG_LONG_MAX__
|
|
|
|
#define LLONG_MIN (-__LONG_LONG_MAX__-1LL)
|
|
|
|
#define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
|
|
|
|
#endif
|
|
|
|
|
2009-04-01 08:44:37 +08:00
|
|
|
/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. It's too bad
|
|
|
|
that we don't have something like #pragma poison that could be used to
|
|
|
|
deprecate a macro - the code should just use LLONG_MAX and friends.
|
|
|
|
*/
|
|
|
|
#if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)
|
|
|
|
|
|
|
|
#undef LONG_LONG_MIN
|
|
|
|
#undef LONG_LONG_MAX
|
|
|
|
#undef ULONG_LONG_MAX
|
|
|
|
|
|
|
|
#define LONG_LONG_MAX __LONG_LONG_MAX__
|
|
|
|
#define LONG_LONG_MIN (-__LONG_LONG_MAX__-1LL)
|
|
|
|
#define ULONG_LONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
|
|
|
|
#endif
|
|
|
|
|
2009-02-13 07:06:31 +08:00
|
|
|
#endif /* __CLANG_LIMITS_H */
|