limits.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* Copyright (C) 1991, 1992, 1996, 1997, 1998 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 not,
  13. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. Boston, MA 02111-1307, USA. */
  15. /*
  16. * ISO C Standard: 4.14/2.2.4.2 Limits of integral types <limits.h>
  17. */
  18. #ifndef _LIBC_LIMITS_H_
  19. #define _LIBC_LIMITS_H_ 1
  20. #include <features.h>
  21. #ifdef __USE_POSIX
  22. /* POSIX adds things to <limits.h>. */
  23. # include <bits/posix1_lim.h>
  24. #endif
  25. #ifdef __USE_POSIX2
  26. # include <bits/posix2_lim.h>
  27. #endif
  28. #ifdef __USE_XOPEN
  29. # include <bits/xopen_lim.h>
  30. #endif
  31. /* Maximum length of any multibyte character in any locale.
  32. We define this value here since the gcc header does not define
  33. the correct value. */
  34. #define MB_LEN_MAX 6
  35. /* We only protect from multiple inclusion here, because all the other
  36. #include's protect themselves, and in GCC 2 we may #include_next through
  37. multiple copies of this file before we get to GCC's. */
  38. # ifndef _LIMITS_H
  39. # define _LIMITS_H 1
  40. /* We don't have #include_next.
  41. Define ANSI <limits.h> for standard 32-bit words. */
  42. /* These assume 8-bit `char's, 16-bit `short int's,
  43. and 32-bit `int's and `long int's. */
  44. /* Number of bits in a `char'. */
  45. # define CHAR_BIT 8
  46. /* Minimum and maximum values a `signed char' can hold. */
  47. # define SCHAR_MIN (-128)
  48. # define SCHAR_MAX 127
  49. /* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
  50. # define UCHAR_MAX 255
  51. /* Minimum and maximum values a `char' can hold. */
  52. # ifdef __CHAR_UNSIGNED__
  53. # define CHAR_MIN 0
  54. # define CHAR_MAX UCHAR_MAX
  55. # else
  56. # define CHAR_MIN SCHAR_MIN
  57. # define CHAR_MAX SCHAR_MAX
  58. # endif
  59. /* Minimum and maximum values a `signed short int' can hold. */
  60. # define SHRT_MIN (-32768)
  61. # define SHRT_MAX 32767
  62. /* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */
  63. # define USHRT_MAX 65535
  64. /* Minimum and maximum values a `signed int' can hold. */
  65. # define INT_MIN (-INT_MAX - 1)
  66. # define INT_MAX 2147483647
  67. /* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
  68. # ifdef __STDC__
  69. # define UINT_MAX 4294967295U
  70. # else
  71. # define UINT_MAX 4294967295
  72. # endif
  73. /* Minimum and maximum values a `signed long int' can hold. */
  74. # ifdef __alpha__
  75. # define LONG_MAX 9223372036854775807L
  76. # else
  77. # define LONG_MAX 2147483647L
  78. # endif
  79. # define LONG_MIN (-LONG_MAX - 1L)
  80. /* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */
  81. # ifdef __alpha__
  82. # define ULONG_MAX 18446744073709551615UL
  83. # else
  84. # ifdef __STDC__
  85. # define ULONG_MAX 4294967295UL
  86. # else
  87. # define ULONG_MAX 4294967295L
  88. # endif
  89. # endif
  90. # endif /* limits.h */
  91. #endif /* !_LIBC_LIMITS_H_ */
  92. /* Get the compiler's limits.h, which defines almost all the ISO constants.
  93. We put this #include_next outside the double inclusion check because
  94. it should be possible to include this file more than once and still get
  95. the definitions from gcc's header. */
  96. #if defined __GNUC__ && !defined _GCC_LIMITS_H_
  97. /* `_GCC_LIMITS_H_' is what GCC's file defines. */
  98. # include_next <limits.h>
  99. #endif