limits.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public License as
  5. published by the Free Software Foundation; either version 2 of the
  6. License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with the GNU C Library; see the file COPYING.LIB. If
  13. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  14. Cambridge, MA 02139, USA. */
  15. /*
  16. * ANSI Standard: 4.14/2.2.4.2 Limits of integral types <limits.h>
  17. */
  18. #ifndef _LIMITS_H
  19. #define _LIMITS_H 1
  20. #include <features.h>
  21. #ifdef __USE_POSIX
  22. /* POSIX adds things to <limits.h>. */
  23. #include <posix1_lim.h>
  24. #endif
  25. #ifdef __USE_POSIX2
  26. #include <posix2_lim.h>
  27. #endif
  28. /* Only if gcc 2.x is used and -traditional is not used, we can use
  29. * #include_next.
  30. #if __GNUC__ >= 2 && __STDC__
  31. */
  32. #if __GNUC__ >= 2
  33. /* Have we done that? */
  34. # if !defined(_GCC_LIMITS_H_) && !defined(_GCC_LIMITS_H)
  35. /* Get the compiler's limits.h, which defines all the ANSI
  36. * constants.
  37. */
  38. /* This tells it not to look for another. */
  39. # define _LIBC_LIMITS_H
  40. # define _LIBC_LIMITS_H_
  41. # include_next <limits.h>
  42. # endif
  43. #else /* Not GCC 2. */
  44. /* We don't have #include_next.
  45. Define ANSI <limits.h> for standard 32-bit words. */
  46. /* These assume 8-bit `char's, 16-bit `short int's,
  47. and 32-bit `int's and `long int's. */
  48. /* Number of bits in a `char'. */
  49. #define CHAR_BIT 8
  50. /* Maximum length of any multibyte character in any locale.
  51. Locale-writers should change this as necessary. */
  52. #define MB_LEN_MAX 1
  53. /* Minimum and maximum values a `signed char' can hold. */
  54. #define SCHAR_MIN (-128)
  55. #define SCHAR_MAX 127
  56. /* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
  57. #ifdef __STDC__
  58. #define UCHAR_MAX 255U
  59. #else
  60. #define UCHAR_MAX 255
  61. #endif
  62. /* Minimum and maximum values a `char' can hold. */
  63. #ifdef __CHAR_UNSIGNED__
  64. #define CHAR_MIN 0
  65. #define CHAR_MAX UCHAR_MAX
  66. #else
  67. #define CHAR_MIN SCHAR_MIN
  68. #define CHAR_MAX SCHAR_MAX
  69. #endif
  70. /* Minimum and maximum values a `signed short int' can hold. */
  71. #define SHRT_MIN (-32768)
  72. #define SHRT_MAX 32767
  73. /* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */
  74. #define USHRT_MAX 65535
  75. /* Minimum and maximum values a `signed int' can hold. */
  76. #define INT_MIN (- INT_MAX - 1)
  77. #define INT_MAX 2147483647
  78. /* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
  79. #ifdef __STDC__
  80. #define UINT_MAX 4294967295U
  81. #else
  82. #define UINT_MAX 4294967295
  83. #endif
  84. /* Minimum and maximum values a `signed long int' can hold. */
  85. #define LONG_MIN INT_MIN
  86. #define LONG_MAX INT_MAX
  87. /* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */
  88. #define ULONG_MAX UINT_MAX
  89. #endif /* GCC 2. */
  90. #ifndef RAND_MAX
  91. /* The largest number rand will return (same as INT_MAX). */
  92. #define RAND_MAX INT_MAX
  93. #endif
  94. #ifdef __SVR4_I386_ABI_L1__
  95. #define NL_ARGMAX 9
  96. #define NL_LANGMAX 14
  97. #define NL_MSGMAX 32767
  98. #define NL_NMAX 1
  99. #define NL_SETMAX 255
  100. #define NL_TEXTMAX 255
  101. #define NZERO 20
  102. #define WORD_BIT 32
  103. #define LONG_BIT 32
  104. #define FCHR_MAX 1048576
  105. #endif /* __SVR4_I386_ABI_L1__ */
  106. #endif /* limits.h */