diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/cbasetypes.h | 89 |
1 files changed, 33 insertions, 56 deletions
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 906e4f31b..e2fe17555 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -79,14 +79,8 @@ ////////////////////////////////////////////////////////////////////////// #include <inttypes.h> #include <stdint.h> - -////////////////////////////////////////////////////////////////////////// -// typedefs to compensate type size change from 32bit to 64bit -// MS implements LLP64 model, normal unix does LP64, -// only Silicon Graphics/Cray goes ILP64 so don't care (and don't support) -////////////////////////////////////////////////////////////////////////// - #include <limits.h> + // ILP64 isn't supported, so always 32 bits? #ifndef UINT_MAX #define UINT_MAX 0xffffffff @@ -96,49 +90,56 @@ // Integers with guaranteed _exact_ size. ////////////////////////////////////////////////////////////////////////// -#define SIZEOF_LONG 4 -#define SIZEOF_INT 4 -#define HAVE_INT_8_16_32 +typedef int8_t int8; +typedef int16_t int16; +typedef int32_t int32; +typedef int64_t int64; -typedef char int8; -typedef short int16; -typedef int int32; +typedef int8_t sint8; +typedef int16_t sint16; +typedef int32_t sint32; +typedef int64_t sint64; -typedef signed char sint8; -typedef signed short sint16; -typedef signed int sint32; - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; +typedef uint8_t uint8; +typedef uint16_t uint16; +typedef uint32_t uint32; +typedef uint64_t uint64; #undef UINT8_MIN #undef UINT16_MIN #undef UINT32_MIN -#define UINT8_MIN ((uint8) 0) -#define UINT16_MIN ((uint16)0) -#define UINT32_MIN ((uint32)0) +#undef UINT64_MIN +#define UINT8_MIN ((uint8) UINT8_C(0x00)) +#define UINT16_MIN ((uint16)UINT16_C(0x0000)) +#define UINT32_MIN ((uint32)UINT32_C(0x00000000)) +#define UINT64_MIN ((uint64)UINT64_C(0x0000000000000000)) #undef UINT8_MAX #undef UINT16_MAX #undef UINT32_MAX -#define UINT8_MAX ((uint8) 0xFF) -#define UINT16_MAX ((uint16)0xFFFF) -#define UINT32_MAX ((uint32)0xFFFFFFFF) +#undef UINT64_MAX +#define UINT8_MAX ((uint8) UINT8_C(0xFF)) +#define UINT16_MAX ((uint16)UINT16_C(0xFFFF)) +#define UINT32_MAX ((uint32)UINT32_C(0xFFFFFFFF)) +#define UINT64_MAX ((uint64)UINT64_C(0xFFFFFFFFFFFFFFFF)) #undef SINT8_MIN #undef SINT16_MIN #undef SINT32_MIN -#define SINT8_MIN ((sint8) 0x80) -#define SINT16_MIN ((sint16)0x8000) -#define SINT32_MIN ((sint32)0x80000000) +#undef SINT64_MIN +#define SINT8_MIN ((sint8) INT8_C(0x80)) +#define SINT16_MIN ((sint16)INT16_C(0x8000)) +#define SINT32_MIN ((sint32)INT32_C(0x80000000)) +#define SINT64_MIN ((sint32)INT64_C(0x8000000000000000)) #undef SINT8_MAX #undef SINT16_MAX #undef SINT32_MAX -#define SINT8_MAX ((sint8) 0x7F) -#define SINT16_MAX ((sint16)0x7FFF) -#define SINT32_MAX ((sint32)0x7FFFFFFF) +#undef SINT64_MAX +#define SINT8_MAX ((sint8) INT8_C(0x7F)) +#define SINT16_MAX ((sint16)INT16_C(0x7FFF)) +#define SINT32_MAX ((sint32)INT32_C(0x7FFFFFFF)) +#define SINT64_MAX ((sint64)INT64_C(0x7FFFFFFFFFFFFFFF)) ////////////////////////////////////////////////////////////////////////// // Integers with guaranteed _minimum_ size. @@ -174,30 +175,6 @@ typedef int ssize_t; ////////////////////////////////////////////////////////////////////////// -// portable 64-bit integers -////////////////////////////////////////////////////////////////////////// -#if defined(_MSC_VER) || defined(__BORLANDC__) -typedef __int64 int64; -typedef signed __int64 sint64; -typedef unsigned __int64 uint64; -#else -typedef long long int64; -typedef signed long long sint64; -typedef unsigned long long uint64; -#endif - -#ifndef INT64_MIN -#define INT64_MIN (INT64_C(-9223372036854775807)-1) -#endif -#ifndef INT64_MAX -#define INT64_MAX (INT64_C(9223372036854775807)) -#endif -#ifndef UINT64_MAX -#define UINT64_MAX (UINT64_C(18446744073709551615)) -#endif - - -////////////////////////////////////////////////////////////////////////// // pointer sized integers ////////////////////////////////////////////////////////////////////////// typedef intptr_t intptr; |