2 * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2007 The Regents of the University of California.
4 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
8 * This file is part of the SPL, Solaris Porting Layer.
10 * The SPL is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
15 * The SPL is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * You should have received a copy of the GNU General Public License along
21 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef _SPL_ISA_DEFS_H
25 #define _SPL_ISA_DEFS_H
27 /* x86_64 arch specific defines */
28 #if defined(__x86_64) || defined(__x86_64__)
30 #if !defined(__x86_64)
43 /* x32-specific defines; careful to *not* define _LP64 here */
50 /* i386 arch specific defines */
51 #elif defined(__i386) || defined(__i386__)
65 /* powerpc (ppc64) arch specific defines */
66 #elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__)
68 #if !defined(__powerpc)
72 #if !defined(__powerpc__)
76 #if defined(__powerpc64__)
86 /* arm arch specific defines */
87 #elif defined(__arm) || defined(__arm__)
101 #if defined(__ARMEL__)
102 #define _ZFS_LITTLE_ENDIAN
104 #define _ZFS_BIG_ENDIAN
107 /* aarch64 arch specific defines */
108 #elif defined(__aarch64__)
114 #if defined(__AARCH64EL__)
115 #define _ZFS_LITTLE_ENDIAN
117 #define _ZFS_BIG_ENDIAN
120 /* sparc arch specific defines */
121 #elif defined(__sparc) || defined(__sparc__)
123 #if !defined(__sparc)
127 #if !defined(__sparc__)
131 #if defined(__arch64__)
141 #define _ZFS_BIG_ENDIAN
142 #define _SUNOS_VTOC_16
144 /* s390 arch specific defines */
145 #elif defined(__s390__)
146 #if defined(__s390x__)
156 #define _ZFS_BIG_ENDIAN
158 /* MIPS arch specific defines */
159 #elif defined(__mips__)
161 #if defined(__MIPSEB__)
162 #define _ZFS_BIG_ENDIAN
163 #elif defined(__MIPSEL__)
164 #define _ZFS_LITTLE_ENDIAN
166 #error MIPS no endian specified
173 #define _SUNOS_VTOC_16
176 * RISC-V arch specific defines
177 * only RV64G (including atomic) LP64 is supported yet
179 #elif defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64 && \
180 defined(__riscv_atomic) && __riscv_atomic
194 #define _ZFS_LITTLE_ENDIAN
196 #define _SUNOS_VTOC_16
199 * LoongArch arch specific defines
200 * only LoongArch64 is supported yet
202 #elif defined(__loongarch__) && defined(__loongarch_lp64)
208 #define _ZFS_LITTLE_ENDIAN
209 #define _SUNOS_VTOC_16
211 /* not all LoongArch cores support unaligned accesses in hardware */
212 #define _ALIGNMENT_REQUIRED 1
216 * Currently supported:
217 * x86_64, x32, i386, arm, powerpc, s390, sparc, mips, RV64G, and LoongArch64
219 #error "Unsupported ISA type"
222 #if defined(_ILP32) && defined(_LP64)
223 #error "Both _ILP32 and _LP64 are defined"
226 #if !defined(_ILP32) && !defined(_LP64)
227 #error "Neither _ILP32 or _LP64 are defined"
230 #include <sys/byteorder.h>
233 * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS will be defined by the Linux
234 * kernel for architectures which support efficient unaligned access.
236 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
237 #define HAVE_EFFICIENT_UNALIGNED_ACCESS
240 #if defined(_ZFS_LITTLE_ENDIAN) && defined(_ZFS_BIG_ENDIAN)
241 #error "Both _ZFS_LITTLE_ENDIAN and _ZFS_BIG_ENDIAN are defined"
244 #if !defined(_ZFS_LITTLE_ENDIAN) && !defined(_ZFS_BIG_ENDIAN)
245 #error "Neither _ZFS_LITTLE_ENDIAN or _ZFS_BIG_ENDIAN are defined"
248 #endif /* _SPL_ISA_DEFS_H */