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