2000-11-12 18:35:33 +00:00
|
|
|
// boost cstdint.hpp header file ------------------------------------------//
|
2000-07-07 16:04:40 +00:00
|
|
|
|
|
|
|
// (C) Copyright boost.org 1999. Permission to copy, use, modify, sell
|
|
|
|
// and distribute this software is granted provided this copyright
|
|
|
|
// notice appears in all copies. This software is provided "as is" without
|
|
|
|
// express or implied warranty, and with no claim as to its suitability for
|
|
|
|
// any purpose.
|
|
|
|
|
|
|
|
// See http://www.boost.org for most recent version including documentation.
|
|
|
|
|
2001-11-04 21:53:21 +00:00
|
|
|
// Revision History
|
2001-10-31 19:35:59 +00:00
|
|
|
// 31 Oct 01 use BOOST_HAS_LONG_LONG to check for "long long" (Jens M.)
|
2001-04-16 12:53:03 +00:00
|
|
|
// 16 Apr 01 check LONGLONG_MAX when looking for "long long" (Jens Maurer)
|
2001-01-23 19:45:00 +00:00
|
|
|
// 23 Jan 01 prefer "long" over "int" for int32_t and intmax_t (Jens Maurer)
|
2000-11-12 18:35:33 +00:00
|
|
|
// 12 Nov 00 Merged <boost/stdint.h> (Jens Maurer)
|
2000-09-24 11:35:25 +00:00
|
|
|
// 23 Sep 00 Added INTXX_C macro support (John Maddock).
|
2000-09-22 20:39:23 +00:00
|
|
|
// 22 Sep 00 Better 64-bit support (John Maddock)
|
2000-07-07 16:04:40 +00:00
|
|
|
// 29 Jun 00 Reimplement to avoid including stdint.h within namespace boost
|
2000-09-22 20:39:23 +00:00
|
|
|
// 8 Aug 99 Initial version (Beman Dawes)
|
2000-07-07 16:04:40 +00:00
|
|
|
|
2000-09-24 11:35:25 +00:00
|
|
|
|
2000-07-07 16:04:40 +00:00
|
|
|
#ifndef BOOST_CSTDINT_HPP
|
|
|
|
#define BOOST_CSTDINT_HPP
|
|
|
|
|
2000-11-12 18:35:33 +00:00
|
|
|
#include <boost/config.hpp>
|
|
|
|
|
2000-07-07 16:04:40 +00:00
|
|
|
|
2001-09-18 11:13:39 +00:00
|
|
|
#ifdef BOOST_HAS_STDINT_H
|
2000-11-12 18:35:33 +00:00
|
|
|
|
2001-05-07 21:21:13 +00:00
|
|
|
// The following #include is an implementation artifact; not part of interface.
|
|
|
|
# ifdef __hpux
|
2001-09-20 19:25:35 +00:00
|
|
|
// HP-UX has a vaguely nice <stdint.h> in a non-standard location
|
|
|
|
# include <inttypes.h>
|
2001-05-08 18:14:14 +00:00
|
|
|
# ifdef __STDC_32_MODE__
|
|
|
|
// this is triggered with GCC, because it defines __cplusplus < 199707L
|
|
|
|
# define BOOST_NO_INT64_T
|
|
|
|
# endif
|
2001-05-07 21:21:13 +00:00
|
|
|
# else
|
|
|
|
# include <stdint.h>
|
|
|
|
# endif
|
2000-07-07 16:04:40 +00:00
|
|
|
|
|
|
|
namespace boost
|
|
|
|
{
|
|
|
|
|
|
|
|
using ::int8_t;
|
|
|
|
using ::int_least8_t;
|
|
|
|
using ::int_fast8_t;
|
|
|
|
using ::uint8_t;
|
|
|
|
using ::uint_least8_t;
|
|
|
|
using ::uint_fast8_t;
|
|
|
|
|
|
|
|
using ::int16_t;
|
|
|
|
using ::int_least16_t;
|
|
|
|
using ::int_fast16_t;
|
|
|
|
using ::uint16_t;
|
|
|
|
using ::uint_least16_t;
|
|
|
|
using ::uint_fast16_t;
|
|
|
|
|
|
|
|
using ::int32_t;
|
|
|
|
using ::int_least32_t;
|
|
|
|
using ::int_fast32_t;
|
|
|
|
using ::uint32_t;
|
|
|
|
using ::uint_least32_t;
|
|
|
|
using ::uint_fast32_t;
|
|
|
|
|
2000-11-12 18:35:33 +00:00
|
|
|
# ifndef BOOST_NO_INT64_T
|
2000-07-07 16:04:40 +00:00
|
|
|
|
|
|
|
using ::int64_t;
|
|
|
|
using ::int_least64_t;
|
|
|
|
using ::int_fast64_t;
|
|
|
|
using ::uint64_t;
|
|
|
|
using ::uint_least64_t;
|
|
|
|
using ::uint_fast64_t;
|
|
|
|
|
2000-11-12 18:35:33 +00:00
|
|
|
# endif
|
2000-07-07 16:04:40 +00:00
|
|
|
|
|
|
|
using ::intmax_t;
|
|
|
|
using ::uintmax_t;
|
|
|
|
|
|
|
|
} // namespace boost
|
|
|
|
|
2000-09-24 11:35:25 +00:00
|
|
|
|
2001-09-18 11:13:39 +00:00
|
|
|
#else // BOOST_HAS_STDINT_H
|
2000-11-12 18:35:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
# include <limits.h> // implementation artifact; not part of interface
|
|
|
|
|
|
|
|
|
|
|
|
namespace boost
|
|
|
|
{
|
|
|
|
|
|
|
|
// These are fairly safe guesses for some 16-bit, and most 32-bit and 64-bit
|
|
|
|
// platforms. For other systems, they will have to be hand tailored.
|
|
|
|
//
|
|
|
|
// Because the fast types are assumed to be the same as the undecorated types,
|
|
|
|
// it may be possible to hand tailor a more efficient implementation. Such
|
|
|
|
// an optimization may be illusionary; on the Intel x86-family 386 on, for
|
|
|
|
// example, byte arithmetic and load/stores are as fast as "int" sized ones.
|
|
|
|
|
|
|
|
// 8-bit types ------------------------------------------------------------//
|
|
|
|
|
|
|
|
# if UCHAR_MAX == 0xff
|
|
|
|
typedef signed char int8_t;
|
|
|
|
typedef signed char int_least8_t;
|
|
|
|
typedef signed char int_fast8_t;
|
|
|
|
typedef unsigned char uint8_t;
|
|
|
|
typedef unsigned char uint_least8_t;
|
|
|
|
typedef unsigned char uint_fast8_t;
|
|
|
|
# else
|
|
|
|
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
|
|
|
# endif
|
|
|
|
|
|
|
|
// 16-bit types -----------------------------------------------------------//
|
|
|
|
|
|
|
|
# if USHRT_MAX == 0xffff
|
|
|
|
typedef short int16_t;
|
|
|
|
typedef short int_least16_t;
|
|
|
|
typedef short int_fast16_t;
|
|
|
|
typedef unsigned short uint16_t;
|
|
|
|
typedef unsigned short uint_least16_t;
|
|
|
|
typedef unsigned short uint_fast16_t;
|
|
|
|
# else
|
|
|
|
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
|
|
|
# endif
|
|
|
|
|
|
|
|
// 32-bit types -----------------------------------------------------------//
|
|
|
|
|
2001-01-23 19:45:00 +00:00
|
|
|
# if ULONG_MAX == 0xffffffff
|
2000-11-12 18:35:33 +00:00
|
|
|
typedef long int32_t;
|
|
|
|
typedef long int_least32_t;
|
|
|
|
typedef long int_fast32_t;
|
|
|
|
typedef unsigned long uint32_t;
|
|
|
|
typedef unsigned long uint_least32_t;
|
|
|
|
typedef unsigned long uint_fast32_t;
|
2001-01-23 19:45:00 +00:00
|
|
|
# elif UINT_MAX == 0xffffffff
|
|
|
|
typedef int int32_t;
|
|
|
|
typedef int int_least32_t;
|
|
|
|
typedef int int_fast32_t;
|
|
|
|
typedef unsigned int uint32_t;
|
|
|
|
typedef unsigned int uint_least32_t;
|
|
|
|
typedef unsigned int uint_fast32_t;
|
2000-11-12 18:35:33 +00:00
|
|
|
# else
|
|
|
|
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
|
|
|
# endif
|
|
|
|
|
|
|
|
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
|
|
|
|
|
2001-10-31 19:35:59 +00:00
|
|
|
# if defined(BOOST_HAS_LONG_LONG) && \
|
|
|
|
!defined(BOOST_MSVC) && !defined(__BORLANDC__) && \
|
2001-11-01 21:52:08 +00:00
|
|
|
(!defined(__GLIBCPP__) || defined(_GLIBCPP_USE_LONG_LONG)) && \
|
2001-05-11 17:04:56 +00:00
|
|
|
(defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
|
2001-09-20 19:25:35 +00:00
|
|
|
# if defined(__hpux)
|
|
|
|
// HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
|
|
|
|
# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615ULL) || (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615ULL) || (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615ULL)
|
2000-11-12 18:35:33 +00:00
|
|
|
// 2**64 - 1
|
2001-09-20 19:25:35 +00:00
|
|
|
# else
|
|
|
|
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
|
|
|
# endif
|
|
|
|
|
2000-11-12 18:35:33 +00:00
|
|
|
typedef long long intmax_t;
|
|
|
|
typedef unsigned long long uintmax_t;
|
|
|
|
typedef long long int64_t;
|
|
|
|
typedef long long int_least64_t;
|
|
|
|
typedef long long int_fast64_t;
|
|
|
|
typedef unsigned long long uint64_t;
|
|
|
|
typedef unsigned long long uint_least64_t;
|
|
|
|
typedef unsigned long long uint_fast64_t;
|
2001-09-20 19:25:35 +00:00
|
|
|
|
2000-11-12 18:35:33 +00:00
|
|
|
# elif ULONG_MAX != 0xffffffff
|
|
|
|
|
|
|
|
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
|
|
|
|
typedef long intmax_t;
|
|
|
|
typedef unsigned long uintmax_t;
|
|
|
|
typedef long int64_t;
|
|
|
|
typedef long int_least64_t;
|
|
|
|
typedef long int_fast64_t;
|
|
|
|
typedef unsigned long uint64_t;
|
|
|
|
typedef unsigned long uint_least64_t;
|
|
|
|
typedef unsigned long uint_fast64_t;
|
|
|
|
# else
|
|
|
|
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
|
|
|
# endif
|
|
|
|
# elif (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
|
|
|
|
//
|
|
|
|
// we have Borland/Microsoft __int64:
|
|
|
|
//
|
|
|
|
typedef __int64 intmax_t;
|
|
|
|
typedef unsigned __int64 uintmax_t;
|
|
|
|
typedef __int64 int64_t;
|
|
|
|
typedef __int64 int_least64_t;
|
|
|
|
typedef __int64 int_fast64_t;
|
|
|
|
typedef unsigned __int64 uint64_t;
|
|
|
|
typedef unsigned __int64 uint_least64_t;
|
|
|
|
typedef unsigned __int64 uint_fast64_t;
|
|
|
|
# else // assume no 64-bit integers
|
|
|
|
# define BOOST_NO_INT64_T
|
|
|
|
typedef int32_t intmax_t;
|
|
|
|
typedef uint32_t uintmax_t;
|
|
|
|
# endif
|
|
|
|
|
|
|
|
} // namespace boost
|
|
|
|
|
|
|
|
|
2001-09-18 11:13:39 +00:00
|
|
|
#endif // BOOST_HAS_STDINT_H
|
2000-11-12 18:35:33 +00:00
|
|
|
|
|
|
|
#endif // BOOST_CSTDINT_HPP
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************
|
|
|
|
|
|
|
|
Macro definition section:
|
|
|
|
|
|
|
|
Define various INTXX_C macros only if
|
|
|
|
__STDC_CONSTANT_MACROS is defined.
|
|
|
|
|
|
|
|
Undefine the macros if __STDC_CONSTANT_MACROS is
|
|
|
|
not defined and the macros are (cf <cassert>).
|
|
|
|
|
2001-09-18 11:13:39 +00:00
|
|
|
Added 23rd September 2000 (John Maddock).
|
|
|
|
Modified 11th September 2001 to be excluded when
|
|
|
|
BOOST_HAS_STDINT_H is defined (John Maddock).
|
2000-11-12 18:35:33 +00:00
|
|
|
|
|
|
|
******************************************************/
|
|
|
|
|
2001-09-18 11:13:39 +00:00
|
|
|
#if defined(__STDC_CONSTANT_MACROS) && !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(BOOST_HAS_STDINT_H)
|
2000-11-12 18:35:33 +00:00
|
|
|
# define BOOST__STDC_CONSTANT_MACROS_DEFINED
|
|
|
|
# if (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
|
|
|
|
//
|
|
|
|
// Borland/Microsoft compilers have width specific suffixes:
|
|
|
|
//
|
|
|
|
# define INT8_C(value) value##i8
|
|
|
|
# define INT16_C(value) value##i16
|
|
|
|
# define INT32_C(value) value##i32
|
|
|
|
# define INT64_C(value) value##i64
|
|
|
|
# ifdef __BORLANDC__
|
|
|
|
// Borland bug: appending ui8 makes the type a signed char
|
|
|
|
# define UINT8_C(value) static_cast<unsigned char>(value##u)
|
|
|
|
# else
|
|
|
|
# define UINT8_C(value) value##ui8
|
|
|
|
# endif
|
|
|
|
# define UINT16_C(value) value##ui16
|
|
|
|
# define UINT32_C(value) value##ui32
|
|
|
|
# define UINT64_C(value) value##ui64
|
|
|
|
# define INTMAX_C(value) value##i64
|
|
|
|
# define UINTMAX_C(value) value##ui64
|
|
|
|
|
|
|
|
# else
|
|
|
|
// do it the old fashioned way:
|
|
|
|
|
|
|
|
// 8-bit types ------------------------------------------------------------//
|
|
|
|
|
|
|
|
# if UCHAR_MAX == 0xff
|
|
|
|
# define INT8_C(value) static_cast<boost::int8_t>(value)
|
|
|
|
# define UINT8_C(value) static_cast<boost::uint8_t>(value##u)
|
|
|
|
# endif
|
|
|
|
|
|
|
|
// 16-bit types -----------------------------------------------------------//
|
|
|
|
|
|
|
|
# if USHRT_MAX == 0xffff
|
|
|
|
# define INT16_C(value) static_cast<boost::int16_t>(value)
|
|
|
|
# define UINT16_C(value) static_cast<boost::uint16_t>(value##u)
|
|
|
|
# endif
|
|
|
|
|
|
|
|
// 32-bit types -----------------------------------------------------------//
|
|
|
|
|
|
|
|
# if UINT_MAX == 0xffffffff
|
|
|
|
# define INT32_C(value) value
|
|
|
|
# define UINT32_C(value) value##u
|
|
|
|
# elif ULONG_MAX == 0xffffffff
|
|
|
|
# define INT32_C(value) value##L
|
|
|
|
# define UINT32_C(value) value##uL
|
|
|
|
# endif
|
|
|
|
|
|
|
|
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
|
|
|
|
|
2001-10-31 19:35:59 +00:00
|
|
|
# if defined(BOOST_HAS_LONG_LONG) && \
|
|
|
|
(defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
|
|
|
|
|
2001-09-20 19:25:35 +00:00
|
|
|
# if defined(__hpux)
|
2001-05-09 21:07:20 +00:00
|
|
|
// HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
|
2001-09-20 19:25:35 +00:00
|
|
|
# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615U) || \
|
|
|
|
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615U) || \
|
2001-05-09 21:07:20 +00:00
|
|
|
(defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615U)
|
2001-09-20 19:25:35 +00:00
|
|
|
|
2000-11-12 18:35:33 +00:00
|
|
|
# else
|
|
|
|
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
|
|
|
# endif
|
2001-09-20 19:25:35 +00:00
|
|
|
# define INT64_C(value) value##LL
|
|
|
|
# define UINT64_C(value) value##uLL
|
2000-11-12 18:35:33 +00:00
|
|
|
# elif ULONG_MAX != 0xffffffff
|
|
|
|
|
|
|
|
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
|
|
|
|
# define INT64_C(value) value##L
|
|
|
|
# define UINT64_C(value) value##uL
|
|
|
|
# else
|
|
|
|
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# ifdef BOOST_NO_INT64_T
|
|
|
|
# define INTMAX_C(value) INT32_C(value)
|
|
|
|
# define UINTMAX_C(value) UINT32_C(value)
|
|
|
|
# else
|
|
|
|
# define INTMAX_C(value) INT64_C(value)
|
|
|
|
# define UINTMAX_C(value) UINT64_C(value)
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# endif // Borland/Microsoft specific width suffixes
|
|
|
|
|
|
|
|
|
2001-09-18 11:13:39 +00:00
|
|
|
#elif defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(__STDC_CONSTANT_MACROS) && !defined(BOOST_HAS_STDINT_H)
|
2000-11-12 18:35:33 +00:00
|
|
|
//
|
|
|
|
// undef all the macros:
|
|
|
|
//
|
|
|
|
# undef INT8_C
|
|
|
|
# undef INT16_C
|
|
|
|
# undef INT32_C
|
|
|
|
# undef INT64_C
|
|
|
|
# undef UINT8_C
|
|
|
|
# undef UINT16_C
|
|
|
|
# undef UINT32_C
|
|
|
|
# undef UINT64_C
|
|
|
|
# undef INTMAX_C
|
|
|
|
# undef UINTMAX_C
|
|
|
|
|
|
|
|
#endif // __STDC_CONSTANT_MACROS_DEFINED etc.
|
2001-01-24 12:18:30 +00:00
|
|
|
|
2001-05-11 10:47:57 +00:00
|
|
|
|