idn-int.h

Go to the documentation of this file.
00001 /* Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc.
00002    Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
00003    This file is part of gnulib.
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU Lesser General Public License as published by
00007    the Free Software Foundation; either version 2.1, or (at your option)
00008    any later version.
00009 
00010    This program 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
00013    GNU Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public License
00016    along with this program; if not, write to the Free Software Foundation,
00017    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
00018 
00019 #ifndef _GL_STDINT_H
00020 #define _GL_STDINT_H
00021 
00022 /*
00023  * ISO C 99 <stdint.h> for platforms that lack it.
00024  * <http://www.opengroup.org/susv3xbd/stdint.h.html>
00025  */
00026 
00027 /* Get those types that are already defined in other system include
00028    files, so that we can "#define int8_t signed char" below without
00029    worrying about a later system include file containing a "typedef
00030    signed char int8_t;" that will get messed up by our macro.  Our
00031    macros should all be consistent with the system versions, except
00032    for the "fast" types and macros, which we recommend against using
00033    in public interfaces due to compiler differences.  */
00034 
00035 #if 1
00036 # if defined __sgi && ! defined __c99
00037    /* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users
00038       with "This header file is to be used only for c99 mode compilations"
00039       diagnostics.  */
00040 #  define __STDINT_H__
00041 # endif
00042   /* Other systems may have an incomplete or buggy <stdint.h>.
00043      Include it before <inttypes.h>, since any "#include <stdint.h>"
00044      in <inttypes.h> would reinclude us, skipping our contents because
00045      _GL_STDINT_H is defined.  */
00046 # include "
00047 #endif
00048 
00049 /* <sys/types.h> defines some of the stdint.h types as well, on glibc,
00050    IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
00051    MacOS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
00052    relies on the system <stdint.h> definitions, so include
00053    <sys/types.h> after "///usr/include/stdint.h".  */
00054 #if 1
00055 # include <sys/types.h>
00056 #endif
00057 
00058 /* Get LONG_MIN, LONG_MAX, ULONG_MAX.  */
00059 #include <limits.h>
00060 
00061 #if 1
00062   /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
00063      int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
00064      <inttypes.h> also defines intptr_t and uintptr_t.  */
00065 # define _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H
00066 # include <inttypes.h>
00067 # undef _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H
00068 #elif 0
00069   /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
00070      the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX.  */
00071 # include <sys/inttypes.h>
00072 #endif
00073 
00074 #if 1 && ! defined __BIT_TYPES_DEFINED__
00075   /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
00076      int{8,16,32,64}_t and __BIT_TYPES_DEFINED__.  In libc5 >= 5.2.2 it is
00077      included by <sys/types.h>.  */
00078 # include <sys/bitypes.h>
00079 #endif
00080 
00081 #if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
00082 
00083 /* Get WCHAR_MIN, WCHAR_MAX.  */
00084 # if 1 && ! (defined WCHAR_MIN && defined WCHAR_MAX)
00085    /* BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
00086       <wchar.h>.  */
00087 #  include <stdio.h>
00088 #  include <time.h>
00089 #  include <wchar.h>
00090 # endif
00091 
00092 #endif
00093 
00094 /* Minimum and maximum values for a integer type under the usual assumption.
00095    Return an unspecified value if BITS == 0, adding a check to pacify
00096    picky compilers.  */
00097 
00098 #define _STDINT_MIN(signed, bits, zero) \
00099   ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero))
00100 
00101 #define _STDINT_MAX(signed, bits, zero) \
00102   ((signed) \
00103    ? ~ _STDINT_MIN (signed, bits, zero) \
00104    : ((((zero) + 1) << ((bits) ? (bits) - 1 : 0)) - 1) * 2 + 1)
00105 
00106 /* 7.18.1.1. Exact-width integer types */
00107 
00108 /* Here we assume a standard architecture where the hardware integer
00109    types have 8, 16, 32, optionally 64 bits.  */
00110 
00111 #undef int8_t
00112 #undef uint8_t
00113 #define int8_t signed char
00114 #define uint8_t unsigned char
00115 
00116 #undef int16_t
00117 #undef uint16_t
00118 #define int16_t short int
00119 #define uint16_t unsigned short int
00120 
00121 #undef int32_t
00122 #undef uint32_t
00123 #define int32_t int
00124 #define uint32_t unsigned int
00125 
00126 #undef int64_t
00127 #undef uint64_t
00128 #if LONG_MAX >> 31 >> 31 == 1
00129 # define int64_t long int
00130 # define uint64_t unsigned long int
00131 #elif defined _MSC_VER
00132 # define int64_t __int64
00133 # define uint64_t unsigned __int64
00134 #elif 1
00135 # define int64_t long long int
00136 # define uint64_t unsigned long long int
00137 #endif
00138 
00139 /* Avoid collision with Solaris 2.5.1 <pthread.h> etc.  */
00140 #define _UINT8_T
00141 #define _UINT32_T
00142 #define _UINT64_T
00143 
00144 
00145 /* 7.18.1.2. Minimum-width integer types */
00146 
00147 /* Here we assume a standard architecture where the hardware integer
00148    types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
00149    are the same as the corresponding N_t types.  */
00150 
00151 #undef int_least8_t
00152 #undef uint_least8_t
00153 #undef int_least16_t
00154 #undef uint_least16_t
00155 #undef int_least32_t
00156 #undef uint_least32_t
00157 #undef int_least64_t
00158 #undef uint_least64_t
00159 #define int_least8_t int8_t
00160 #define uint_least8_t uint8_t
00161 #define int_least16_t int16_t
00162 #define uint_least16_t uint16_t
00163 #define int_least32_t int32_t
00164 #define uint_least32_t uint32_t
00165 #ifdef int64_t
00166 # define int_least64_t int64_t
00167 # define uint_least64_t uint64_t
00168 #endif
00169 
00170 /* 7.18.1.3. Fastest minimum-width integer types */
00171 
00172 /* Note: Other <stdint.h> substitutes may define these types differently.
00173    It is not recommended to use these types in public header files. */
00174 
00175 /* Here we assume a standard architecture where the hardware integer
00176    types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
00177    are taken from the same list of types.  Assume that 'long int'
00178    is fast enough for all narrower integers.  */
00179 
00180 #undef int_fast8_t
00181 #undef uint_fast8_t
00182 #undef int_fast16_t
00183 #undef uint_fast16_t
00184 #undef int_fast32_t
00185 #undef uint_fast32_t
00186 #undef int_fast64_t
00187 #undef uint_fast64_t
00188 #define int_fast8_t long int
00189 #define uint_fast8_t unsigned int_fast8_t
00190 #define int_fast16_t long int
00191 #define uint_fast16_t unsigned int_fast16_t
00192 #define int_fast32_t long int
00193 #define uint_fast32_t unsigned int_fast32_t
00194 #ifdef int64_t
00195 # define int_fast64_t int64_t
00196 # define uint_fast64_t uint64_t
00197 #endif
00198 
00199 /* 7.18.1.4. Integer types capable of holding object pointers */
00200 
00201 #undef intptr_t
00202 #undef uintptr_t
00203 #define intptr_t long int
00204 #define uintptr_t unsigned long int
00205 
00206 /* 7.18.1.5. Greatest-width integer types */
00207 
00208 /* Note: These types are compiler dependent. It may be unwise to use them in
00209    public header files. */
00210 
00211 #undef intmax_t
00212 #undef uintmax_t
00213 #if 1 && LONG_MAX >> 30 == 1
00214 # define intmax_t long long int
00215 # define uintmax_t unsigned long long int
00216 #elif defined int64_t
00217 # define intmax_t int64_t
00218 # define uintmax_t uint64_t
00219 #else
00220 # define intmax_t long int
00221 # define uintmax_t unsigned long int
00222 #endif
00223 
00224 /* 7.18.2. Limits of specified-width integer types */
00225 
00226 #if ! defined __cplusplus || defined __STDC_LIMIT_MACROS
00227 
00228 /* 7.18.2.1. Limits of exact-width integer types */
00229 
00230 /* Here we assume a standard architecture where the hardware integer
00231    types have 8, 16, 32, optionally 64 bits.  */
00232 
00233 #undef INT8_MIN
00234 #undef INT8_MAX
00235 #undef UINT8_MAX
00236 #define INT8_MIN  (~ INT8_MAX)
00237 #define INT8_MAX  127
00238 #define UINT8_MAX  255
00239 
00240 #undef INT16_MIN
00241 #undef INT16_MAX
00242 #undef UINT16_MAX
00243 #define INT16_MIN  (~ INT16_MAX)
00244 #define INT16_MAX  32767
00245 #define UINT16_MAX  65535
00246 
00247 #undef INT32_MIN
00248 #undef INT32_MAX
00249 #undef UINT32_MAX
00250 #define INT32_MIN  (~ INT32_MAX)
00251 #define INT32_MAX  2147483647
00252 #define UINT32_MAX  4294967295U
00253 
00254 #undef INT64_MIN
00255 #undef INT64_MAX
00256 #undef UINT64_MAX
00257 #ifdef int64_t
00258 # define INT64_MIN  (~ INT64_MAX)
00259 # define INT64_MAX  INTMAX_C (9223372036854775807)
00260 # define UINT64_MAX  UINTMAX_C (18446744073709551615)
00261 #endif
00262 
00263 /* 7.18.2.2. Limits of minimum-width integer types */
00264 
00265 /* Here we assume a standard architecture where the hardware integer
00266    types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
00267    are the same as the corresponding N_t types.  */
00268 
00269 #undef INT_LEAST8_MIN
00270 #undef INT_LEAST8_MAX
00271 #undef UINT_LEAST8_MAX
00272 #define INT_LEAST8_MIN  INT8_MIN
00273 #define INT_LEAST8_MAX  INT8_MAX
00274 #define UINT_LEAST8_MAX  UINT8_MAX
00275 
00276 #undef INT_LEAST16_MIN
00277 #undef INT_LEAST16_MAX
00278 #undef UINT_LEAST16_MAX
00279 #define INT_LEAST16_MIN  INT16_MIN
00280 #define INT_LEAST16_MAX  INT16_MAX
00281 #define UINT_LEAST16_MAX  UINT16_MAX
00282 
00283 #undef INT_LEAST32_MIN
00284 #undef INT_LEAST32_MAX
00285 #undef UINT_LEAST32_MAX
00286 #define INT_LEAST32_MIN  INT32_MIN
00287 #define INT_LEAST32_MAX  INT32_MAX
00288 #define UINT_LEAST32_MAX  UINT32_MAX
00289 
00290 #undef INT_LEAST64_MIN
00291 #undef INT_LEAST64_MAX
00292 #undef UINT_LEAST64_MAX
00293 #ifdef int64_t
00294 # define INT_LEAST64_MIN  INT64_MIN
00295 # define INT_LEAST64_MAX  INT64_MAX
00296 # define UINT_LEAST64_MAX  UINT64_MAX
00297 #endif
00298 
00299 /* 7.18.2.3. Limits of fastest minimum-width integer types */
00300 
00301 /* Here we assume a standard architecture where the hardware integer
00302    types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
00303    are taken from the same list of types.  */
00304 
00305 #undef INT_FAST8_MIN
00306 #undef INT_FAST8_MAX
00307 #undef UINT_FAST8_MAX
00308 #define INT_FAST8_MIN  LONG_MIN
00309 #define INT_FAST8_MAX  LONG_MAX
00310 #define UINT_FAST8_MAX  ULONG_MAX
00311 
00312 #undef INT_FAST16_MIN
00313 #undef INT_FAST16_MAX
00314 #undef UINT_FAST16_MAX
00315 #define INT_FAST16_MIN  LONG_MIN
00316 #define INT_FAST16_MAX  LONG_MAX
00317 #define UINT_FAST16_MAX  ULONG_MAX
00318 
00319 #undef INT_FAST32_MIN
00320 #undef INT_FAST32_MAX
00321 #undef UINT_FAST32_MAX
00322 #define INT_FAST32_MIN  LONG_MIN
00323 #define INT_FAST32_MAX  LONG_MAX
00324 #define UINT_FAST32_MAX  ULONG_MAX
00325 
00326 #undef INT_FAST64_MIN
00327 #undef INT_FAST64_MAX
00328 #undef UINT_FAST64_MAX
00329 #ifdef int64_t
00330 # define INT_FAST64_MIN  INT64_MIN
00331 # define INT_FAST64_MAX  INT64_MAX
00332 # define UINT_FAST64_MAX  UINT64_MAX
00333 #endif
00334 
00335 /* 7.18.2.4. Limits of integer types capable of holding object pointers */
00336 
00337 #undef INTPTR_MIN
00338 #undef INTPTR_MAX
00339 #undef UINTPTR_MAX
00340 #define INTPTR_MIN  LONG_MIN
00341 #define INTPTR_MAX  LONG_MAX
00342 #define UINTPTR_MAX  ULONG_MAX
00343 
00344 /* 7.18.2.5. Limits of greatest-width integer types */
00345 
00346 #undef INTMAX_MIN
00347 #undef INTMAX_MAX
00348 #undef UINTMAX_MAX
00349 #define INTMAX_MIN  (~ INTMAX_MAX)
00350 #ifdef INT64_MAX
00351 # define INTMAX_MAX  INT64_MAX
00352 # define UINTMAX_MAX  UINT64_MAX
00353 #else
00354 # define INTMAX_MAX  INT32_MAX
00355 # define UINTMAX_MAX  UINT32_MAX
00356 #endif
00357 
00358 /* 7.18.3. Limits of other integer types */
00359 
00360 /* ptrdiff_t limits */
00361 #undef PTRDIFF_MIN
00362 #undef PTRDIFF_MAX
00363 #define PTRDIFF_MIN  \
00364    _STDINT_MIN (1, 32, 0)
00365 #define PTRDIFF_MAX  \
00366    _STDINT_MAX (1, 32, 0)
00367 
00368 /* sig_atomic_t limits */
00369 #undef SIG_ATOMIC_MIN
00370 #undef SIG_ATOMIC_MAX
00371 #define SIG_ATOMIC_MIN  \
00372    _STDINT_MIN (1, 32, \
00373                 0)
00374 #define SIG_ATOMIC_MAX  \
00375    _STDINT_MAX (1, 32, \
00376                 0)
00377 
00378 
00379 /* size_t limit */
00380 #undef SIZE_MAX
00381 #define SIZE_MAX  _STDINT_MAX (0, 32, 0u)
00382 
00383 /* wchar_t limits */
00384 #undef WCHAR_MIN
00385 #undef WCHAR_MAX
00386 #define WCHAR_MIN  \
00387    _STDINT_MIN (1, 32, 0)
00388 #define WCHAR_MAX  \
00389    _STDINT_MAX (1, 32, 0)
00390 
00391 /* wint_t limits */
00392 #undef WINT_MIN
00393 #undef WINT_MAX
00394 #define WINT_MIN  \
00395    _STDINT_MIN (0, 32, 0u)
00396 #define WINT_MAX  \
00397    _STDINT_MAX (0, 32, 0u)
00398 
00399 #endif /* !defined __cplusplus || defined __STDC_LIMIT_MACROS */
00400 
00401 /* 7.18.4. Macros for integer constants */
00402 
00403 #if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
00404 
00405 /* 7.18.4.1. Macros for minimum-width integer constants */
00406 /* According to ISO C 99 Technical Corrigendum 1 */
00407 
00408 /* Here we assume a standard architecture where the hardware integer
00409    types have 8, 16, 32, optionally 64 bits, and int is 32 bits.  */
00410 
00411 #undef INT8_C
00412 #undef UINT8_C
00413 #define INT8_C(x) x
00414 #define UINT8_C(x) x
00415 
00416 #undef INT16_C
00417 #undef UINT16_C
00418 #define INT16_C(x) x
00419 #define UINT16_C(x) x
00420 
00421 #undef INT32_C
00422 #undef UINT32_C
00423 #define INT32_C(x) x
00424 #define UINT32_C(x) x ## U
00425 
00426 #undef INT64_C
00427 #undef UINT64_C
00428 #if LONG_MAX >> 31 >> 31 == 1
00429 # define INT64_C(x) x##L
00430 # define UINT64_C(x) x##UL
00431 #elif defined _MSC_VER
00432 # define INT64_C(x) x##i64
00433 # define UINT64_C(x) x##ui64
00434 #elif 1
00435 # define INT64_C(x) x##LL
00436 # define UINT64_C(x) x##ULL
00437 #endif
00438 
00439 /* 7.18.4.2. Macros for greatest-width integer constants */
00440 
00441 #undef INTMAX_C
00442 #undef UINTMAX_C
00443 #if 1 && LONG_MAX >> 30 == 1
00444 # define INTMAX_C(x)   x##LL
00445 # define UINTMAX_C(x)  x##ULL
00446 #elif defined int64_t
00447 # define INTMAX_C(x)   INT64_C(x)
00448 # define UINTMAX_C(x)  UINT64_C(x)
00449 #else
00450 # define INTMAX_C(x)   x##L
00451 # define UINTMAX_C(x)  x##UL
00452 #endif
00453 
00454 #endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */
00455 
00456 #endif /* _GL_STDINT_H */

Generated on Wed Sep 13 10:20:31 2006 for libidn by  doxygen 1.4.7