Back to index

glibc  2.9
stdint.h
Go to the documentation of this file.
00001 /* Copyright (C) 1997,1998,1999,2000,2001,2006 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 /*
00020  *     ISO C99: 7.18 Integer types <stdint.h>
00021  */
00022 
00023 #ifndef _STDINT_H
00024 #define _STDINT_H    1
00025 
00026 #include <features.h>
00027 #include <bits/wchar.h>
00028 #include <bits/wordsize.h>
00029 
00030 /* Exact integral types.  */
00031 
00032 /* Signed.  */
00033 
00034 /* There is some amount of overlap with <sys/types.h> as known by inet code */
00035 #ifndef __int8_t_defined
00036 # define __int8_t_defined
00037 typedef signed char         int8_t;
00038 typedef short int           int16_t;
00039 typedef int                 int32_t;
00040 # if __WORDSIZE == 64
00041 typedef long int            int64_t;
00042 # else
00043 __extension__
00044 typedef long long int              int64_t;
00045 # endif
00046 #endif
00047 
00048 /* Unsigned.  */
00049 typedef unsigned char              uint8_t;
00050 typedef unsigned short int  uint16_t;
00051 #ifndef __uint32_t_defined
00052 typedef unsigned int        uint32_t;
00053 # define __uint32_t_defined
00054 #endif
00055 #if __WORDSIZE == 64
00056 typedef unsigned long int   uint64_t;
00057 #else
00058 __extension__
00059 typedef unsigned long long int     uint64_t;
00060 #endif
00061 
00062 
00063 /* Small types.  */
00064 
00065 /* Signed.  */
00066 typedef signed char         int_least8_t;
00067 typedef short int           int_least16_t;
00068 typedef int                 int_least32_t;
00069 #if __WORDSIZE == 64
00070 typedef long int            int_least64_t;
00071 #else
00072 __extension__
00073 typedef long long int              int_least64_t;
00074 #endif
00075 
00076 /* Unsigned.  */
00077 typedef unsigned char              uint_least8_t;
00078 typedef unsigned short int  uint_least16_t;
00079 typedef unsigned int        uint_least32_t;
00080 #if __WORDSIZE == 64
00081 typedef unsigned long int   uint_least64_t;
00082 #else
00083 __extension__
00084 typedef unsigned long long int     uint_least64_t;
00085 #endif
00086 
00087 
00088 /* Fast types.  */
00089 
00090 /* Signed.  */
00091 typedef signed char         int_fast8_t;
00092 #if __WORDSIZE == 64
00093 typedef long int            int_fast16_t;
00094 typedef long int            int_fast32_t;
00095 typedef long int            int_fast64_t;
00096 #else
00097 typedef int                 int_fast16_t;
00098 typedef int                 int_fast32_t;
00099 __extension__
00100 typedef long long int              int_fast64_t;
00101 #endif
00102 
00103 /* Unsigned.  */
00104 typedef unsigned char              uint_fast8_t;
00105 #if __WORDSIZE == 64
00106 typedef unsigned long int   uint_fast16_t;
00107 typedef unsigned long int   uint_fast32_t;
00108 typedef unsigned long int   uint_fast64_t;
00109 #else
00110 typedef unsigned int        uint_fast16_t;
00111 typedef unsigned int        uint_fast32_t;
00112 __extension__
00113 typedef unsigned long long int     uint_fast64_t;
00114 #endif
00115 
00116 
00117 /* Types for `void *' pointers.  */
00118 #if __WORDSIZE == 64
00119 # ifndef __intptr_t_defined
00120 typedef long int            intptr_t;
00121 #  define __intptr_t_defined
00122 # endif
00123 typedef unsigned long int   uintptr_t;
00124 #else
00125 # ifndef __intptr_t_defined
00126 typedef int                 intptr_t;
00127 #  define __intptr_t_defined
00128 # endif
00129 typedef unsigned int        uintptr_t;
00130 #endif
00131 
00132 
00133 /* Largest integral types.  */
00134 #if __WORDSIZE == 64
00135 typedef long int            intmax_t;
00136 typedef unsigned long int   uintmax_t;
00137 #else
00138 __extension__
00139 typedef long long int              intmax_t;
00140 __extension__
00141 typedef unsigned long long int     uintmax_t;
00142 #endif
00143 
00144 
00145 /* The ISO C99 standard specifies that in C++ implementations these
00146    macros should only be defined if explicitly requested.  */
00147 #if !defined __cplusplus || defined __STDC_LIMIT_MACROS
00148 
00149 # if __WORDSIZE == 64
00150 #  define __INT64_C(c)      c ## L
00151 #  define __UINT64_C(c)     c ## UL
00152 # else
00153 #  define __INT64_C(c)      c ## LL
00154 #  define __UINT64_C(c)     c ## ULL
00155 # endif
00156 
00157 /* Limits of integral types.  */
00158 
00159 /* Minimum of signed integral types.  */
00160 # define INT8_MIN           (-128)
00161 # define INT16_MIN          (-32767-1)
00162 # define INT32_MIN          (-2147483647-1)
00163 # define INT64_MIN          (-__INT64_C(9223372036854775807)-1)
00164 /* Maximum of signed integral types.  */
00165 # define INT8_MAX           (127)
00166 # define INT16_MAX          (32767)
00167 # define INT32_MAX          (2147483647)
00168 # define INT64_MAX          (__INT64_C(9223372036854775807))
00169 
00170 /* Maximum of unsigned integral types.  */
00171 # define UINT8_MAX          (255)
00172 # define UINT16_MAX         (65535)
00173 # define UINT32_MAX         (4294967295U)
00174 # define UINT64_MAX         (__UINT64_C(18446744073709551615))
00175 
00176 
00177 /* Minimum of signed integral types having a minimum size.  */
00178 # define INT_LEAST8_MIN            (-128)
00179 # define INT_LEAST16_MIN    (-32767-1)
00180 # define INT_LEAST32_MIN    (-2147483647-1)
00181 # define INT_LEAST64_MIN    (-__INT64_C(9223372036854775807)-1)
00182 /* Maximum of signed integral types having a minimum size.  */
00183 # define INT_LEAST8_MAX            (127)
00184 # define INT_LEAST16_MAX    (32767)
00185 # define INT_LEAST32_MAX    (2147483647)
00186 # define INT_LEAST64_MAX    (__INT64_C(9223372036854775807))
00187 
00188 /* Maximum of unsigned integral types having a minimum size.  */
00189 # define UINT_LEAST8_MAX    (255)
00190 # define UINT_LEAST16_MAX   (65535)
00191 # define UINT_LEAST32_MAX   (4294967295U)
00192 # define UINT_LEAST64_MAX   (__UINT64_C(18446744073709551615))
00193 
00194 
00195 /* Minimum of fast signed integral types having a minimum size.  */
00196 # define INT_FAST8_MIN             (-128)
00197 # if __WORDSIZE == 64
00198 #  define INT_FAST16_MIN    (-9223372036854775807L-1)
00199 #  define INT_FAST32_MIN    (-9223372036854775807L-1)
00200 # else
00201 #  define INT_FAST16_MIN    (-2147483647-1)
00202 #  define INT_FAST32_MIN    (-2147483647-1)
00203 # endif
00204 # define INT_FAST64_MIN            (-__INT64_C(9223372036854775807)-1)
00205 /* Maximum of fast signed integral types having a minimum size.  */
00206 # define INT_FAST8_MAX             (127)
00207 # if __WORDSIZE == 64
00208 #  define INT_FAST16_MAX    (9223372036854775807L)
00209 #  define INT_FAST32_MAX    (9223372036854775807L)
00210 # else
00211 #  define INT_FAST16_MAX    (2147483647)
00212 #  define INT_FAST32_MAX    (2147483647)
00213 # endif
00214 # define INT_FAST64_MAX            (__INT64_C(9223372036854775807))
00215 
00216 /* Maximum of fast unsigned integral types having a minimum size.  */
00217 # define UINT_FAST8_MAX            (255)
00218 # if __WORDSIZE == 64
00219 #  define UINT_FAST16_MAX   (18446744073709551615UL)
00220 #  define UINT_FAST32_MAX   (18446744073709551615UL)
00221 # else
00222 #  define UINT_FAST16_MAX   (4294967295U)
00223 #  define UINT_FAST32_MAX   (4294967295U)
00224 # endif
00225 # define UINT_FAST64_MAX    (__UINT64_C(18446744073709551615))
00226 
00227 
00228 /* Values to test for integral types holding `void *' pointer.  */
00229 # if __WORDSIZE == 64
00230 #  define INTPTR_MIN        (-9223372036854775807L-1)
00231 #  define INTPTR_MAX        (9223372036854775807L)
00232 #  define UINTPTR_MAX              (18446744073709551615UL)
00233 # else
00234 #  define INTPTR_MIN        (-2147483647-1)
00235 #  define INTPTR_MAX        (2147483647)
00236 #  define UINTPTR_MAX              (4294967295U)
00237 # endif
00238 
00239 
00240 /* Minimum for largest signed integral type.  */
00241 # define INTMAX_MIN         (-__INT64_C(9223372036854775807)-1)
00242 /* Maximum for largest signed integral type.  */
00243 # define INTMAX_MAX         (__INT64_C(9223372036854775807))
00244 
00245 /* Maximum for largest unsigned integral type.  */
00246 # define UINTMAX_MAX        (__UINT64_C(18446744073709551615))
00247 
00248 
00249 /* Limits of other integer types.  */
00250 
00251 /* Limits of `ptrdiff_t' type.  */
00252 # if __WORDSIZE == 64
00253 #  define PTRDIFF_MIN              (-9223372036854775807L-1)
00254 #  define PTRDIFF_MAX              (9223372036854775807L)
00255 # else
00256 #  define PTRDIFF_MIN              (-2147483647-1)
00257 #  define PTRDIFF_MAX              (2147483647)
00258 # endif
00259 
00260 /* Limits of `sig_atomic_t'.  */
00261 # define SIG_ATOMIC_MIN            (-2147483647-1)
00262 # define SIG_ATOMIC_MAX            (2147483647)
00263 
00264 /* Limit of `size_t' type.  */
00265 # if __WORDSIZE == 64
00266 #  define SIZE_MAX          (18446744073709551615UL)
00267 # else
00268 #  define SIZE_MAX          (4294967295U)
00269 # endif
00270 
00271 /* Limits of `wchar_t'.  */
00272 # ifndef WCHAR_MIN
00273 /* These constants might also be defined in <wchar.h>.  */
00274 #  define WCHAR_MIN         __WCHAR_MIN
00275 #  define WCHAR_MAX         __WCHAR_MAX
00276 # endif
00277 
00278 /* Limits of `wint_t'.  */
00279 # define WINT_MIN           (0u)
00280 # define WINT_MAX           (4294967295u)
00281 
00282 #endif /* C++ && limit macros */
00283 
00284 
00285 /* The ISO C99 standard specifies that in C++ implementations these
00286    should only be defined if explicitly requested.  */
00287 #if !defined __cplusplus || defined __STDC_CONSTANT_MACROS
00288 
00289 /* Signed.  */
00290 # define INT8_C(c)   c
00291 # define INT16_C(c)  c
00292 # define INT32_C(c)  c
00293 # if __WORDSIZE == 64
00294 #  define INT64_C(c) c ## L
00295 # else
00296 #  define INT64_C(c) c ## LL
00297 # endif
00298 
00299 /* Unsigned.  */
00300 # define UINT8_C(c)  c
00301 # define UINT16_C(c) c
00302 # define UINT32_C(c) c ## U
00303 # if __WORDSIZE == 64
00304 #  define UINT64_C(c)       c ## UL
00305 # else
00306 #  define UINT64_C(c)       c ## ULL
00307 # endif
00308 
00309 /* Maximal type.  */
00310 # if __WORDSIZE == 64
00311 #  define INTMAX_C(c)       c ## L
00312 #  define UINTMAX_C(c)      c ## UL
00313 # else
00314 #  define INTMAX_C(c)       c ## LL
00315 #  define UINTMAX_C(c)      c ## ULL
00316 # endif
00317 
00318 #endif /* C++ && constant macros */
00319 
00320 #endif /* stdint.h */