]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/openzfs/include/os/linux/spl/sys/isa_defs.h
Update OpenZFS to 2.0.0-rc3-gfc5966
[FreeBSD/FreeBSD.git] / sys / contrib / openzfs / include / os / linux / spl / sys / isa_defs.h
1 /*
2  *  Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3  *  Copyright (C) 2007 The Regents of the University of California.
4  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5  *  Written by Brian Behlendorf <behlendorf1@llnl.gov>.
6  *  UCRL-CODE-235197
7  *
8  *  This file is part of the SPL, Solaris Porting Layer.
9  *
10  *  The SPL is free software; you can redistribute it and/or modify it
11  *  under the terms of the GNU General Public License as published by the
12  *  Free Software Foundation; either version 2 of the License, or (at your
13  *  option) any later version.
14  *
15  *  The SPL is distributed in the hope that it will be useful, but WITHOUT
16  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18  *  for more details.
19  *
20  *  You should have received a copy of the GNU General Public License along
21  *  with the SPL.  If not, see <http://www.gnu.org/licenses/>.
22  */
23
24 #ifndef _SPL_ISA_DEFS_H
25 #define _SPL_ISA_DEFS_H
26
27 /* x86_64 arch specific defines */
28 #if defined(__x86_64) || defined(__x86_64__)
29
30 #if !defined(__x86_64)
31 #define __x86_64
32 #endif
33
34 #if !defined(__amd64)
35 #define __amd64
36 #endif
37
38 #if !defined(__x86)
39 #define __x86
40 #endif
41
42 #if defined(_ILP32)
43 /* x32-specific defines; careful to *not* define _LP64 here */
44 #else
45 #if !defined(_LP64)
46 #define _LP64
47 #endif
48 #endif
49
50 #define _ALIGNMENT_REQUIRED     1
51
52
53 /* i386 arch specific defines */
54 #elif defined(__i386) || defined(__i386__)
55
56 #if !defined(__i386)
57 #define __i386
58 #endif
59
60 #if !defined(__x86)
61 #define __x86
62 #endif
63
64 #if !defined(_ILP32)
65 #define _ILP32
66 #endif
67
68 #define _ALIGNMENT_REQUIRED     0
69
70 /* powerpc (ppc64) arch specific defines */
71 #elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__)
72
73 #if !defined(__powerpc)
74 #define __powerpc
75 #endif
76
77 #if !defined(__powerpc__)
78 #define __powerpc__
79 #endif
80
81 #if defined(__powerpc64__)
82 #if !defined(_LP64)
83 #define _LP64
84 #endif
85 #else
86 #if !defined(_ILP32)
87 #define _ILP32
88 #endif
89 #endif
90
91 /*
92  * Illumos doesn't define _ALIGNMENT_REQUIRED for PPC, so default to 1
93  * out of paranoia.
94  */
95 #define _ALIGNMENT_REQUIRED     1
96
97 /* arm arch specific defines */
98 #elif defined(__arm) || defined(__arm__) || defined(__aarch64__)
99
100 #if !defined(__arm)
101 #define __arm
102 #endif
103
104 #if !defined(__arm__)
105 #define __arm__
106 #endif
107
108 #if defined(__aarch64__)
109 #if !defined(_LP64)
110 #define _LP64
111 #endif
112 #else
113 #if !defined(_ILP32)
114 #define _ILP32
115 #endif
116 #endif
117
118 #if defined(__ARMEL__) || defined(__AARCH64EL__)
119 #define _ZFS_LITTLE_ENDIAN
120 #else
121 #define _ZFS_BIG_ENDIAN
122 #endif
123
124 /*
125  * Illumos doesn't define _ALIGNMENT_REQUIRED for ARM, so default to 1
126  * out of paranoia.
127  */
128 #define _ALIGNMENT_REQUIRED     1
129
130 /* sparc arch specific defines */
131 #elif defined(__sparc) || defined(__sparc__)
132
133 #if !defined(__sparc)
134 #define __sparc
135 #endif
136
137 #if !defined(__sparc__)
138 #define __sparc__
139 #endif
140
141 #if defined(__arch64__)
142 #if !defined(_LP64)
143 #define _LP64
144 #endif
145 #else
146 #if !defined(_ILP32)
147 #define _ILP32
148 #endif
149 #endif
150
151 #define _ZFS_BIG_ENDIAN
152 #define _SUNOS_VTOC_16
153 #define _ALIGNMENT_REQUIRED     1
154
155 /* s390 arch specific defines */
156 #elif defined(__s390__)
157 #if defined(__s390x__)
158 #if !defined(_LP64)
159 #define _LP64
160 #endif
161 #else
162 #if !defined(_ILP32)
163 #define _ILP32
164 #endif
165 #endif
166
167 #define _ZFS_BIG_ENDIAN
168
169 /*
170  * Illumos doesn't define _ALIGNMENT_REQUIRED for s390, so default to 1
171  * out of paranoia.
172  */
173 #define _ALIGNMENT_REQUIRED     1
174
175 /* MIPS arch specific defines */
176 #elif defined(__mips__)
177
178 #if defined(__MIPSEB__)
179 #define _ZFS_BIG_ENDIAN
180 #elif defined(__MIPSEL__)
181 #define _ZFS_LITTLE_ENDIAN
182 #else
183 #error MIPS no endian specified
184 #endif
185
186 #ifndef _LP64
187 #define _ILP32
188 #endif
189
190 #define _SUNOS_VTOC_16
191
192 /*
193  * Illumos doesn't define _ALIGNMENT_REQUIRED for MIPS, so default to 1
194  * out of paranoia.
195  */
196 #define _ALIGNMENT_REQUIRED     1
197
198 /*
199  * RISC-V arch specific defines
200  * only RV64G (including atomic) LP64 is supported yet
201  */
202 #elif defined(__riscv) && defined(_LP64) && _LP64 && \
203         defined(__riscv_atomic) && __riscv_atomic
204
205 #ifndef __riscv__
206 #define __riscv__
207 #endif
208
209 #ifndef __rv64g__
210 #define __rv64g__
211 #endif
212
213 #define _ZFS_LITTLE_ENDIAN
214
215 #define _SUNOS_VTOC_16
216
217 #define _ALIGNMENT_REQUIRED     1
218
219 #else
220 /*
221  * Currently supported:
222  * x86_64, x32, i386, arm, powerpc, s390, sparc, mips, and RV64G
223  */
224 #error "Unsupported ISA type"
225 #endif
226
227 #if defined(_ILP32) && defined(_LP64)
228 #error "Both _ILP32 and _LP64 are defined"
229 #endif
230
231 #if !defined(_ILP32) && !defined(_LP64)
232 #error "Neither _ILP32 or _LP64 are defined"
233 #endif
234
235 #include <sys/byteorder.h>
236
237 /*
238  * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS will be defined by the Linux
239  * kernel for architectures which support efficient unaligned access.
240  */
241 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
242 #define HAVE_EFFICIENT_UNALIGNED_ACCESS
243 #endif
244
245 #if defined(_ZFS_LITTLE_ENDIAN) && defined(_ZFS_BIG_ENDIAN)
246 #error "Both _ZFS_LITTLE_ENDIAN and _ZFS_BIG_ENDIAN are defined"
247 #endif
248
249 #if !defined(_ZFS_LITTLE_ENDIAN) && !defined(_ZFS_BIG_ENDIAN)
250 #error "Neither _ZFS_LITTLE_ENDIAN or _ZFS_BIG_ENDIAN are defined"
251 #endif
252
253 #endif  /* _SPL_ISA_DEFS_H */