]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
limits.h: provide all limit macros for standard [u]intNN_t types
authorRasmus Villemoes <ravi@prevas.dk>
Mon, 7 Jul 2025 20:36:55 +0000 (22:36 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 14 Jul 2025 18:43:28 +0000 (12:43 -0600)
Currently, we only have UINT32_MAX and UINT64_MAX in limits.h, and
then stdint.h and kernel.h somewhat randomly define UINT8_MAX and
INT32_MAX, respectively.

Provide a full set of definitions in terms of the min/max macros for
the types that [u]intNN_t are defined in terms of, namely the {s,u}NN
ones.

Try to avoid breaking whatever depended on getting UINT8_MAX from our
compat stdint.h by replacing it with an include of limits.h.

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

index c2e3d0302b7adf5fa2cfaecbe909e42fa25acdc0..a032bc5b84d1e3fd4ad5fb945225af5532515fd5 100644 (file)
 #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))
index d3d979834aed9d3d7483e50772b908947a659a45..e0443ecac8452a3d5d379aebd5919033a0be0baf 100644 (file)
@@ -5,8 +5,6 @@
 #include <linux/printk.h> /* for printf/pr_* utilities */
 #include <limits.h>
 
-#define INT32_MAX      S32_MAX
-
 #define STACK_MAGIC    0xdeadbeef
 
 #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))
index dea83c8226a0608c17a3e703987ebc2c3085eed2..90fd2bdee080ee3655bb19c6b7a1e7c787b9e836 100644 (file)
@@ -9,6 +9,6 @@
 #ifndef __UB_STDINT_H
 #define __UB_STDINT_H
 
-#define UINT8_MAX      0xff
+#include <limits.h>
 
 #endif