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 http://www.opensolaris.org/os/licensing.
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__) || defined(__aarch64__)
130 
131 #if !defined(__arm)
132 #define	__arm
133 #endif
134 
135 #if !defined(__arm__)
136 #define	__arm__
137 #endif
138 
139 #if defined(__aarch64__)
140 #if !defined(_LP64)
141 #define	_LP64
142 #endif
143 #else
144 #if !defined(_ILP32)
145 #define	_ILP32
146 #endif
147 #endif
148 
149 #if defined(__ARMEL__) || defined(__AARCH64EL__)
150 #define	_ZFS_LITTLE_ENDIAN
151 #else
152 #define	_ZFS_BIG_ENDIAN
153 #endif
154 
155 #define	_SUNOS_VTOC_16
156 
157 #if defined(__ARM_FEATURE_UNALIGNED)
158 #define	HAVE_EFFICIENT_UNALIGNED_ACCESS
159 #endif
160 
161 /* sparc arch specific defines */
162 #elif defined(__sparc) || defined(__sparc__)
163 
164 #if !defined(__sparc)
165 #define	__sparc
166 #endif
167 
168 #if !defined(__sparc__)
169 #define	__sparc__
170 #endif
171 
172 #define	_ZFS_BIG_ENDIAN
173 #define	_SUNOS_VTOC_16
174 
175 #if defined(__arch64__)
176 #if !defined(_LP64)
177 #define	_LP64
178 #endif
179 #else
180 #if !defined(_ILP32)
181 #define	_ILP32
182 #endif
183 #endif
184 
185 /* s390 arch specific defines */
186 #elif defined(__s390__)
187 #if defined(__s390x__)
188 #if !defined(_LP64)
189 #define	_LP64
190 #endif
191 #else
192 #if !defined(_ILP32)
193 #define	_ILP32
194 #endif
195 #endif
196 
197 #define	_ZFS_BIG_ENDIAN
198 #define	_SUNOS_VTOC_16
199 
200 /* MIPS arch specific defines */
201 #elif defined(__mips__)
202 
203 #if defined(__MIPSEB__)
204 #define	_ZFS_BIG_ENDIAN
205 #elif defined(__MIPSEL__)
206 #define	_ZFS_LITTLE_ENDIAN
207 #else
208 #error MIPS no endian specified
209 #endif
210 
211 #if !defined(_LP64) && !defined(_ILP32)
212 #define	_ILP32
213 #endif
214 
215 #define	_SUNOS_VTOC_16
216 
217 /*
218  * RISC-V arch specific defines
219  * only RV64G (including atomic) LP64 is supported yet
220  */
221 #elif defined(__riscv) && defined(_LP64) && _LP64 && \
222 	defined(__riscv_atomic) && __riscv_atomic
223 
224 #ifndef	__riscv__
225 #define	__riscv__
226 #endif
227 
228 #ifndef	__rv64g__
229 #define	__rv64g__
230 #endif
231 
232 #define	_ZFS_LITTLE_ENDIAN
233 
234 #define	_SUNOS_VTOC_16
235 
236 #else
237 /*
238  * Currently supported:
239  * x86_64, x32, i386, arm, powerpc, s390, sparc, mips, and RV64G
240  */
241 #error "Unsupported ISA type"
242 #endif
243 
244 #if defined(_ILP32) && defined(_LP64)
245 #error "Both _ILP32 and _LP64 are defined"
246 #endif
247 
248 #if !defined(_ILP32) && !defined(_LP64)
249 #error "Neither _ILP32 or _LP64 are defined"
250 #endif
251 
252 #if defined(_ZFS_LITTLE_ENDIAN) && defined(_ZFS_BIG_ENDIAN)
253 #error "Both _ZFS_LITTLE_ENDIAN and _ZFS_BIG_ENDIAN are defined"
254 #endif
255 
256 #if !defined(_ZFS_LITTLE_ENDIAN) && !defined(_ZFS_BIG_ENDIAN)
257 #error "Neither _ZFS_LITTLE_ENDIAN nor _ZFS_BIG_ENDIAN are defined"
258 #endif
259 
260 #ifdef  __cplusplus
261 }
262 #endif
263 
264 #endif	/* _SYS_ISA_DEFS_H */
265