diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/limits.h | 58 | ||||
-rw-r--r-- | include/linux/kernel.h | 26 | ||||
-rw-r--r-- | include/stdint.h | 2 |
3 files changed, 55 insertions, 31 deletions
diff --git a/include/limits.h b/include/limits.h index 1d0bbf69be7..a032bc5b84d 100644 --- a/include/limits.h +++ b/include/limits.h @@ -3,11 +3,61 @@ #ifndef _LIMITS_H #define _LIMITS_H -#define INT_MAX 0x7fffffff -#define UINT_MAX 0xffffffffU +#define SCHAR_MAX __SCHAR_MAX__ +#define SCHAR_MIN (-SCHAR_MAX - 1) +#define UCHAR_MAX (SCHAR_MAX * 2 + 1) + +#ifdef __CHAR_UNSIGNED__ +#define CHAR_MAX UCHAR_MAX +#define CHAR_MIN 0 +#else +#define CHAR_MAX SCHAR_MAX +#define CHAR_MIN SCHAR_MIN +#endif + +#define SHRT_MAX __SHRT_MAX__ +#define SHRT_MIN (-SHRT_MAX - 1) +#define USHRT_MAX (SHRT_MAX * 2 + 1) + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) +#define UINT_MAX (INT_MAX * 2U + 1U) + +#define LONG_MAX __LONG_MAX__ +#define LONG_MIN (-LONG_MAX - 1L) +#define ULONG_MAX (LONG_MAX * 2UL + 1UL) + +#define LLONG_MAX __LONG_LONG_MAX__ +#define LLONG_MIN (-LLONG_MAX - 1LL) +#define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) + +#define U8_MAX UCHAR_MAX +#define S8_MAX SCHAR_MAX +#define S8_MIN SCHAR_MIN +#define U16_MAX USHRT_MAX +#define S16_MAX SHRT_MAX +#define S16_MIN SHRT_MIN +#define U32_MAX UINT_MAX +#define S32_MAX INT_MAX +#define S32_MIN INT_MIN +#define U64_MAX ULLONG_MAX +#define S64_MAX LLONG_MAX +#define S64_MIN LLONG_MIN + +#define UINT8_MAX U8_MAX +#define INT8_MAX S8_MAX +#define INT8_MIN S8_MIN +#define UINT16_MAX U16_MAX +#define INT16_MAX S16_MAX +#define INT16_MIN S16_MIN +#define UINT32_MAX U32_MAX +#define INT32_MAX S32_MAX +#define INT32_MIN S32_MIN +#define UINT64_MAX U64_MAX +#define INT64_MAX S64_MAX +#define INT64_MIN S64_MIN + #define CHAR_BIT 8 -#define UINT32_MAX 0xffffffffU -#define UINT64_MAX 0xffffffffffffffffULL #if (defined(CONFIG_64BIT) && !defined(CONFIG_SPL_BUILD)) || \ (defined(CONFIG_SPL_64BIT) && defined(CONFIG_SPL_BUILD)) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 9467edd65ab..e0443ecac84 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -5,32 +5,6 @@ #include <linux/printk.h> /* for printf/pr_* utilities */ #include <limits.h> -#define USHRT_MAX ((u16)(~0U)) -#define SHRT_MAX ((s16)(USHRT_MAX>>1)) -#define SHRT_MIN ((s16)(-SHRT_MAX - 1)) -#define INT_MIN (-INT_MAX - 1) -#define LONG_MAX ((long)(~0UL>>1)) -#define LONG_MIN (-LONG_MAX - 1) -#define ULONG_MAX (~0UL) -#define LLONG_MAX ((long long)(~0ULL>>1)) -#define LLONG_MIN (-LLONG_MAX - 1) -#define ULLONG_MAX (~0ULL) - -#define U8_MAX ((u8)~0U) -#define S8_MAX ((s8)(U8_MAX>>1)) -#define S8_MIN ((s8)(-S8_MAX - 1)) -#define U16_MAX ((u16)~0U) -#define S16_MAX ((s16)(U16_MAX>>1)) -#define S16_MIN ((s16)(-S16_MAX - 1)) -#define U32_MAX ((u32)~0U) -#define S32_MAX ((s32)(U32_MAX>>1)) -#define S32_MIN ((s32)(-S32_MAX - 1)) -#define U64_MAX ((u64)~0ULL) -#define S64_MAX ((s64)(U64_MAX>>1)) -#define S64_MIN ((s64)(-S64_MAX - 1)) - -#define INT32_MAX S32_MAX - #define STACK_MAGIC 0xdeadbeef #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) diff --git a/include/stdint.h b/include/stdint.h index dea83c8226a..90fd2bdee08 100644 --- a/include/stdint.h +++ b/include/stdint.h @@ -9,6 +9,6 @@ #ifndef __UB_STDINT_H #define __UB_STDINT_H -#define UINT8_MAX 0xff +#include <limits.h> #endif |