]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
move limits for sNN/uNN types from kernel.h to limits.h
authorRasmus Villemoes <ravi@prevas.dk>
Mon, 7 Jul 2025 20:36:54 +0000 (22:36 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 14 Jul 2025 18:43:28 +0000 (12:43 -0600)
Since we define the {s,u}{8,16,32,64} types the same way on all
architectures, i.e. everybody uses asm-generic/int-ll64.h, we can just
define the associated limit macros in terms of those for the
corresponding types. This eliminates another set of limit macros that
are not usable in #if conditionals.

These type names and macros are not C or POSIX, so there's no language
violation, but certainly a violation of developers' reasonable
expectations.

Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
include/limits.h
include/linux/kernel.h

index 4dcfbe9b15665b68145db1ee3cf588aff45b6d85..c2e3d0302b7adf5fa2cfaecbe909e42fa25acdc0 100644 (file)
 #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 CHAR_BIT    8
 #define UINT32_MAX  0xffffffffU
 #define UINT64_MAX  0xffffffffffffffffULL
index f26274fbe1d247bfb304927f818e5c8fa70e7dc6..d3d979834aed9d3d7483e50772b908947a659a45 100644 (file)
@@ -5,19 +5,6 @@
 #include <linux/printk.h> /* for printf/pr_* utilities */
 #include <limits.h>
 
-#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