Diff between 75cfe39fa7974d10b925e5e3ab5bd4e3ffab6b54 and 7261d9f12f9863beb5f09fde92174d0775b5c4eb

Changed Files

File Additions Deletions Status
src/shared/util.h +16 -0 modified

Full Patch

diff --git a/src/shared/util.h b/src/shared/util.h
index f0d2368..e93b742 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -55,6 +55,22 @@
 #error "Unknown byte order"
 #endif
 
+#define get_unaligned(ptr)			\
+({						\
+	struct __attribute__((packed)) {	\
+		typeof(*(ptr)) __v;		\
+	} *__p = (typeof(__p)) (ptr);		\
+	__p->__v;				\
+})
+
+#define put_unaligned(val, ptr)			\
+do {						\
+	struct __attribute__((packed)) {	\
+		typeof(*(ptr)) __v;		\
+	} *__p = (typeof(__p)) (ptr);		\
+	__p->__v = (val);			\
+} while (0)
+
 #define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
 #define UINT_TO_PTR(u) ((void *) ((uintptr_t) (u)))