summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2014-07-26 17:24:43 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-07-28 07:31:18 +0200
commit7df5350362a21cf74c1e87542a33345b100aeb6f (patch)
treef8d90a431c6d88afb13a7b21aaf8af02bb9f09e4
parent343ccff163789949f2c683dcea819ceb68dbcf02 (diff)
downloadbarebox-7df5350362a21cf74c1e87542a33345b100aeb6f.tar.gz
include: import {lower,upper}_32_bits helpers
This imports {lower,upper}_32_bits defines to allow to get upper and lower 32b part of a 64b number. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--include/common.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
index e7ab5fe..9919fa4 100644
--- a/include/common.h
+++ b/include/common.h
@@ -281,6 +281,22 @@ void barebox_set_hostname(const char *);
} \
)
+/**
+ * upper_32_bits - return bits 32-63 of a number
+ * @n: the number we're accessing
+ *
+ * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
+ * the "right shift count >= width of type" warning when that quantity is
+ * 32-bits.
+ */
+#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
+
+/**
+ * lower_32_bits - return bits 0-31 of a number
+ * @n: the number we're accessing
+ */
+#define lower_32_bits(n) ((u32)(n))
+
#define abs(x) ({ \
long __x = (x); \
(__x < 0) ? -__x : __x; \