Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*===---- limits.h - Standard header for integer sizes --------------------===*\
  2.  *
  3.  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4.  * See https://llvm.org/LICENSE.txt for license information.
  5.  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6.  *
  7. \*===----------------------------------------------------------------------===*/
  8.  
  9. #ifndef __CLANG_LIMITS_H
  10. #define __CLANG_LIMITS_H
  11.  
  12. /* The system's limits.h may, in turn, try to #include_next GCC's limits.h.
  13.    Avert this #include_next madness. */
  14. #if defined __GNUC__ && !defined _GCC_LIMITS_H_
  15. #define _GCC_LIMITS_H_
  16. #endif
  17.  
  18. /* System headers include a number of constants from POSIX in <limits.h>.
  19.    Include it if we're hosted. */
  20. #if __STDC_HOSTED__ && __has_include_next(<limits.h>)
  21. #include_next <limits.h>
  22. #endif
  23.  
  24. /* Many system headers try to "help us out" by defining these.  No really, we
  25.    know how big each datatype is. */
  26. #undef  SCHAR_MIN
  27. #undef  SCHAR_MAX
  28. #undef  UCHAR_MAX
  29. #undef  SHRT_MIN
  30. #undef  SHRT_MAX
  31. #undef  USHRT_MAX
  32. #undef  INT_MIN
  33. #undef  INT_MAX
  34. #undef  UINT_MAX
  35. #undef  LONG_MIN
  36. #undef  LONG_MAX
  37. #undef  ULONG_MAX
  38.  
  39. #undef  CHAR_BIT
  40. #undef  CHAR_MIN
  41. #undef  CHAR_MAX
  42.  
  43. /* C90/99 5.2.4.2.1 */
  44. #define SCHAR_MAX __SCHAR_MAX__
  45. #define SHRT_MAX  __SHRT_MAX__
  46. #define INT_MAX   __INT_MAX__
  47. #define LONG_MAX  __LONG_MAX__
  48.  
  49. #define SCHAR_MIN (-__SCHAR_MAX__-1)
  50. #define SHRT_MIN  (-__SHRT_MAX__ -1)
  51. #define INT_MIN   (-__INT_MAX__  -1)
  52. #define LONG_MIN  (-__LONG_MAX__ -1L)
  53.  
  54. #define UCHAR_MAX (__SCHAR_MAX__*2  +1)
  55. #define USHRT_MAX (__SHRT_MAX__ *2  +1)
  56. #define UINT_MAX  (__INT_MAX__  *2U +1U)
  57. #define ULONG_MAX (__LONG_MAX__ *2UL+1UL)
  58.  
  59. #ifndef MB_LEN_MAX
  60. #define MB_LEN_MAX 1
  61. #endif
  62.  
  63. #define CHAR_BIT  __CHAR_BIT__
  64.  
  65. /* C2x 5.2.4.2.1 */
  66. /* FIXME: This is using the placeholder dates Clang produces for these macros
  67.    in C2x mode; switch to the correct values once they've been published. */
  68. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
  69. #define BOOL_WIDTH   __BOOL_WIDTH__
  70. #define CHAR_WIDTH   CHAR_BIT
  71. #define SCHAR_WIDTH  CHAR_BIT
  72. #define UCHAR_WIDTH  CHAR_BIT
  73. #define USHRT_WIDTH  __SHRT_WIDTH__
  74. #define SHRT_WIDTH   __SHRT_WIDTH__
  75. #define UINT_WIDTH   __INT_WIDTH__
  76. #define INT_WIDTH    __INT_WIDTH__
  77. #define ULONG_WIDTH  __LONG_WIDTH__
  78. #define LONG_WIDTH   __LONG_WIDTH__
  79. #define ULLONG_WIDTH __LLONG_WIDTH__
  80. #define LLONG_WIDTH  __LLONG_WIDTH__
  81.  
  82. #define BITINT_MAXWIDTH __BITINT_MAXWIDTH__
  83. #endif
  84.  
  85. #ifdef __CHAR_UNSIGNED__  /* -funsigned-char */
  86. #define CHAR_MIN 0
  87. #define CHAR_MAX UCHAR_MAX
  88. #else
  89. #define CHAR_MIN SCHAR_MIN
  90. #define CHAR_MAX __SCHAR_MAX__
  91. #endif
  92.  
  93. /* C99 5.2.4.2.1: Added long long.
  94.    C++11 18.3.3.2: same contents as the Standard C Library header <limits.h>.
  95.  */
  96. #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) ||              \
  97.     (defined(__cplusplus) && __cplusplus >= 201103L)
  98.  
  99. #undef  LLONG_MIN
  100. #undef  LLONG_MAX
  101. #undef  ULLONG_MAX
  102.  
  103. #define LLONG_MAX  __LONG_LONG_MAX__
  104. #define LLONG_MIN  (-__LONG_LONG_MAX__-1LL)
  105. #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
  106. #endif
  107.  
  108. /* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension.  It's too bad
  109.    that we don't have something like #pragma poison that could be used to
  110.    deprecate a macro - the code should just use LLONG_MAX and friends.
  111.  */
  112. #if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)
  113.  
  114. #undef   LONG_LONG_MIN
  115. #undef   LONG_LONG_MAX
  116. #undef   ULONG_LONG_MAX
  117.  
  118. #define LONG_LONG_MAX  __LONG_LONG_MAX__
  119. #define LONG_LONG_MIN  (-__LONG_LONG_MAX__-1LL)
  120. #define ULONG_LONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
  121. #endif
  122.  
  123. #endif /* __CLANG_LIMITS_H */
  124.