Fix gcc uninitialized warning in FreeBSD zio_crypt.c
[zfs.git] / lib / libspl / include / sys / isa_defs.h
blob302f31e989cbc78039b9a43700d6e3d0abe2dfc8
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 /* x86_64 arch specific defines */
35 #if defined(__x86_64) || defined(__x86_64__)
37 #if !defined(__x86_64)
38 #define __x86_64
39 #endif
41 #if !defined(__amd64)
42 #define __amd64
43 #endif
45 #if !defined(__x86)
46 #define __x86
47 #endif
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
57 #if !defined(_ZFS_LITTLE_ENDIAN)
58 #define _ZFS_LITTLE_ENDIAN
59 #endif
61 #define _SUNOS_VTOC_16
62 #define HAVE_EFFICIENT_UNALIGNED_ACCESS
64 /* i386 arch specific defines */
65 #elif defined(__i386) || defined(__i386__)
67 #if !defined(__i386)
68 #define __i386
69 #endif
71 #if !defined(__x86)
72 #define __x86
73 #endif
75 #if !defined(_ILP32)
76 #define _ILP32
77 #endif
79 #if !defined(_ZFS_LITTLE_ENDIAN)
80 #define _ZFS_LITTLE_ENDIAN
81 #endif
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)
90 #define __powerpc
91 #endif
93 #if !defined(__powerpc__)
94 #define __powerpc__
95 #endif
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
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
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
128 /* arm arch specific defines */
129 #elif defined(__arm) || defined(__arm__)
131 #if !defined(__arm)
132 #define __arm
133 #endif
135 #if !defined(__arm__)
136 #define __arm__
137 #endif
139 #if !defined(_ILP32)
140 #define _ILP32
141 #endif
143 #if defined(__ARMEL__)
144 #define _ZFS_LITTLE_ENDIAN
145 #else
146 #define _ZFS_BIG_ENDIAN
147 #endif
149 #define _SUNOS_VTOC_16
151 #if defined(__ARM_FEATURE_UNALIGNED)
152 #define HAVE_EFFICIENT_UNALIGNED_ACCESS
153 #endif
155 /* aarch64 arch specific defines */
156 #elif defined(__aarch64__)
158 #if !defined(_LP64)
159 #define _LP64
160 #endif
162 #if defined(__AARCH64EL__)
163 #define _ZFS_LITTLE_ENDIAN
164 #else
165 #define _ZFS_BIG_ENDIAN
166 #endif
168 #define _SUNOS_VTOC_16
170 /* sparc arch specific defines */
171 #elif defined(__sparc) || defined(__sparc__)
173 #if !defined(__sparc)
174 #define __sparc
175 #endif
177 #if !defined(__sparc__)
178 #define __sparc__
179 #endif
181 #define _ZFS_BIG_ENDIAN
182 #define _SUNOS_VTOC_16
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
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
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
216 #else
217 #error MIPS no endian specified
218 #endif
220 #if !defined(_LP64) && !defined(_ILP32)
221 #define _ILP32
222 #endif
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
233 #if !defined(_LP64)
234 #define _LP64 1
235 #endif
237 #ifndef __riscv__
238 #define __riscv__
239 #endif
241 #ifndef __rv64g__
242 #define __rv64g__
243 #endif
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)
255 #if !defined(_LP64)
256 #define _LP64
257 #endif
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
265 #else
267 * Currently supported:
268 * x86_64, x32, i386, arm, powerpc, s390, sparc, mips, RV64G, and LoongArch64
270 #error "Unsupported ISA type"
271 #endif
273 #if defined(_ILP32) && defined(_LP64)
274 #error "Both _ILP32 and _LP64 are defined"
275 #endif
277 #if !defined(_ILP32) && !defined(_LP64)
278 #error "Neither _ILP32 or _LP64 are defined"
279 #endif
281 #if defined(_ZFS_LITTLE_ENDIAN) && defined(_ZFS_BIG_ENDIAN)
282 #error "Both _ZFS_LITTLE_ENDIAN and _ZFS_BIG_ENDIAN are defined"
283 #endif
285 #if !defined(_ZFS_LITTLE_ENDIAN) && !defined(_ZFS_BIG_ENDIAN)
286 #error "Neither _ZFS_LITTLE_ENDIAN nor _ZFS_BIG_ENDIAN are defined"
287 #endif
289 #ifdef __cplusplus
291 #endif
293 #endif /* _SYS_ISA_DEFS_H */