From 3cbfd259b709e3561b4b407d4a27eeec6dc201d0 Mon Sep 17 00:00:00 2001 From: Eric Dillmann Date: Mon, 28 Jan 2013 23:48:11 +0100 Subject: 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 --- include/sys/byteorder.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/sys') 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 */ -- cgit v1.2.3