version 1.1.1.1, 2012/02/21 22:57:48
|
version 1.1.1.2, 2012/05/29 09:29:43
|
Line 1
|
Line 1
|
/* Copyright (C) 2001-2002, 2004-2009 Free Software Foundation, Inc. | /* Copyright (C) 2001-2002, 2004-2011 Free Software Foundation, Inc. |
Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. |
Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. |
This file is part of gnulib. |
This file is part of gnulib. |
|
|
Line 21
|
Line 21
|
* <http://www.opengroup.org/susv3xbd/stdint.h.html> |
* <http://www.opengroup.org/susv3xbd/stdint.h.html> |
*/ |
*/ |
|
|
#ifndef _GL_STDINT_H | #ifndef _@GUARD_PREFIX@_STDINT_H |
|
|
|
#if __GNUC__ >= 3 |
|
@PRAGMA_SYSTEM_HEADER@ |
|
#endif |
|
@PRAGMA_COLUMNS@ |
|
|
/* When including a system file that in turn includes <inttypes.h>, |
/* When including a system file that in turn includes <inttypes.h>, |
use the system <inttypes.h>, not our substitute. This avoids |
use the system <inttypes.h>, not our substitute. This avoids |
problems with (for example) VMS, whose <sys/bitypes.h> includes |
problems with (for example) VMS, whose <sys/bitypes.h> includes |
Line 47
|
Line 52
|
/* Other systems may have an incomplete or buggy <stdint.h>. |
/* Other systems may have an incomplete or buggy <stdint.h>. |
Include it before <inttypes.h>, since any "#include <stdint.h>" |
Include it before <inttypes.h>, since any "#include <stdint.h>" |
in <inttypes.h> would reinclude us, skipping our contents because |
in <inttypes.h> would reinclude us, skipping our contents because |
_GL_STDINT_H is defined. | _@GUARD_PREFIX@_STDINT_H is defined. |
The include_next requires a split double-inclusion guard. */ |
The include_next requires a split double-inclusion guard. */ |
# if __GNUC__ >= 3 |
|
@PRAGMA_SYSTEM_HEADER@ |
|
# endif |
|
# @INCLUDE_NEXT@ @NEXT_STDINT_H@ |
# @INCLUDE_NEXT@ @NEXT_STDINT_H@ |
#endif |
#endif |
|
|
#if ! defined _GL_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H | #if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H |
#define _GL_STDINT_H | #define _@GUARD_PREFIX@_STDINT_H |
|
|
/* <sys/types.h> defines some of the stdint.h types as well, on glibc, |
/* <sys/types.h> defines some of the stdint.h types as well, on glibc, |
IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>). |
IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>). |
Line 91
|
Line 93
|
|
|
#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H |
#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H |
|
|
/* Minimum and maximum values for a integer type under the usual assumption. | /* Minimum and maximum values for an integer type under the usual assumption. |
Return an unspecified value if BITS == 0, adding a check to pacify |
Return an unspecified value if BITS == 0, adding a check to pacify |
picky compilers. */ |
picky compilers. */ |
|
|
Line 102
|
Line 104
|
((signed) \ |
((signed) \ |
? ~ _STDINT_MIN (signed, bits, zero) \ |
? ~ _STDINT_MIN (signed, bits, zero) \ |
: /* The expression for the unsigned case. The subtraction of (signed) \ |
: /* The expression for the unsigned case. The subtraction of (signed) \ |
is a nop in the unsigned case and avoids "signed integer overflow" \ | is a nop in the unsigned case and avoids "signed integer overflow" \ |
warnings in the signed case. */ \ | warnings in the signed case. */ \ |
((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) |
((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) |
|
|
|
#if !GNULIB_defined_stdint_types |
|
|
/* 7.18.1.1. Exact-width integer types */ |
/* 7.18.1.1. Exact-width integer types */ |
|
|
/* Here we assume a standard architecture where the hardware integer |
/* Here we assume a standard architecture where the hardware integer |
Line 132 typedef unsigned int gl_uint32_t;
|
Line 136 typedef unsigned int gl_uint32_t;
|
#define int32_t gl_int32_t |
#define int32_t gl_int32_t |
#define uint32_t gl_uint32_t |
#define uint32_t gl_uint32_t |
|
|
|
/* If the system defines INT64_MAX, assume int64_t works. That way, |
|
if the underlying platform defines int64_t to be a 64-bit long long |
|
int, the code below won't mistakenly define it to be a 64-bit long |
|
int, which would mess up C++ name mangling. We must use #ifdef |
|
rather than #if, to avoid an error with HP-UX 10.20 cc. */ |
|
|
|
#ifdef INT64_MAX |
|
# define GL_INT64_T |
|
#else |
/* Do not undefine int64_t if gnulib is not being used with 64-bit |
/* Do not undefine int64_t if gnulib is not being used with 64-bit |
types, since otherwise it breaks platforms like Tandem/NSK. */ |
types, since otherwise it breaks platforms like Tandem/NSK. */ |
#if LONG_MAX >> 31 >> 31 == 1 | # if LONG_MAX >> 31 >> 31 == 1 |
# undef int64_t | # undef int64_t |
typedef long int gl_int64_t; |
typedef long int gl_int64_t; |
# define int64_t gl_int64_t | # define int64_t gl_int64_t |
# define GL_INT64_T | # define GL_INT64_T |
#elif defined _MSC_VER | # elif defined _MSC_VER |
# undef int64_t | typedef __int64 gl_int64_t; |
typedef __int64 gl_int64_t; |
typedef __int64 gl_int64_t; |
# define int64_t gl_int64_t | # define int64_t gl_int64_t |
# define GL_INT64_T | # define GL_INT64_T |
#elif @HAVE_LONG_LONG_INT@ | # elif @HAVE_LONG_LONG_INT@ |
# undef int64_t | typedef long long int gl_int64_t; |
typedef long long int gl_int64_t; |
typedef long long int gl_int64_t; |
# define int64_t gl_int64_t | # define int64_t gl_int64_t |
# define GL_INT64_T | # define GL_INT64_T |
| # endif |
#endif |
#endif |
|
|
#if ULONG_MAX >> 31 >> 31 >> 1 == 1 | #ifdef UINT64_MAX |
# undef uint64_t | |
typedef unsigned long int gl_uint64_t; | |
# define uint64_t gl_uint64_t | |
# define GL_UINT64_T |
# define GL_UINT64_T |
#elif defined _MSC_VER | #else |
# undef uint64_t | # if ULONG_MAX >> 31 >> 31 >> 1 == 1 |
| # undef uint64_t |
| typedef unsigned long int gl_uint64_t; |
| # define uint64_t gl_uint64_t |
| # define GL_UINT64_T |
| # elif defined _MSC_VER |
| # undef uint64_t |
typedef unsigned __int64 gl_uint64_t; |
typedef unsigned __int64 gl_uint64_t; |
# define uint64_t gl_uint64_t | # define uint64_t gl_uint64_t |
# define GL_UINT64_T | # define GL_UINT64_T |
#elif @HAVE_UNSIGNED_LONG_LONG_INT@ | # elif @HAVE_UNSIGNED_LONG_LONG_INT@ |
# undef uint64_t | typedef unsigned long long int gl_uint64_t; |
typedef unsigned long long int gl_uint64_t; |
typedef unsigned long long int gl_uint64_t; |
# define uint64_t gl_uint64_t | # define uint64_t gl_uint64_t |
# define GL_UINT64_T | # define GL_UINT64_T |
| # endif |
#endif |
#endif |
|
|
/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */ |
/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */ |
Line 252 typedef unsigned long int gl_uintptr_t;
|
Line 270 typedef unsigned long int gl_uintptr_t;
|
/* Note: These types are compiler dependent. It may be unwise to use them in |
/* Note: These types are compiler dependent. It may be unwise to use them in |
public header files. */ |
public header files. */ |
|
|
#undef intmax_t | /* If the system defines INTMAX_MAX, assume that intmax_t works, and |
#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 | similarly for UINTMAX_MAX and uintmax_t. This avoids problems with |
| assuming one type where another is used by the system. */ |
| |
| #ifndef INTMAX_MAX |
| # undef INTMAX_C |
| # undef intmax_t |
| # if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 |
typedef long long int gl_intmax_t; |
typedef long long int gl_intmax_t; |
# define intmax_t gl_intmax_t | # define intmax_t gl_intmax_t |
#elif defined GL_INT64_T | # elif defined GL_INT64_T |
# define intmax_t int64_t | # define intmax_t int64_t |
#else | typedef long int gl_intmax_t; |
typedef long int gl_intmax_t; |
typedef long int gl_intmax_t; |
# define intmax_t gl_intmax_t | # define intmax_t gl_intmax_t |
| # endif |
#endif |
#endif |
|
|
#undef uintmax_t | #ifndef UINTMAX_MAX |
#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 | # undef UINTMAX_C |
| # undef uintmax_t |
| # if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 |
typedef unsigned long long int gl_uintmax_t; |
typedef unsigned long long int gl_uintmax_t; |
# define uintmax_t gl_uintmax_t | # define uintmax_t gl_uintmax_t |
#elif defined GL_UINT64_T | # elif defined GL_UINT64_T |
# define uintmax_t uint64_t | # define uintmax_t uint64_t |
#else | typedef unsigned long int gl_uintmax_t; |
typedef unsigned long int gl_uintmax_t; |
typedef unsigned long int gl_uintmax_t; |
# define uintmax_t gl_uintmax_t | # define uintmax_t gl_uintmax_t |
| # endif |
#endif |
#endif |
|
|
/* Verify that intmax_t and uintmax_t have the same size. Too much code |
/* Verify that intmax_t and uintmax_t have the same size. Too much code |
breaks if this is not the case. If this check fails, the reason is likely |
breaks if this is not the case. If this check fails, the reason is likely |
to be found in the autoconf macros. */ |
to be found in the autoconf macros. */ |
typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) - 1]; | typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) |
| ? 1 : -1]; |
|
|
|
#define GNULIB_defined_stdint_types 1 |
|
#endif /* !GNULIB_defined_stdint_types */ |
|
|
/* 7.18.2. Limits of specified-width integer types */ |
/* 7.18.2. Limits of specified-width integer types */ |
|
|
#if ! defined __cplusplus || defined __STDC_LIMIT_MACROS |
#if ! defined __cplusplus || defined __STDC_LIMIT_MACROS |
Line 309 typedef int _verify_intmax_size[2 * (sizeof (intmax_t)
|
Line 341 typedef int _verify_intmax_size[2 * (sizeof (intmax_t)
|
#define INT32_MAX 2147483647 |
#define INT32_MAX 2147483647 |
#define UINT32_MAX 4294967295U |
#define UINT32_MAX 4294967295U |
|
|
#undef INT64_MIN | #if defined GL_INT64_T && ! defined INT64_MAX |
#undef INT64_MAX | |
#ifdef GL_INT64_T | |
/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 |
/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 |
evaluates the latter incorrectly in preprocessor expressions. */ |
evaluates the latter incorrectly in preprocessor expressions. */ |
# define INT64_MIN (- INTMAX_C (1) << 63) |
# define INT64_MIN (- INTMAX_C (1) << 63) |
# define INT64_MAX INTMAX_C (9223372036854775807) |
# define INT64_MAX INTMAX_C (9223372036854775807) |
#endif |
#endif |
|
|
#undef UINT64_MAX | #if defined GL_UINT64_T && ! defined UINT64_MAX |
#ifdef GL_UINT64_T | |
# define UINT64_MAX UINTMAX_C (18446744073709551615) |
# define UINT64_MAX UINTMAX_C (18446744073709551615) |
#endif |
#endif |
|
|
Line 412 typedef int _verify_intmax_size[2 * (sizeof (intmax_t)
|
Line 441 typedef int _verify_intmax_size[2 * (sizeof (intmax_t)
|
|
|
/* 7.18.2.5. Limits of greatest-width integer types */ |
/* 7.18.2.5. Limits of greatest-width integer types */ |
|
|
#undef INTMAX_MIN | #ifndef INTMAX_MAX |
#undef INTMAX_MAX | # undef INTMAX_MIN |
#ifdef INT64_MAX | # ifdef INT64_MAX |
# define INTMAX_MIN INT64_MIN | # define INTMAX_MIN INT64_MIN |
# define INTMAX_MAX INT64_MAX | # define INTMAX_MAX INT64_MAX |
#else | # else |
# define INTMAX_MIN INT32_MIN | # define INTMAX_MIN INT32_MIN |
# define INTMAX_MAX INT32_MAX | # define INTMAX_MAX INT32_MAX |
| # endif |
#endif |
#endif |
|
|
#undef UINTMAX_MAX | #ifndef UINTMAX_MAX |
#ifdef UINT64_MAX | # ifdef UINT64_MAX |
# define UINTMAX_MAX UINT64_MAX | # define UINTMAX_MAX UINT64_MAX |
#else | # else |
# define UINTMAX_MAX UINT32_MAX | # define UINTMAX_MAX UINT32_MAX |
| # endif |
#endif |
#endif |
|
|
/* 7.18.3. Limits of other integer types */ |
/* 7.18.3. Limits of other integer types */ |
Line 454 typedef int _verify_intmax_size[2 * (sizeof (intmax_t)
|
Line 485 typedef int _verify_intmax_size[2 * (sizeof (intmax_t)
|
#undef SIG_ATOMIC_MAX |
#undef SIG_ATOMIC_MAX |
#define SIG_ATOMIC_MIN \ |
#define SIG_ATOMIC_MIN \ |
_STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ |
_STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ |
0@SIG_ATOMIC_T_SUFFIX@) | 0@SIG_ATOMIC_T_SUFFIX@) |
#define SIG_ATOMIC_MAX \ |
#define SIG_ATOMIC_MAX \ |
_STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ |
_STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ |
0@SIG_ATOMIC_T_SUFFIX@) | 0@SIG_ATOMIC_T_SUFFIX@) |
|
|
|
|
/* size_t limit */ |
/* size_t limit */ |
Line 474 typedef int _verify_intmax_size[2 * (sizeof (intmax_t)
|
Line 505 typedef int _verify_intmax_size[2 * (sizeof (intmax_t)
|
|
|
/* wchar_t limits */ |
/* wchar_t limits */ |
/* Get WCHAR_MIN, WCHAR_MAX. |
/* Get WCHAR_MIN, WCHAR_MAX. |
This include is not on the top, above, because on OSF/1 4.0 we have a sequence of nested | This include is not on the top, above, because on OSF/1 4.0 we have a |
includes <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes | sequence of nested includes |
| <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes |
<stdint.h> and assumes its types are already defined. */ |
<stdint.h> and assumes its types are already defined. */ |
#if ! (defined WCHAR_MIN && defined WCHAR_MAX) | #if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) |
| /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be |
| included before <wchar.h>. */ |
| # include <stddef.h> |
| # include <stdio.h> |
| # include <time.h> |
# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H |
# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H |
# include <wchar.h> |
# include <wchar.h> |
# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H |
# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H |
Line 543 typedef int _verify_intmax_size[2 * (sizeof (intmax_t)
|
Line 580 typedef int _verify_intmax_size[2 * (sizeof (intmax_t)
|
|
|
/* 7.18.4.2. Macros for greatest-width integer constants */ |
/* 7.18.4.2. Macros for greatest-width integer constants */ |
|
|
#undef INTMAX_C | #ifndef INTMAX_C |
#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 | # if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 |
# define INTMAX_C(x) x##LL | # define INTMAX_C(x) x##LL |
#elif defined GL_INT64_T | # elif defined GL_INT64_T |
# define INTMAX_C(x) INT64_C(x) | # define INTMAX_C(x) INT64_C(x) |
#else | # else |
# define INTMAX_C(x) x##L | # define INTMAX_C(x) x##L |
| # endif |
#endif |
#endif |
|
|
#undef UINTMAX_C | #ifndef UINTMAX_C |
#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 | # if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 |
# define UINTMAX_C(x) x##ULL | # define UINTMAX_C(x) x##ULL |
#elif defined GL_UINT64_T | # elif defined GL_UINT64_T |
# define UINTMAX_C(x) UINT64_C(x) | # define UINTMAX_C(x) UINT64_C(x) |
#else | # else |
# define UINTMAX_C(x) x##UL | # define UINTMAX_C(x) x##UL |
| # endif |
#endif |
#endif |
|
|
#endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */ |
#endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */ |
|
|
#endif /* _GL_STDINT_H */ | #endif /* _@GUARD_PREFIX@_STDINT_H */ |
#endif /* !defined _GL_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ | #endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ |