unaligned.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_GENERIC_UNALIGNED_H
  3. #define __ASM_GENERIC_UNALIGNED_H
  4. /*
  5. * This is the most generic implementation of unaligned accesses
  6. * and should work almost anywhere.
  7. */
  8. #include <asm/byteorder.h>
  9. /* Set by the arch if it can handle unaligned accesses in hardware. */
  10. #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
  11. # include <linux/unaligned/access_ok.h>
  12. #endif
  13. #if defined(__LITTLE_ENDIAN)
  14. # ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
  15. # include <linux/unaligned/le_struct.h>
  16. # include <linux/unaligned/be_byteshift.h>
  17. # endif
  18. # include <linux/unaligned/generic.h>
  19. # define get_unaligned __get_unaligned_le
  20. # define put_unaligned __put_unaligned_le
  21. #elif defined(__BIG_ENDIAN)
  22. # ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
  23. # include <linux/unaligned/be_struct.h>
  24. # include <linux/unaligned/le_byteshift.h>
  25. # endif
  26. # include <linux/unaligned/generic.h>
  27. # define get_unaligned __get_unaligned_be
  28. # define put_unaligned __put_unaligned_be
  29. #else
  30. # error need to define endianess
  31. #endif
  32. #endif /* __ASM_GENERIC_UNALIGNED_H */