diff options
Diffstat (limited to 'newlib/libc/include')
-rw-r--r-- | newlib/libc/include/stdint.h | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/newlib/libc/include/stdint.h b/newlib/libc/include/stdint.h index a95c149a2..59be0eb6c 100644 --- a/newlib/libc/include/stdint.h +++ b/newlib/libc/include/stdint.h @@ -28,6 +28,20 @@ extern "C" { #include <limits.h> #endif +/* Check if "long long" is 64bit wide */ +/* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */ +#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \ + || ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) ) +#define __have_longlong64 1 +#endif + +/* Check if "long" is 64bit or 32bit wide */ +#if __STDINT_EXP(LONG_MAX) > 0x7fffffff +#define __have_long64 1 +#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff +#define __have_long32 1 +#endif + #if __STDINT_EXP(SCHAR_MAX) == 0x7f typedef signed char int8_t ; typedef unsigned char uint8_t ; @@ -74,7 +88,6 @@ typedef unsigned int uint32_t; typedef signed long int32_t; typedef unsigned long uint32_t; #define __int32_t_defined 1 -#define __have_long32 1 #elif __STDINT_EXP(SHRT_MAX) == 0x7fffffffL typedef signed short int32_t; typedef unsigned short uint32_t; @@ -103,21 +116,14 @@ typedef uint32_t uint_least16_t; #endif #endif -#if __STDINT_EXP(LONG_MAX) > 0x7fffffff +#if __have_long64 typedef signed long int64_t; typedef unsigned long uint64_t; #define __int64_t_defined 1 -#define __have_long64 1 -#elif defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -#define __int64_t_defined 1 -#define __have_longlong64 1 -#elif defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) +#elif __have_longlong64 typedef signed long long int64_t; typedef unsigned long long uint64_t; #define __int64_t_defined 1 -#define __have_longlong64 1 #elif __STDINT_EXP(INT_MAX) > 0x7fffffff typedef signed int int64_t; typedef unsigned int uint64_t; @@ -163,9 +169,9 @@ typedef uint64_t uint_least32_t; typedef __UINTMAX_TYPE__ uintmax_t; #elif __have_longlong64 typedef unsigned long long uintmax_t; - #else +#else typedef unsigned long uintmax_t; - #endif +#endif /* * GCC doesn't provide an appropriate macro for [u]intptr_t @@ -232,7 +238,7 @@ typedef unsigned long uintptr_t; #define INT64_MIN (-9223372036854775807L-1L) #define INT64_MAX 9223372036854775807L #define UINT64_MAX 18446744073709551615U -#elif defined(__have_longlong64) +#elif __have_longlong64 #define INT64_MIN (-9223372036854775807LL-1LL) #define INT64_MAX 9223372036854775807LL #define UINT64_MAX 18446744073709551615ULL @@ -244,7 +250,7 @@ typedef unsigned long uintptr_t; #define INT_LEAST64_MIN (-9223372036854775807L-1L) #define INT_LEAST64_MAX 9223372036854775807L #define UINT_LEAST64_MAX 18446744073709551615U -#elif defined(__have_longlong64) +#elif __have_longlong64 #define INT_LEAST64_MIN (-9223372036854775807LL-1LL) #define INT_LEAST64_MAX 9223372036854775807LL #define UINT_LEAST64_MAX 18446744073709551615ULL |