aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/platform.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/platform.h')
-rw-r--r--src/utils/platform.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/utils/platform.h b/src/utils/platform.h
new file mode 100644
index 0000000..9ab734b
--- /dev/null
+++ b/src/utils/platform.h
@@ -0,0 +1,19 @@
+#include <stddef.h>
+#include <errno.h>
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+#include <endian.h>
+
+#define le16_to_cpu le16toh
+#define le32_to_cpu le32toh
+#define get_unaligned(p) \
+({ \
+ struct packed_dummy_struct { \
+ typeof(*(p)) __val; \
+ } __attribute__((packed)) *__ptr = (void *) (p); \
+ \
+ __ptr->__val; \
+})
+#define get_unaligned_le16(p) le16_to_cpu(get_unaligned((uint16_t *)(p)))
+#define get_unaligned_le32(p) le32_to_cpu(get_unaligned((uint32_t *)(p)))