| 1 |
// boost cstdint.hpp header file ------------------------------------------// |
| 2 |
|
| 3 |
// (C) Copyright Beman Dawes 1999. |
| 4 |
// (C) Copyright Jens Mauer 2001 |
| 5 |
// (C) Copyright John Maddock 2001 |
| 6 |
// Distributed under the Boost |
| 7 |
// Software License, Version 1.0. (See accompanying file |
| 8 |
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 9 |
|
| 10 |
// See http://www.boost.org/libs/integer for documentation. |
| 11 |
|
| 12 |
// Revision History |
| 13 |
// 31 Oct 01 use BOOST_HAS_LONG_LONG to check for "long long" (Jens M.) |
| 14 |
// 16 Apr 01 check LONGLONG_MAX when looking for "long long" (Jens Maurer) |
| 15 |
// 23 Jan 01 prefer "long" over "int" for int32_t and intmax_t (Jens Maurer) |
| 16 |
// 12 Nov 00 Merged <boost/stdint.h> (Jens Maurer) |
| 17 |
// 23 Sep 00 Added INTXX_C macro support (John Maddock). |
| 18 |
// 22 Sep 00 Better 64-bit support (John Maddock) |
| 19 |
// 29 Jun 00 Reimplement to avoid including stdint.h within namespace boost |
| 20 |
// 8 Aug 99 Initial version (Beman Dawes) |
| 21 |
|
| 22 |
|
| 23 |
#ifndef STDINT_H |
| 24 |
#define STDINT_H |
| 25 |
|
| 26 |
#ifndef UNDER_CE |
| 27 |
#include <crtdefs.h> |
| 28 |
#endif |
| 29 |
|
| 30 |
#include <limits.h> |
| 31 |
|
| 32 |
// These are fairly safe guesses for some 16-bit, and most 32-bit and 64-bit |
| 33 |
// platforms. For other systems, they will have to be hand tailored. |
| 34 |
// |
| 35 |
// Because the fast types are assumed to be the same as the undecorated types, |
| 36 |
// it may be possible to hand tailor a more efficient implementation. Such |
| 37 |
// an optimization may be illusionary; on the Intel x86-family 386 on, for |
| 38 |
// example, byte arithmetic and load/stores are as fast as "int" sized ones. |
| 39 |
|
| 40 |
// 8-bit types ------------------------------------------------------------// |
| 41 |
|
| 42 |
# if UCHAR_MAX == 0xff |
| 43 |
typedef signed char int8_t; |
| 44 |
typedef signed char int_least8_t; |
| 45 |
typedef signed char int_fast8_t; |
| 46 |
typedef unsigned char uint8_t; |
| 47 |
typedef unsigned char uint_least8_t; |
| 48 |
typedef unsigned char uint_fast8_t; |
| 49 |
# else |
| 50 |
# error defaults not correct; you must hand modify boost/cstdint.hpp |
| 51 |
# endif |
| 52 |
|
| 53 |
// 16-bit types -----------------------------------------------------------// |
| 54 |
|
| 55 |
# if USHRT_MAX == 0xffff |
| 56 |
# if defined(__crayx1) |
| 57 |
// The Cray X1 has a 16-bit short, however it is not recommend |
| 58 |
// for use in performance critical code. |
| 59 |
typedef short int16_t; |
| 60 |
typedef short int_least16_t; |
| 61 |
typedef int int_fast16_t; |
| 62 |
typedef unsigned short uint16_t; |
| 63 |
typedef unsigned short uint_least16_t; |
| 64 |
typedef unsigned int uint_fast16_t; |
| 65 |
# else |
| 66 |
typedef short int16_t; |
| 67 |
typedef short int_least16_t; |
| 68 |
typedef short int_fast16_t; |
| 69 |
typedef unsigned short uint16_t; |
| 70 |
typedef unsigned short uint_least16_t; |
| 71 |
typedef unsigned short uint_fast16_t; |
| 72 |
# endif |
| 73 |
# elif (USHRT_MAX == 0xffffffff) && defined(CRAY) |
| 74 |
// no 16-bit types on Cray: |
| 75 |
typedef short int_least16_t; |
| 76 |
typedef short int_fast16_t; |
| 77 |
typedef unsigned short uint_least16_t; |
| 78 |
typedef unsigned short uint_fast16_t; |
| 79 |
# else |
| 80 |
# error defaults not correct; you must hand modify boost/cstdint.hpp |
| 81 |
# endif |
| 82 |
|
| 83 |
// 32-bit types -----------------------------------------------------------// |
| 84 |
|
| 85 |
# if ULONG_MAX == 0xffffffff |
| 86 |
typedef long int32_t; |
| 87 |
typedef long int_least32_t; |
| 88 |
typedef long int_fast32_t; |
| 89 |
typedef unsigned long uint32_t; |
| 90 |
typedef unsigned long uint_least32_t; |
| 91 |
typedef unsigned long uint_fast32_t; |
| 92 |
# elif UINT_MAX == 0xffffffff |
| 93 |
typedef int int32_t; |
| 94 |
typedef int int_least32_t; |
| 95 |
typedef int int_fast32_t; |
| 96 |
typedef unsigned int uint32_t; |
| 97 |
typedef unsigned int uint_least32_t; |
| 98 |
typedef unsigned int uint_fast32_t; |
| 99 |
# else |
| 100 |
# error defaults not correct; you must hand modify boost/cstdint.hpp |
| 101 |
# endif |
| 102 |
|
| 103 |
// 64-bit types + intmax_t and uintmax_t ----------------------------------// |
| 104 |
|
| 105 |
// |
| 106 |
// we have Borland/Intel/Microsoft __int64: |
| 107 |
// |
| 108 |
typedef __int64 intmax_t; |
| 109 |
typedef unsigned __int64 uintmax_t; |
| 110 |
typedef __int64 int64_t; |
| 111 |
typedef __int64 int_least64_t; |
| 112 |
typedef __int64 int_fast64_t; |
| 113 |
typedef unsigned __int64 uint64_t; |
| 114 |
typedef unsigned __int64 uint_least64_t; |
| 115 |
typedef unsigned __int64 uint_fast64_t; |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
/**************************************************** |
| 120 |
|
| 121 |
Macro definition section: |
| 122 |
|
| 123 |
Define various INTXX_C macros only if |
| 124 |
__STDC_CONSTANT_MACROS is defined. |
| 125 |
|
| 126 |
Undefine the macros if __STDC_CONSTANT_MACROS is |
| 127 |
not defined and the macros are (cf <cassert>). |
| 128 |
|
| 129 |
Added 23rd September 2000 (John Maddock). |
| 130 |
Modified 11th September 2001 to be excluded when |
| 131 |
BOOST_HAS_STDINT_H is defined (John Maddock). |
| 132 |
|
| 133 |
******************************************************/ |
| 134 |
|
| 135 |
#if defined(__STDC_CONSTANT_MACROS) || !defined(__cplusplus) |
| 136 |
// |
| 137 |
// Borland/Intel/Microsoft compilers have width specific suffixes: |
| 138 |
// |
| 139 |
# define INT8_C(value) value##i8 |
| 140 |
# define INT16_C(value) value##i16 |
| 141 |
# define INT32_C(value) value##i32 |
| 142 |
# define INT64_C(value) value##i64 |
| 143 |
# define UINT8_C(value) value##ui8 |
| 144 |
# define UINT16_C(value) value##ui16 |
| 145 |
# define UINT32_C(value) value##ui32 |
| 146 |
# define UINT64_C(value) value##ui64 |
| 147 |
# define INTMAX_C(value) value##i64 |
| 148 |
# define UINTMAX_C(value) value##ui64 |
| 149 |
|
| 150 |
#endif // __STDC_CONSTANT_MACROS_DEFINED etc. |
| 151 |
|
| 152 |
#if defined(__STDC_LIMIT_MACROS) || !defined(__cplusplus) |
| 153 |
# define INT8_MIN INT8_C(-127)-1 |
| 154 |
# define INT8_MAX INT8_C(127) |
| 155 |
# define INT16_MIN INT16_C(-32767)-1 |
| 156 |
# define INT16_MAX INT16_C(32767) |
| 157 |
# define INT32_MIN INT32_C(-2147483647)-1 |
| 158 |
# define INT32_MAX INT32_C(2147483647) |
| 159 |
# define INT64_MAX INT64_C(9223372036854775807) |
| 160 |
# define UINT8_MAX UINT8_C(255) |
| 161 |
# define UINT16_MAX UINT16_C(65535) |
| 162 |
# define UINT32_MAX UINT32_C(4294967295) |
| 163 |
# define UINT64_MAX UINT64_C(18446744073709551615) |
| 164 |
#endif |
| 165 |
|
| 166 |
#ifdef UNDER_CE |
| 167 |
typedef unsigned long uintptr_t; |
| 168 |
typedef long intptr_t; |
| 169 |
#endif |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
#endif // BOOST_CSTDINT_HPP |
| 174 |
|