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.
9 * For details, see <http://zfsonlinux.org/>.
11 * The SPL is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
16 * The SPL is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * You should have received a copy of the GNU General Public License along
22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
25 #ifndef _SPL_ISA_DEFS_H
26 #define _SPL_ISA_DEFS_H
28 /* x86_64 arch specific defines */
29 #if defined(__x86_64) || defined(__x86_64__)
31 #if !defined(__x86_64)
44 /* x32-specific defines; careful to *not* define _LP64 here */
51 #define _ALIGNMENT_REQUIRED 1
54 /* i386 arch specific defines */
55 #elif defined(__i386) || defined(__i386__)
69 #define _ALIGNMENT_REQUIRED 0
71 /* powerpc (ppc64) arch specific defines */
72 #elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__)
74 #if !defined(__powerpc)
78 #if !defined(__powerpc__)
82 #if defined(__powerpc64__)
93 * Illumos doesn't define _ALIGNMENT_REQUIRED for PPC, so default to 1
96 #define _ALIGNMENT_REQUIRED 1
98 /* arm arch specific defines */
99 #elif defined(__arm) || defined(__arm__) || defined(__aarch64__)
105 #if !defined(__arm__)
109 #if defined(__aarch64__)
119 #if defined(__ARMEL__) || defined(__AARCH64EL__)
120 #define _LITTLE_ENDIAN
126 * Illumos doesn't define _ALIGNMENT_REQUIRED for ARM, so default to 1
129 #define _ALIGNMENT_REQUIRED 1
131 /* sparc arch specific defines */
132 #elif defined(__sparc) || defined(__sparc__)
134 #if !defined(__sparc)
138 #if !defined(__sparc__)
142 #if defined(__arch64__)
153 #define _SUNOS_VTOC_16
154 #define _ALIGNMENT_REQUIRED 1
156 /* s390 arch specific defines */
157 #elif defined(__s390__)
158 #if defined(__s390x__)
171 * Illumos doesn't define _ALIGNMENT_REQUIRED for s390, so default to 1
174 #define _ALIGNMENT_REQUIRED 1
176 /* MIPS arch specific defines */
177 #elif defined(__mips__)
179 #if defined(__MIPSEB__)
181 #elif defined(__MIPSEL__)
182 #define _LITTLE_ENDIAN
184 #error MIPS no endian specified
191 #define _SUNOS_VTOC_16
194 * Illumos doesn't define _ALIGNMENT_REQUIRED for MIPS, so default to 1
197 #define _ALIGNMENT_REQUIRED 1
200 * RISC-V arch specific defines
201 * only RV64G (including atomic) LP64 is supported yet
203 #elif defined(__riscv) && defined(_LP64) && _LP64 && \
204 defined(__riscv_atomic) && __riscv_atomic
214 #define _LITTLE_ENDIAN
216 #define _SUNOS_VTOC_16
218 #define _ALIGNMENT_REQUIRED 1
222 * Currently supported:
223 * x86_64, x32, i386, arm, powerpc, s390, sparc, mips, and RV64G
225 #error "Unsupported ISA type"
228 #if defined(_ILP32) && defined(_LP64)
229 #error "Both _ILP32 and _LP64 are defined"
232 #if !defined(_ILP32) && !defined(_LP64)
233 #error "Neither _ILP32 or _LP64 are defined"
236 #include <sys/byteorder.h>
239 * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS will be defined by the Linux
240 * kernel for architectures which support efficient unaligned access.
242 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
243 #define HAVE_EFFICIENT_UNALIGNED_ACCESS
246 #if defined(__LITTLE_ENDIAN) && !defined(_LITTLE_ENDIAN)
247 #define _LITTLE_ENDIAN __LITTLE_ENDIAN
250 #if defined(__BIG_ENDIAN) && !defined(_BIG_ENDIAN)
251 #define _BIG_ENDIAN __BIG_ENDIAN
254 #if defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN)
255 #error "Both _LITTLE_ENDIAN and _BIG_ENDIAN are defined"
258 #if !defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
259 #error "Neither _LITTLE_ENDIAN or _BIG_ENDIAN are defined"
262 #endif /* _SPL_ISA_DEFS_H */