limits.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. /* If we are not using GNU CC we have to define all the symbols ourself.
  36. Otherwise use gcc's definitions (see below). */
  37. #if !defined __GNUC__ || __GNUC__ < 2
  38. /* We only protect from multiple inclusion here, because all the other
  39. #include's protect themselves, and in GCC 2 we may #include_next through
  40. multiple copies of this file before we get to GCC's. */
  41. # ifndef _LIMITS_H
  42. # define _LIMITS_H 1
  43. /* We don't have #include_next.
  44. Define ANSI <limits.h> for standard 32-bit words. */
  45. /* These assume 8-bit `char's, 16-bit `short int's,
  46. and 32-bit `int's and `long int's. */
  47. /* Number of bits in a `char'. */
  48. # define CHAR_BIT 8
  49. /* Minimum and maximum values a `signed char' can hold. */
  50. # define SCHAR_MIN (-128)
  51. # define SCHAR_MAX 127
  52. /* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
  53. # define UCHAR_MAX 255
  54. /* Minimum and maximum values a `char' can hold. */
  55. # ifdef __CHAR_UNSIGNED__
  56. # define CHAR_MIN 0
  57. # define CHAR_MAX UCHAR_MAX
  58. # else
  59. # define CHAR_MIN SCHAR_MIN
  60. # define CHAR_MAX SCHAR_MAX
  61. # endif
  62. /* Minimum and maximum values a `signed short int' can hold. */
  63. # define SHRT_MIN (-32768)
  64. # define SHRT_MAX 32767
  65. /* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */
  66. # define USHRT_MAX 65535
  67. /* Minimum and maximum values a `signed int' can hold. */
  68. # define INT_MIN (-INT_MAX - 1)
  69. # define INT_MAX 2147483647
  70. /* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
  71. # ifdef __STDC__
  72. # define UINT_MAX 4294967295U
  73. # else
  74. # define UINT_MAX 4294967295
  75. # endif
  76. /* Minimum and maximum values a `signed long int' can hold. */
  77. # ifdef __alpha__
  78. # define LONG_MAX 9223372036854775807L
  79. # else
  80. # define LONG_MAX 2147483647L
  81. # endif
  82. # define LONG_MIN (-LONG_MAX - 1L)
  83. /* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */
  84. # ifdef __alpha__
  85. # define ULONG_MAX 18446744073709551615UL
  86. # else
  87. # ifdef __STDC__
  88. # define ULONG_MAX 4294967295UL
  89. # else
  90. # define ULONG_MAX 4294967295L
  91. # endif
  92. # endif
  93. # endif /* limits.h */
  94. #endif /* GCC 2. */
  95. #endif /* !_LIBC_LIMITS_H_ */
  96. /* Get the compiler's limits.h, which defines almost all the ISO constants.
  97. We put this #include_next outside the double inclusion check because
  98. it should be possible to include this file more than once and still get
  99. the definitions from gcc's header. */
  100. #if defined __GNUC__ && !defined _GCC_LIMITS_H_
  101. /* `_GCC_LIMITS_H_' is what GCC's file defines. */
  102. # include_next <limits.h>
  103. #endif