summaryrefslogtreecommitdiff
path: root/payloads
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2019-03-27 14:41:56 -0700
committerPatrick Georgi <pgeorgi@google.com>2019-04-10 10:43:27 +0000
commit18c1b6b240b675c877b8bd731dfd58f5723d0c57 (patch)
tree430b903f8e227d41a83a11ef98d30d17f97b0a41 /payloads
parentf5b76fe9e9dc179cc0e29f724d132e530f88b401 (diff)
downloadcoreboot-18c1b6b240b675c877b8bd731dfd58f5723d0c57.tar.xz
libpayload: limits.h: Provide reliable definitions for all XXX_MAX/MIN
Our current limits.h only provides (U)INT_MAX constants. This patch adds most others expected by POSIX. Since some of these may be different depending on architecture (e.g. 'long' is 32-bit on x86 and 64-bit on arm64), provide a definition that will automatically figure out the right value for the data model the compiler is using (as long as it's using two's complement for signed integers, which I think we can assume these days). Change-Id: I1124a41279abd4f53d208270e392e590ca8eaada Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/32085 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'payloads')
-rw-r--r--payloads/libpayload/include/limits.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/payloads/libpayload/include/limits.h b/payloads/libpayload/include/limits.h
index 2fecf239b0..4238e0e90b 100644
--- a/payloads/libpayload/include/limits.h
+++ b/payloads/libpayload/include/limits.h
@@ -40,7 +40,20 @@
# endif
#endif
-#define UINT_MAX (unsigned int)0xffffffff
-#define INT_MAX (unsigned int)0x7fffffff
+#define USHRT_MAX ((unsigned short int)~0U)
+#define SHRT_MIN ((short int)(USHRT_MAX & ~(USHRT_MAX >> 1)))
+#define SHRT_MAX ((short int)(USHRT_MAX >> 1))
+
+#define UINT_MAX ((unsigned int)~0U)
+#define INT_MIN ((int)(UINT_MAX & ~(UINT_MAX >> 1)))
+#define INT_MAX ((int)(UINT_MAX >> 1))
+
+#define ULONG_MAX ((unsigned long int)~0UL)
+#define LONG_MIN ((long int)(ULONG_MAX & ~(ULONG_MAX >> 1)))
+#define LONG_MAX ((long int)(ULONG_MAX >> 1))
+
+#define ULLONG_MAX ((unsigned long long int)~0UL)
+#define LLONG_MIN ((long long int)(ULLONG_MAX & ~(ULLONG_MAX >> 1)))
+#define LLONG_MAX ((long long int)(ULLONG_MAX >> 1))
#endif