1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_ISA_DEFS_H
28 #define	_SYS_ISA_DEFS_H
29 
30 #ifdef  __cplusplus
31 extern "C" {
32 #endif
33 
34 /* x86_64 arch specific defines */
35 #if defined(__x86_64) || defined(__x86_64__)
36 
37 #if !defined(__x86_64)
38 #define	__x86_64
39 #endif
40 
41 #if !defined(__amd64)
42 #define	__amd64
43 #endif
44 
45 #if !defined(__x86)
46 #define	__x86
47 #endif
48 
49 #if defined(_ILP32)
50 /* x32-specific defines; careful to *not* define _LP64 here */
51 #else
52 #if !defined(_LP64)
53 #define	_LP64
54 #endif
55 #endif
56 
57 #if !defined(_ZFS_LITTLE_ENDIAN)
58 #define	_ZFS_LITTLE_ENDIAN
59 #endif
60 
61 #define	_SUNOS_VTOC_16
62 #define	HAVE_EFFICIENT_UNALIGNED_ACCESS
63 
64 /* i386 arch specific defines */
65 #elif defined(__i386) || defined(__i386__)
66 
67 #if !defined(__i386)
68 #define	__i386
69 #endif
70 
71 #if !defined(__x86)
72 #define	__x86
73 #endif
74 
75 #if !defined(_ILP32)
76 #define	_ILP32
77 #endif
78 
79 #if !defined(_ZFS_LITTLE_ENDIAN)
80 #define	_ZFS_LITTLE_ENDIAN
81 #endif
82 
83 #define	_SUNOS_VTOC_16
84 #define	HAVE_EFFICIENT_UNALIGNED_ACCESS
85 
86 /* powerpc arch specific defines */
87 #elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__)
88 
89 #if !defined(__powerpc)
90 #define	__powerpc
91 #endif
92 
93 #if !defined(__powerpc__)
94 #define	__powerpc__
95 #endif
96 
97 #if defined(__powerpc64__)
98 #if !defined(_LP64)
99 #define	_LP64
100 #endif
101 #else
102 #if !defined(_ILP32)
103 #define	_ILP32
104 #endif
105 #endif
106 
107 #define	_SUNOS_VTOC_16
108 #define	HAVE_EFFICIENT_UNALIGNED_ACCESS
109 
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
115 #endif
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
121 #endif
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
126 #endif
127 
128 /* arm arch specific defines */
129 #elif defined(__arm) || defined(__arm__)
130 
131 #if !defined(__arm)
132 #define	__arm
133 #endif
134 
135 #if !defined(__arm__)
136 #define	__arm__
137 #endif
138 
139 #if !defined(_ILP32)
140 #define	_ILP32
141 #endif
142 
143 #if defined(__ARMEL__)
144 #define	_ZFS_LITTLE_ENDIAN
145 #else
146 #define	_ZFS_BIG_ENDIAN
147 #endif
148 
149 #define	_SUNOS_VTOC_16
150 
151 #if defined(__ARM_FEATURE_UNALIGNED)
152 #define	HAVE_EFFICIENT_UNALIGNED_ACCESS
153 #endif
154 
155 /* aarch64 arch specific defines */
156 #elif defined(__aarch64__)
157 
158 #if !defined(_LP64)
159 #define	_LP64
160 #endif
161 
162 #if defined(__AARCH64EL__)
163 #define	_ZFS_LITTLE_ENDIAN
164 #else
165 #define	_ZFS_BIG_ENDIAN
166 #endif
167 
168 #define	_SUNOS_VTOC_16
169 
170 /* sparc arch specific defines */
171 #elif defined(__sparc) || defined(__sparc__)
172 
173 #if !defined(__sparc)
174 #define	__sparc
175 #endif
176 
177 #if !defined(__sparc__)
178 #define	__sparc__
179 #endif
180 
181 #define	_ZFS_BIG_ENDIAN
182 #define	_SUNOS_VTOC_16
183 
184 #if defined(__arch64__)
185 #if !defined(_LP64)
186 #define	_LP64
187 #endif
188 #else
189 #if !defined(_ILP32)
190 #define	_ILP32
191 #endif
192 #endif
193 
194 /* s390 arch specific defines */
195 #elif defined(__s390__)
196 #if defined(__s390x__)
197 #if !defined(_LP64)
198 #define	_LP64
199 #endif
200 #else
201 #if !defined(_ILP32)
202 #define	_ILP32
203 #endif
204 #endif
205 
206 #define	_ZFS_BIG_ENDIAN
207 #define	_SUNOS_VTOC_16
208 
209 /* MIPS arch specific defines */
210 #elif defined(__mips__)
211 
212 #if defined(__MIPSEB__)
213 #define	_ZFS_BIG_ENDIAN
214 #elif defined(__MIPSEL__)
215 #define	_ZFS_LITTLE_ENDIAN
216 #else
217 #error MIPS no endian specified
218 #endif
219 
220 #if !defined(_LP64) && !defined(_ILP32)
221 #define	_ILP32
222 #endif
223 
224 #define	_SUNOS_VTOC_16
225 
226 /*
227  * RISC-V arch specific defines
228  * only RV64G (including atomic) LP64 is supported yet
229  */
230 #elif defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64 && \
231 	defined(__riscv_atomic) && __riscv_atomic
232 
233 #if !defined(_LP64)
234 #define	_LP64 1
235 #endif
236 
237 #ifndef	__riscv__
238 #define	__riscv__
239 #endif
240 
241 #ifndef	__rv64g__
242 #define	__rv64g__
243 #endif
244 
245 #define	_ZFS_LITTLE_ENDIAN
246 
247 #define	_SUNOS_VTOC_16
248 
249 #else
250 /*
251  * Currently supported:
252  * x86_64, x32, i386, arm, powerpc, s390, sparc, mips, and RV64G
253  */
254 #error "Unsupported ISA type"
255 #endif
256 
257 #if defined(_ILP32) && defined(_LP64)
258 #error "Both _ILP32 and _LP64 are defined"
259 #endif
260 
261 #if !defined(_ILP32) && !defined(_LP64)
262 #error "Neither _ILP32 or _LP64 are defined"
263 #endif
264 
265 #if defined(_ZFS_LITTLE_ENDIAN) && defined(_ZFS_BIG_ENDIAN)
266 #error "Both _ZFS_LITTLE_ENDIAN and _ZFS_BIG_ENDIAN are defined"
267 #endif
268 
269 #if !defined(_ZFS_LITTLE_ENDIAN) && !defined(_ZFS_BIG_ENDIAN)
270 #error "Neither _ZFS_LITTLE_ENDIAN nor _ZFS_BIG_ENDIAN are defined"
271 #endif
272 
273 #ifdef  __cplusplus
274 }
275 #endif
276 
277 #endif	/* _SYS_ISA_DEFS_H */
278