unaligned.h 737 B

12345678910111213141516171819202122232425
  1. #ifndef __ASM_AVR32_UNALIGNED_H
  2. #define __ASM_AVR32_UNALIGNED_H
  3. /*
  4. * AVR32 can handle some unaligned accesses, depending on the
  5. * implementation. The AVR32 AP implementation can handle unaligned
  6. * words, but halfwords must be halfword-aligned, and doublewords must
  7. * be word-aligned.
  8. *
  9. * TODO: Make all this CPU-specific and optimize.
  10. */
  11. #include <linux/string.h>
  12. /* Use memmove here, so gcc does not insert a __builtin_memcpy. */
  13. #define get_unaligned(ptr) \
  14. ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; })
  15. #define put_unaligned(val, ptr) \
  16. ({ __typeof__(*(ptr)) __tmp = (val); \
  17. memmove((ptr), &__tmp, sizeof(*(ptr))); \
  18. (void)0; })
  19. #endif /* __ASM_AVR32_UNALIGNED_H */