Back to index

glibc  2.9
limits.h
Go to the documentation of this file.
00001 /* Copyright (C) 1991, 1992, 1996, 1997, 1998, 1999, 2000, 2005
00002    Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 /*
00021  *     ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h>
00022  */
00023 
00024 #ifndef _LIBC_LIMITS_H_
00025 #define _LIBC_LIMITS_H_     1
00026 
00027 #include <features.h>
00028 
00029 
00030 /* Maximum length of any multibyte character in any locale.
00031    We define this value here since the gcc header does not define
00032    the correct value.  */
00033 #define MB_LEN_MAX   16
00034 
00035 
00036 /* If we are not using GNU CC we have to define all the symbols ourself.
00037    Otherwise use gcc's definitions (see below).  */
00038 #if !defined __GNUC__ || __GNUC__ < 2
00039 
00040 /* We only protect from multiple inclusion here, because all the other
00041    #include's protect themselves, and in GCC 2 we may #include_next through
00042    multiple copies of this file before we get to GCC's.  */
00043 # ifndef _LIMITS_H
00044 #  define _LIMITS_H  1
00045 
00046 #include <bits/wordsize.h>
00047 
00048 /* We don't have #include_next.
00049    Define ANSI <limits.h> for standard 32-bit words.  */
00050 
00051 /* These assume 8-bit `char's, 16-bit `short int's,
00052    and 32-bit `int's and `long int's.  */
00053 
00054 /* Number of bits in a `char'.     */
00055 #  define CHAR_BIT   8
00056 
00057 /* Minimum and maximum values a `signed char' can hold.  */
00058 #  define SCHAR_MIN  (-128)
00059 #  define SCHAR_MAX  127
00060 
00061 /* Maximum value an `unsigned char' can hold.  (Minimum is 0.)  */
00062 #  define UCHAR_MAX  255
00063 
00064 /* Minimum and maximum values a `char' can hold.  */
00065 #  ifdef __CHAR_UNSIGNED__
00066 #   define CHAR_MIN  0
00067 #   define CHAR_MAX  UCHAR_MAX
00068 #  else
00069 #   define CHAR_MIN  SCHAR_MIN
00070 #   define CHAR_MAX  SCHAR_MAX
00071 #  endif
00072 
00073 /* Minimum and maximum values a `signed short int' can hold.  */
00074 #  define SHRT_MIN   (-32768)
00075 #  define SHRT_MAX   32767
00076 
00077 /* Maximum value an `unsigned short int' can hold.  (Minimum is 0.)  */
00078 #  define USHRT_MAX  65535
00079 
00080 /* Minimum and maximum values a `signed int' can hold.  */
00081 #  define INT_MIN    (-INT_MAX - 1)
00082 #  define INT_MAX    2147483647
00083 
00084 /* Maximum value an `unsigned int' can hold.  (Minimum is 0.)  */
00085 #  define UINT_MAX   4294967295U
00086 
00087 /* Minimum and maximum values a `signed long int' can hold.  */
00088 #  if __WORDSIZE == 64
00089 #   define LONG_MAX  9223372036854775807L
00090 #  else
00091 #   define LONG_MAX  2147483647L
00092 #  endif
00093 #  define LONG_MIN   (-LONG_MAX - 1L)
00094 
00095 /* Maximum value an `unsigned long int' can hold.  (Minimum is 0.)  */
00096 #  if __WORDSIZE == 64
00097 #   define ULONG_MAX 18446744073709551615UL
00098 #  else
00099 #   define ULONG_MAX 4294967295UL
00100 #  endif
00101 
00102 #  ifdef __USE_ISOC99
00103 
00104 /* Minimum and maximum values a `signed long long int' can hold.  */
00105 #   define LLONG_MAX 9223372036854775807LL
00106 #   define LLONG_MIN (-LLONG_MAX - 1LL)
00107 
00108 /* Maximum value an `unsigned long long int' can hold.  (Minimum is 0.)  */
00109 #   define ULLONG_MAX       18446744073709551615ULL
00110 
00111 #  endif /* ISO C99 */
00112 
00113 # endif       /* limits.h  */
00114 #endif /* GCC 2.  */
00115 
00116 #endif /* !_LIBC_LIMITS_H_ */
00117 
00118  /* Get the compiler's limits.h, which defines almost all the ISO constants.
00119 
00120     We put this #include_next outside the double inclusion check because
00121     it should be possible to include this file more than once and still get
00122     the definitions from gcc's header.  */
00123 #if defined __GNUC__ && !defined _GCC_LIMITS_H_
00124 /* `_GCC_LIMITS_H_' is what GCC's file defines.  */
00125 # include_next <limits.h>
00126 #endif
00127 
00128 /* The <limits.h> files in some gcc versions don't define LLONG_MIN,
00129    LLONG_MAX, and ULLONG_MAX.  Instead only the values gcc defined for
00130    ages are available.  */
00131 #if defined __USE_ISOC99 && defined __GNUC__
00132 # ifndef LLONG_MIN
00133 #  define LLONG_MIN  (-LLONG_MAX-1)
00134 # endif
00135 # ifndef LLONG_MAX
00136 #  define LLONG_MAX  __LONG_LONG_MAX__
00137 # endif
00138 # ifndef ULLONG_MAX
00139 #  define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
00140 # endif
00141 #endif
00142 
00143 #ifdef __USE_POSIX
00144 /* POSIX adds things to <limits.h>.  */
00145 # include <bits/posix1_lim.h>
00146 #endif
00147 
00148 #ifdef __USE_POSIX2
00149 # include <bits/posix2_lim.h>
00150 #endif
00151 
00152 #ifdef __USE_XOPEN
00153 # include <bits/xopen_lim.h>
00154 #endif