Add a couple #defines to stdint
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 28 Mar 2018 20:29:31 +0000 (16:29 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 28 Mar 2018 20:43:05 +0000 (16:43 -0400)
On occasion I want ULONG_MAX, LONG_MAX, and keep wondering if we have
SIZE_MAX.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/include/common.h
kern/include/stdint.h

index 920da6a..cba0003 100644 (file)
@@ -7,8 +7,6 @@
 #ifdef CONFIG_64BIT
 #endif
 
-#define SIZE_MAX        (~(size_t)0)
-
 // Efficient min and max operations
 #define MIN(_a, _b)                                            \
 ({                                                             \
index 229d21f..0c5b4c9 100644 (file)
 # define UINT16_MAX            (65535)
 # define UINT32_MAX            (4294967295U)
 # define UINT64_MAX            (__UINT64_C(18446744073709551615))
+
+#if NUM_ADDR_BITS == 64
+# define SIZE_MAX UINT64_MAX
+# define LONG_MAX INT64_MAX
+# define ULONG_MAX UINT64_MAX
+#elif NUM_ADDR_BITS == 32
+# define SIZE_MAX UINT32_MAX
+# define LONG_MAX INT32_MAX
+# define ULONG_MAX UINT32_MAX
+#else
+# error "NUM_ADDR_BITS is not set"
+#endif