xref: /DragonStub/inc/dragonstub/linux/unaligned.h (revision 3e6106c4d60a23aae3c0740979c5e6fb728b63c3)
1 #pragma once
2 
3 #define __get_unaligned_t(type, ptr)                        \
4 	({                                                  \
5 		const struct {                              \
6 			type x;                             \
7 		} __packed *__pptr = (typeof(__pptr))(ptr); \
8 		__pptr->x;                                  \
9 	})
10 
11 #define __put_unaligned_t(type, val, ptr)                   \
12 	do {                                                \
13 		struct {                                    \
14 			type x;                             \
15 		} __packed *__pptr = (typeof(__pptr))(ptr); \
16 		__pptr->x = (val);                          \
17 	} while (0)
18