diff mbox

[2/3] kernel.h: define u8, s8, u32, etc. limits

Message ID 52E6DA84.6070505@linaro.org
State New
Headers show

Commit Message

Alex Elder Jan. 27, 2014, 10:15 p.m. UTC
-------- Original Message --------
Subject: [PATCH 2/3] kernel.h: define u8, s8, u32, etc. limits
Date: Thu, 26 Dec 2013 09:12:20 -0600
From: Alex Elder <alex.elder@linaro.org>
To: Sage Weil <sage@inktank.com>, David Miller <davem@davemloft.net>,
kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org,
kaber@trash.net, Al Viro <viro@ZenIV.linux.org.uk>, jeffm@suse.com,
Steven Rostedt <rostedt@goodmis.org>, Andrew Morton
<akpm@linux-foundation.org>, mst@redhat.com,  Ingo Molnar <mingo@kernel.org>

Create constants that define the maximum and minimum values
representable by the kernel types u8, s8, u16, s16, and so on.

Signed-off-by: Alex Elder <elder@linaro.org>
---
 include/linux/kernel.h |   13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox

Patch

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index ecb8754..915e07b 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -29,6 +29,19 @@ 
 #define ULLONG_MAX	(~0ULL)
 #define SIZE_MAX	(~(size_t)0)

+#define U8_MAX		(~(u8)0)
+#define S8_MAX		((s8)(U8_MAX>>1))
+#define S8_MIN		((s8)(-S8_MAX - 1))
+#define U16_MAX		(~(u16)0)
+#define S16_MAX		((s16)(U16_MAX>>1))
+#define S16_MIN		((s16)(-S16_MAX - 1))
+#define U32_MAX		(~(u32)0)
+#define S32_MAX		((s32)(U32_MAX>>1))
+#define S32_MIN		((s32)(-S32_MAX - 1))
+#define U64_MAX		(~(u64)0)
+#define S64_MAX		((s64)(U64_MAX>>1))
+#define S64_MIN		((s64)(-S64_MAX - 1))
+
 #define STACK_MAGIC	0xdeadbeef

 #define REPEAT_BYTE(x)	((~0ul / 0xff) * (x))