unaligned.h 636 B

1234567891011121314151617
  1. #pragma once
  2. #define __get_unaligned_t(type, ptr) \
  3. ({ \
  4. const struct { \
  5. type x; \
  6. } __packed *__pptr = (typeof(__pptr))(ptr); \
  7. __pptr->x; \
  8. })
  9. #define __put_unaligned_t(type, val, ptr) \
  10. do { \
  11. struct { \
  12. type x; \
  13. } __packed *__pptr = (typeof(__pptr))(ptr); \
  14. __pptr->x = (val); \
  15. } while (0)