4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_ISA_DEFS_H
28 #define _SYS_ISA_DEFS_H
34 /* x86_64 arch specific defines */
35 #if defined(__x86_64) || defined(__x86_64__)
37 #if !defined(__x86_64)
50 /* x32-specific defines; careful to *not* define _LP64 here */
57 #if !defined(_ZFS_LITTLE_ENDIAN)
58 #define _ZFS_LITTLE_ENDIAN
61 #define _SUNOS_VTOC_16
62 #define HAVE_EFFICIENT_UNALIGNED_ACCESS
64 /* i386 arch specific defines */
65 #elif defined(__i386) || defined(__i386__)
79 #if !defined(_ZFS_LITTLE_ENDIAN)
80 #define _ZFS_LITTLE_ENDIAN
83 #define _SUNOS_VTOC_16
84 #define HAVE_EFFICIENT_UNALIGNED_ACCESS
86 /* powerpc arch specific defines */
87 #elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__)
89 #if !defined(__powerpc)
93 #if !defined(__powerpc__)
97 #if defined(__powerpc64__)
107 #define _SUNOS_VTOC_16
108 #define HAVE_EFFICIENT_UNALIGNED_ACCESS
110 #if defined(__BYTE_ORDER)
111 #if defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN
112 #define _ZFS_BIG_ENDIAN
113 #elif defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
114 #define _ZFS_LITTLE_ENDIAN
116 #elif defined(_BYTE_ORDER)
117 #if defined(_BIG_ENDIAN) && _BYTE_ORDER == _BIG_ENDIAN
118 #define _ZFS_BIG_ENDIAN
119 #elif defined(_LITTLE_ENDIAN) && _BYTE_ORDER == _LITTLE_ENDIAN
120 #define _ZFS_LITTLE_ENDIAN
122 #elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
123 #define _ZFS_BIG_ENDIAN
124 #elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
125 #define _ZFS_LITTLE_ENDIAN
128 /* arm arch specific defines */
129 #elif defined(__arm) || defined(__arm__)
135 #if !defined(__arm__)
143 #if defined(__ARMEL__)
144 #define _ZFS_LITTLE_ENDIAN
146 #define _ZFS_BIG_ENDIAN
149 #define _SUNOS_VTOC_16
151 #if defined(__ARM_FEATURE_UNALIGNED)
152 #define HAVE_EFFICIENT_UNALIGNED_ACCESS
155 /* aarch64 arch specific defines */
156 #elif defined(__aarch64__)
162 #if defined(__AARCH64EL__)
163 #define _ZFS_LITTLE_ENDIAN
165 #define _ZFS_BIG_ENDIAN
168 #define _SUNOS_VTOC_16
170 /* sparc arch specific defines */
171 #elif defined(__sparc) || defined(__sparc__)
173 #if !defined(__sparc)
177 #if !defined(__sparc__)
181 #define _ZFS_BIG_ENDIAN
182 #define _SUNOS_VTOC_16
184 #if defined(__arch64__)
194 /* s390 arch specific defines */
195 #elif defined(__s390__)
196 #if defined(__s390x__)
206 #define _ZFS_BIG_ENDIAN
207 #define _SUNOS_VTOC_16
209 /* MIPS arch specific defines */
210 #elif defined(__mips__)
212 #if defined(__MIPSEB__)
213 #define _ZFS_BIG_ENDIAN
214 #elif defined(__MIPSEL__)
215 #define _ZFS_LITTLE_ENDIAN
217 #error MIPS no endian specified
220 #if !defined(_LP64) && !defined(_ILP32)
224 #define _SUNOS_VTOC_16
227 * RISC-V arch specific defines
228 * only RV64G (including atomic) LP64 is supported yet
230 #elif defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64 && \
231 defined(__riscv_atomic) && __riscv_atomic
245 #define _ZFS_LITTLE_ENDIAN
247 #define _SUNOS_VTOC_16
250 * LoongArch arch specific defines
251 * only LoongArch64 is supported yet
253 #elif defined(__loongarch__) && defined(__loongarch_lp64)
259 #define _ZFS_LITTLE_ENDIAN
260 #define _SUNOS_VTOC_16
262 /* not all LoongArch cores support unaligned accesses in hardware */
263 #define _ALIGNMENT_REQUIRED 1
267 * Currently supported:
268 * x86_64, x32, i386, arm, powerpc, s390, sparc, mips, RV64G, and LoongArch64
270 #error "Unsupported ISA type"
273 #if defined(_ILP32) && defined(_LP64)
274 #error "Both _ILP32 and _LP64 are defined"
277 #if !defined(_ILP32) && !defined(_LP64)
278 #error "Neither _ILP32 or _LP64 are defined"
281 #if defined(_ZFS_LITTLE_ENDIAN) && defined(_ZFS_BIG_ENDIAN)
282 #error "Both _ZFS_LITTLE_ENDIAN and _ZFS_BIG_ENDIAN are defined"
285 #if !defined(_ZFS_LITTLE_ENDIAN) && !defined(_ZFS_BIG_ENDIAN)
286 #error "Neither _ZFS_LITTLE_ENDIAN nor _ZFS_BIG_ENDIAN are defined"
293 #endif /* _SYS_ISA_DEFS_H */