1eda14cbcSMatt Macy /*
2eda14cbcSMatt Macy  * CDDL HEADER START
3eda14cbcSMatt Macy  *
4eda14cbcSMatt Macy  * The contents of this file are subject to the terms of the
5eda14cbcSMatt Macy  * Common Development and Distribution License (the "License").
6eda14cbcSMatt Macy  * You may not use this file except in compliance with the License.
7eda14cbcSMatt Macy  *
8eda14cbcSMatt Macy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9271171e0SMartin Matuska  * or https://opensource.org/licenses/CDDL-1.0.
10eda14cbcSMatt Macy  * See the License for the specific language governing permissions
11eda14cbcSMatt Macy  * and limitations under the License.
12eda14cbcSMatt Macy  *
13eda14cbcSMatt Macy  * When distributing Covered Code, include this CDDL HEADER in each
14eda14cbcSMatt Macy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15eda14cbcSMatt Macy  * If applicable, add the following below this CDDL HEADER, with the
16eda14cbcSMatt Macy  * fields enclosed by brackets "[]" replaced with your own identifying
17eda14cbcSMatt Macy  * information: Portions Copyright [yyyy] [name of copyright owner]
18eda14cbcSMatt Macy  *
19eda14cbcSMatt Macy  * CDDL HEADER END
20eda14cbcSMatt Macy  */
21eda14cbcSMatt Macy 
22eda14cbcSMatt Macy /*
23eda14cbcSMatt Macy  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24eda14cbcSMatt Macy  * Use is subject to license terms.
25eda14cbcSMatt Macy  */
26eda14cbcSMatt Macy 
27eda14cbcSMatt Macy #ifndef	_SYS_ISA_DEFS_H
28eda14cbcSMatt Macy #define	_SYS_ISA_DEFS_H
29eda14cbcSMatt Macy 
30eda14cbcSMatt Macy #ifdef  __cplusplus
31eda14cbcSMatt Macy extern "C" {
32eda14cbcSMatt Macy #endif
33eda14cbcSMatt Macy 
34eda14cbcSMatt Macy /* x86_64 arch specific defines */
35eda14cbcSMatt Macy #if defined(__x86_64) || defined(__x86_64__)
36eda14cbcSMatt Macy 
37eda14cbcSMatt Macy #if !defined(__x86_64)
38eda14cbcSMatt Macy #define	__x86_64
39eda14cbcSMatt Macy #endif
40eda14cbcSMatt Macy 
41eda14cbcSMatt Macy #if !defined(__amd64)
42eda14cbcSMatt Macy #define	__amd64
43eda14cbcSMatt Macy #endif
44eda14cbcSMatt Macy 
45eda14cbcSMatt Macy #if !defined(__x86)
46eda14cbcSMatt Macy #define	__x86
47eda14cbcSMatt Macy #endif
48eda14cbcSMatt Macy 
49eda14cbcSMatt Macy #if defined(_ILP32)
50eda14cbcSMatt Macy /* x32-specific defines; careful to *not* define _LP64 here */
51eda14cbcSMatt Macy #else
52eda14cbcSMatt Macy #if !defined(_LP64)
53eda14cbcSMatt Macy #define	_LP64
54eda14cbcSMatt Macy #endif
55eda14cbcSMatt Macy #endif
56eda14cbcSMatt Macy 
57eda14cbcSMatt Macy #if !defined(_ZFS_LITTLE_ENDIAN)
58eda14cbcSMatt Macy #define	_ZFS_LITTLE_ENDIAN
59eda14cbcSMatt Macy #endif
60eda14cbcSMatt Macy 
61eda14cbcSMatt Macy #define	_SUNOS_VTOC_16
62eda14cbcSMatt Macy #define	HAVE_EFFICIENT_UNALIGNED_ACCESS
63eda14cbcSMatt Macy 
64eda14cbcSMatt Macy /* i386 arch specific defines */
65eda14cbcSMatt Macy #elif defined(__i386) || defined(__i386__)
66eda14cbcSMatt Macy 
67eda14cbcSMatt Macy #if !defined(__i386)
68eda14cbcSMatt Macy #define	__i386
69eda14cbcSMatt Macy #endif
70eda14cbcSMatt Macy 
71eda14cbcSMatt Macy #if !defined(__x86)
72eda14cbcSMatt Macy #define	__x86
73eda14cbcSMatt Macy #endif
74eda14cbcSMatt Macy 
75eda14cbcSMatt Macy #if !defined(_ILP32)
76eda14cbcSMatt Macy #define	_ILP32
77eda14cbcSMatt Macy #endif
78eda14cbcSMatt Macy 
79eda14cbcSMatt Macy #if !defined(_ZFS_LITTLE_ENDIAN)
80eda14cbcSMatt Macy #define	_ZFS_LITTLE_ENDIAN
81eda14cbcSMatt Macy #endif
82eda14cbcSMatt Macy 
83eda14cbcSMatt Macy #define	_SUNOS_VTOC_16
84eda14cbcSMatt Macy #define	HAVE_EFFICIENT_UNALIGNED_ACCESS
85eda14cbcSMatt Macy 
86eda14cbcSMatt Macy /* powerpc arch specific defines */
87eda14cbcSMatt Macy #elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__)
88eda14cbcSMatt Macy 
89eda14cbcSMatt Macy #if !defined(__powerpc)
90eda14cbcSMatt Macy #define	__powerpc
91eda14cbcSMatt Macy #endif
92eda14cbcSMatt Macy 
93eda14cbcSMatt Macy #if !defined(__powerpc__)
94eda14cbcSMatt Macy #define	__powerpc__
95eda14cbcSMatt Macy #endif
96eda14cbcSMatt Macy 
97eda14cbcSMatt Macy #if defined(__powerpc64__)
98eda14cbcSMatt Macy #if !defined(_LP64)
99eda14cbcSMatt Macy #define	_LP64
100eda14cbcSMatt Macy #endif
101eda14cbcSMatt Macy #else
102eda14cbcSMatt Macy #if !defined(_ILP32)
103eda14cbcSMatt Macy #define	_ILP32
104eda14cbcSMatt Macy #endif
105eda14cbcSMatt Macy #endif
106eda14cbcSMatt Macy 
107eda14cbcSMatt Macy #define	_SUNOS_VTOC_16
108eda14cbcSMatt Macy #define	HAVE_EFFICIENT_UNALIGNED_ACCESS
109eda14cbcSMatt Macy 
110eda14cbcSMatt Macy #if defined(__BYTE_ORDER)
111eda14cbcSMatt Macy #if defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN
112eda14cbcSMatt Macy #define	_ZFS_BIG_ENDIAN
113eda14cbcSMatt Macy #elif defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
114eda14cbcSMatt Macy #define	_ZFS_LITTLE_ENDIAN
115eda14cbcSMatt Macy #endif
116eda14cbcSMatt Macy #elif defined(_BYTE_ORDER)
117eda14cbcSMatt Macy #if defined(_BIG_ENDIAN) && _BYTE_ORDER == _BIG_ENDIAN
118eda14cbcSMatt Macy #define	_ZFS_BIG_ENDIAN
119eda14cbcSMatt Macy #elif defined(_LITTLE_ENDIAN) && _BYTE_ORDER == _LITTLE_ENDIAN
120eda14cbcSMatt Macy #define	_ZFS_LITTLE_ENDIAN
121eda14cbcSMatt Macy #endif
122eda14cbcSMatt Macy #elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
123eda14cbcSMatt Macy #define	_ZFS_BIG_ENDIAN
124eda14cbcSMatt Macy #elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
125eda14cbcSMatt Macy #define	_ZFS_LITTLE_ENDIAN
126eda14cbcSMatt Macy #endif
127eda14cbcSMatt Macy 
128eda14cbcSMatt Macy /* arm arch specific defines */
129c03c5b1cSMartin Matuska #elif defined(__arm) || defined(__arm__)
130eda14cbcSMatt Macy 
131eda14cbcSMatt Macy #if !defined(__arm)
132eda14cbcSMatt Macy #define	__arm
133eda14cbcSMatt Macy #endif
134eda14cbcSMatt Macy 
135eda14cbcSMatt Macy #if !defined(__arm__)
136eda14cbcSMatt Macy #define	__arm__
137eda14cbcSMatt Macy #endif
138eda14cbcSMatt Macy 
139eda14cbcSMatt Macy #if !defined(_ILP32)
140eda14cbcSMatt Macy #define	_ILP32
141eda14cbcSMatt Macy #endif
142eda14cbcSMatt Macy 
143c03c5b1cSMartin Matuska #if defined(__ARMEL__)
144eda14cbcSMatt Macy #define	_ZFS_LITTLE_ENDIAN
145eda14cbcSMatt Macy #else
146eda14cbcSMatt Macy #define	_ZFS_BIG_ENDIAN
147eda14cbcSMatt Macy #endif
148eda14cbcSMatt Macy 
149eda14cbcSMatt Macy #define	_SUNOS_VTOC_16
150eda14cbcSMatt Macy 
151eda14cbcSMatt Macy #if defined(__ARM_FEATURE_UNALIGNED)
152eda14cbcSMatt Macy #define	HAVE_EFFICIENT_UNALIGNED_ACCESS
153eda14cbcSMatt Macy #endif
154eda14cbcSMatt Macy 
155c03c5b1cSMartin Matuska /* aarch64 arch specific defines */
156c03c5b1cSMartin Matuska #elif defined(__aarch64__)
157c03c5b1cSMartin Matuska 
158c03c5b1cSMartin Matuska #if !defined(_LP64)
159c03c5b1cSMartin Matuska #define	_LP64
160c03c5b1cSMartin Matuska #endif
161c03c5b1cSMartin Matuska 
162c03c5b1cSMartin Matuska #if defined(__AARCH64EL__)
163c03c5b1cSMartin Matuska #define	_ZFS_LITTLE_ENDIAN
164c03c5b1cSMartin Matuska #else
165c03c5b1cSMartin Matuska #define	_ZFS_BIG_ENDIAN
166c03c5b1cSMartin Matuska #endif
167c03c5b1cSMartin Matuska 
168c03c5b1cSMartin Matuska #define	_SUNOS_VTOC_16
169c03c5b1cSMartin Matuska 
170eda14cbcSMatt Macy /* sparc arch specific defines */
171eda14cbcSMatt Macy #elif defined(__sparc) || defined(__sparc__)
172eda14cbcSMatt Macy 
173eda14cbcSMatt Macy #if !defined(__sparc)
174eda14cbcSMatt Macy #define	__sparc
175eda14cbcSMatt Macy #endif
176eda14cbcSMatt Macy 
177eda14cbcSMatt Macy #if !defined(__sparc__)
178eda14cbcSMatt Macy #define	__sparc__
179eda14cbcSMatt Macy #endif
180eda14cbcSMatt Macy 
181eda14cbcSMatt Macy #define	_ZFS_BIG_ENDIAN
182eda14cbcSMatt Macy #define	_SUNOS_VTOC_16
183eda14cbcSMatt Macy 
184eda14cbcSMatt Macy #if defined(__arch64__)
185eda14cbcSMatt Macy #if !defined(_LP64)
186eda14cbcSMatt Macy #define	_LP64
187eda14cbcSMatt Macy #endif
188eda14cbcSMatt Macy #else
189eda14cbcSMatt Macy #if !defined(_ILP32)
190eda14cbcSMatt Macy #define	_ILP32
191eda14cbcSMatt Macy #endif
192eda14cbcSMatt Macy #endif
193eda14cbcSMatt Macy 
194eda14cbcSMatt Macy /* s390 arch specific defines */
195eda14cbcSMatt Macy #elif defined(__s390__)
196eda14cbcSMatt Macy #if defined(__s390x__)
197eda14cbcSMatt Macy #if !defined(_LP64)
198eda14cbcSMatt Macy #define	_LP64
199eda14cbcSMatt Macy #endif
200eda14cbcSMatt Macy #else
201eda14cbcSMatt Macy #if !defined(_ILP32)
202eda14cbcSMatt Macy #define	_ILP32
203eda14cbcSMatt Macy #endif
204eda14cbcSMatt Macy #endif
205eda14cbcSMatt Macy 
206eda14cbcSMatt Macy #define	_ZFS_BIG_ENDIAN
207eda14cbcSMatt Macy #define	_SUNOS_VTOC_16
208eda14cbcSMatt Macy 
209eda14cbcSMatt Macy /* MIPS arch specific defines */
210eda14cbcSMatt Macy #elif defined(__mips__)
211eda14cbcSMatt Macy 
212eda14cbcSMatt Macy #if defined(__MIPSEB__)
213eda14cbcSMatt Macy #define	_ZFS_BIG_ENDIAN
214eda14cbcSMatt Macy #elif defined(__MIPSEL__)
215eda14cbcSMatt Macy #define	_ZFS_LITTLE_ENDIAN
216eda14cbcSMatt Macy #else
217eda14cbcSMatt Macy #error MIPS no endian specified
218eda14cbcSMatt Macy #endif
219eda14cbcSMatt Macy 
220eda14cbcSMatt Macy #if !defined(_LP64) && !defined(_ILP32)
221eda14cbcSMatt Macy #define	_ILP32
222eda14cbcSMatt Macy #endif
223eda14cbcSMatt Macy 
224eda14cbcSMatt Macy #define	_SUNOS_VTOC_16
225eda14cbcSMatt Macy 
226eda14cbcSMatt Macy /*
227eda14cbcSMatt Macy  * RISC-V arch specific defines
228eda14cbcSMatt Macy  * only RV64G (including atomic) LP64 is supported yet
229eda14cbcSMatt Macy  */
230dbd5678dSMartin Matuska #elif defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64 && \
231eda14cbcSMatt Macy 	defined(__riscv_atomic) && __riscv_atomic
232eda14cbcSMatt Macy 
233dbd5678dSMartin Matuska #if !defined(_LP64)
234dbd5678dSMartin Matuska #define	_LP64 1
235dbd5678dSMartin Matuska #endif
236dbd5678dSMartin Matuska 
237eda14cbcSMatt Macy #ifndef	__riscv__
238eda14cbcSMatt Macy #define	__riscv__
239eda14cbcSMatt Macy #endif
240eda14cbcSMatt Macy 
241eda14cbcSMatt Macy #ifndef	__rv64g__
242eda14cbcSMatt Macy #define	__rv64g__
243eda14cbcSMatt Macy #endif
244eda14cbcSMatt Macy 
245eda14cbcSMatt Macy #define	_ZFS_LITTLE_ENDIAN
246eda14cbcSMatt Macy 
247eda14cbcSMatt Macy #define	_SUNOS_VTOC_16
248eda14cbcSMatt Macy 
249*d411c1d6SMartin Matuska /*
250*d411c1d6SMartin Matuska  * LoongArch arch specific defines
251*d411c1d6SMartin Matuska  * only LoongArch64 is supported yet
252*d411c1d6SMartin Matuska  */
253*d411c1d6SMartin Matuska #elif defined(__loongarch__) && defined(__loongarch_lp64)
254*d411c1d6SMartin Matuska 
255*d411c1d6SMartin Matuska #if !defined(_LP64)
256*d411c1d6SMartin Matuska #define	_LP64
257*d411c1d6SMartin Matuska #endif
258*d411c1d6SMartin Matuska 
259*d411c1d6SMartin Matuska #define	_ZFS_LITTLE_ENDIAN
260*d411c1d6SMartin Matuska #define	_SUNOS_VTOC_16
261*d411c1d6SMartin Matuska 
262*d411c1d6SMartin Matuska /* not all LoongArch cores support unaligned accesses in hardware */
263*d411c1d6SMartin Matuska #define	_ALIGNMENT_REQUIRED	1
264*d411c1d6SMartin Matuska 
265eda14cbcSMatt Macy #else
266eda14cbcSMatt Macy /*
267eda14cbcSMatt Macy  * Currently supported:
268*d411c1d6SMartin Matuska  * x86_64, x32, i386, arm, powerpc, s390, sparc, mips, RV64G, and LoongArch64
269eda14cbcSMatt Macy  */
270eda14cbcSMatt Macy #error "Unsupported ISA type"
271eda14cbcSMatt Macy #endif
272eda14cbcSMatt Macy 
273eda14cbcSMatt Macy #if defined(_ILP32) && defined(_LP64)
274eda14cbcSMatt Macy #error "Both _ILP32 and _LP64 are defined"
275eda14cbcSMatt Macy #endif
276eda14cbcSMatt Macy 
277eda14cbcSMatt Macy #if !defined(_ILP32) && !defined(_LP64)
278eda14cbcSMatt Macy #error "Neither _ILP32 or _LP64 are defined"
279eda14cbcSMatt Macy #endif
280eda14cbcSMatt Macy 
281eda14cbcSMatt Macy #if defined(_ZFS_LITTLE_ENDIAN) && defined(_ZFS_BIG_ENDIAN)
282eda14cbcSMatt Macy #error "Both _ZFS_LITTLE_ENDIAN and _ZFS_BIG_ENDIAN are defined"
283eda14cbcSMatt Macy #endif
284eda14cbcSMatt Macy 
285eda14cbcSMatt Macy #if !defined(_ZFS_LITTLE_ENDIAN) && !defined(_ZFS_BIG_ENDIAN)
286eda14cbcSMatt Macy #error "Neither _ZFS_LITTLE_ENDIAN nor _ZFS_BIG_ENDIAN are defined"
287eda14cbcSMatt Macy #endif
288eda14cbcSMatt Macy 
289eda14cbcSMatt Macy #ifdef  __cplusplus
290eda14cbcSMatt Macy }
291eda14cbcSMatt Macy #endif
292eda14cbcSMatt Macy 
293eda14cbcSMatt Macy #endif	/* _SYS_ISA_DEFS_H */
294