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