aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Dillmann <[email protected]>2013-01-28 23:48:11 +0100
committerBrian Behlendorf <[email protected]>2013-01-29 09:30:23 -0800
commit3cbfd259b709e3561b4b407d4a27eeec6dc201d0 (patch)
treef8b4458104a9ddd4ebd6b16675c22dc1f819c915 /include
parent0936c3449fc81caeed49d23e1705a9decd964700 (diff)
Define BE_IN16 & BE_IN32 for lz4 compression
The new lz4 compression algorithm, zfsonlinux/zfs@9759c60, requires the generic BE_IN16 and BE_IN32 functions. These are added to the SPL for other consumers to take advantage of. Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/sys/byteorder.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/sys/byteorder.h b/include/sys/byteorder.h
index 30700f6b3..d09f5bf3e 100644
--- a/include/sys/byteorder.h
+++ b/include/sys/byteorder.h
@@ -34,4 +34,13 @@
#define BE_32(x) cpu_to_be32(x)
#define BE_64(x) cpu_to_be64(x)
+#define BE_IN8(xa) \
+ *((uint8_t *)(xa))
+
+#define BE_IN16(xa) \
+ (((uint16_t)BE_IN8(xa) << 8) | BE_IN8((uint8_t *)(xa)+1))
+
+#define BE_IN32(xa) \
+ (((uint32_t)BE_IN16(xa) << 16) | BE_IN16((uint8_t *)(xa)+2))
+
#endif /* SPL_BYTEORDER_H */