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 #define _ALIGNMENT_REQUIRED 1
53 /* i386 arch specific defines */
54 #elif defined(__i386) || defined(__i386__)
68 #define _ALIGNMENT_REQUIRED 0
70 /* powerpc (ppc64) arch specific defines */
71 #elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__)
73 #if !defined(__powerpc)
77 #if !defined(__powerpc__)
81 #if defined(__powerpc64__)
92 * Illumos doesn't define _ALIGNMENT_REQUIRED for PPC, so default to 1
95 #define _ALIGNMENT_REQUIRED 1
97 /* arm arch specific defines */
98 #elif defined(__arm) || defined(__arm__) || defined(__aarch64__)
104 #if !defined(__arm__)
108 #if defined(__aarch64__)
118 #if defined(__ARMEL__) || defined(__AARCH64EL__)
119 #define _ZFS_LITTLE_ENDIAN
121 #define _ZFS_BIG_ENDIAN
125 * Illumos doesn't define _ALIGNMENT_REQUIRED for ARM, so default to 1
128 #define _ALIGNMENT_REQUIRED 1
130 /* sparc arch specific defines */
131 #elif defined(__sparc) || defined(__sparc__)
133 #if !defined(__sparc)
137 #if !defined(__sparc__)
141 #if defined(__arch64__)
151 #define _ZFS_BIG_ENDIAN
152 #define _SUNOS_VTOC_16
153 #define _ALIGNMENT_REQUIRED 1
155 /* s390 arch specific defines */
156 #elif defined(__s390__)
157 #if defined(__s390x__)
167 #define _ZFS_BIG_ENDIAN
170 * Illumos doesn't define _ALIGNMENT_REQUIRED for s390, so default to 1
173 #define _ALIGNMENT_REQUIRED 1
175 /* MIPS arch specific defines */
176 #elif defined(__mips__)
178 #if defined(__MIPSEB__)
179 #define _ZFS_BIG_ENDIAN
180 #elif defined(__MIPSEL__)
181 #define _ZFS_LITTLE_ENDIAN
183 #error MIPS no endian specified
190 #define _SUNOS_VTOC_16
193 * Illumos doesn't define _ALIGNMENT_REQUIRED for MIPS, so default to 1
196 #define _ALIGNMENT_REQUIRED 1
199 * RISC-V arch specific defines
200 * only RV64G (including atomic) LP64 is supported yet
202 #elif defined(__riscv) && defined(_LP64) && _LP64 && \
203 defined(__riscv_atomic) && __riscv_atomic
213 #define _ZFS_LITTLE_ENDIAN
215 #define _SUNOS_VTOC_16
217 #define _ALIGNMENT_REQUIRED 1
221 * Currently supported:
222 * x86_64, x32, i386, arm, powerpc, s390, sparc, mips, and RV64G
224 #error "Unsupported ISA type"
227 #if defined(_ILP32) && defined(_LP64)
228 #error "Both _ILP32 and _LP64 are defined"
231 #if !defined(_ILP32) && !defined(_LP64)
232 #error "Neither _ILP32 or _LP64 are defined"
235 #include <sys/byteorder.h>
238 * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS will be defined by the Linux
239 * kernel for architectures which support efficient unaligned access.
241 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
242 #define HAVE_EFFICIENT_UNALIGNED_ACCESS
245 #if defined(_ZFS_LITTLE_ENDIAN) && defined(_ZFS_BIG_ENDIAN)
246 #error "Both _ZFS_LITTLE_ENDIAN and _ZFS_BIG_ENDIAN are defined"
249 #if !defined(_ZFS_LITTLE_ENDIAN) && !defined(_ZFS_BIG_ENDIAN)
250 #error "Neither _ZFS_LITTLE_ENDIAN or _ZFS_BIG_ENDIAN are defined"
253 #endif /* _SPL_ISA_DEFS_H */