diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-31 13:46:01 (GMT) |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-31 13:46:01 (GMT) |
commit | e8bd88d1fcded01ccd066572eeaae1b507989cb3 (patch) | |
tree | c8e7be6c07c6f635f6e803e6a6ba9e7a95fee7c0 /gl/m4/host-cpu-c-abi.m4 | |
parent | 2ad962c13473607ca0d974bfaa516a0ed53ec73d (diff) | |
download | monitoring-plugins-e8bd88d1fcded01ccd066572eeaae1b507989cb3.tar.gz |
Sync with the latest Gnulib code 668c0b8ffa
Diffstat (limited to 'gl/m4/host-cpu-c-abi.m4')
-rw-r--r-- | gl/m4/host-cpu-c-abi.m4 | 678 |
1 files changed, 678 insertions, 0 deletions
diff --git a/gl/m4/host-cpu-c-abi.m4 b/gl/m4/host-cpu-c-abi.m4 new file mode 100644 index 0000000..134f228 --- /dev/null +++ b/gl/m4/host-cpu-c-abi.m4 | |||
@@ -0,0 +1,678 @@ | |||
1 | # host-cpu-c-abi.m4 serial 15 | ||
2 | dnl Copyright (C) 2002-2023 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | dnl From Bruno Haible and Sam Steingold. | ||
8 | |||
9 | dnl Sets the HOST_CPU variable to the canonical name of the CPU. | ||
10 | dnl Sets the HOST_CPU_C_ABI variable to the canonical name of the CPU with its | ||
11 | dnl C language ABI (application binary interface). | ||
12 | dnl Also defines __${HOST_CPU}__ and __${HOST_CPU_C_ABI}__ as C macros in | ||
13 | dnl config.h. | ||
14 | dnl | ||
15 | dnl This canonical name can be used to select a particular assembly language | ||
16 | dnl source file that will interoperate with C code on the given host. | ||
17 | dnl | ||
18 | dnl For example: | ||
19 | dnl * 'i386' and 'sparc' are different canonical names, because code for i386 | ||
20 | dnl will not run on SPARC CPUs and vice versa. They have different | ||
21 | dnl instruction sets. | ||
22 | dnl * 'sparc' and 'sparc64' are different canonical names, because code for | ||
23 | dnl 'sparc' and code for 'sparc64' cannot be linked together: 'sparc' code | ||
24 | dnl contains 32-bit instructions, whereas 'sparc64' code contains 64-bit | ||
25 | dnl instructions. A process on a SPARC CPU can be in 32-bit mode or in 64-bit | ||
26 | dnl mode, but not both. | ||
27 | dnl * 'mips' and 'mipsn32' are different canonical names, because they use | ||
28 | dnl different argument passing and return conventions for C functions, and | ||
29 | dnl although the instruction set of 'mips' is a large subset of the | ||
30 | dnl instruction set of 'mipsn32'. | ||
31 | dnl * 'mipsn32' and 'mips64' are different canonical names, because they use | ||
32 | dnl different sizes for the C types like 'int' and 'void *', and although | ||
33 | dnl the instruction sets of 'mipsn32' and 'mips64' are the same. | ||
34 | dnl * The same canonical name is used for different endiannesses. You can | ||
35 | dnl determine the endianness through preprocessor symbols: | ||
36 | dnl - 'arm': test __ARMEL__. | ||
37 | dnl - 'mips', 'mipsn32', 'mips64': test _MIPSEB vs. _MIPSEL. | ||
38 | dnl - 'powerpc64': test _BIG_ENDIAN vs. _LITTLE_ENDIAN. | ||
39 | dnl * The same name 'i386' is used for CPUs of type i386, i486, i586 | ||
40 | dnl (Pentium), AMD K7, Pentium II, Pentium IV, etc., because | ||
41 | dnl - Instructions that do not exist on all of these CPUs (cmpxchg, | ||
42 | dnl MMX, SSE, SSE2, 3DNow! etc.) are not frequently used. If your | ||
43 | dnl assembly language source files use such instructions, you will | ||
44 | dnl need to make the distinction. | ||
45 | dnl - Speed of execution of the common instruction set is reasonable across | ||
46 | dnl the entire family of CPUs. If you have assembly language source files | ||
47 | dnl that are optimized for particular CPU types (like GNU gmp has), you | ||
48 | dnl will need to make the distinction. | ||
49 | dnl See <https://en.wikipedia.org/wiki/X86_instruction_listings>. | ||
50 | AC_DEFUN([gl_HOST_CPU_C_ABI], | ||
51 | [ | ||
52 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
53 | AC_REQUIRE([gl_C_ASM]) | ||
54 | AC_CACHE_CHECK([host CPU and C ABI], [gl_cv_host_cpu_c_abi], | ||
55 | [case "$host_cpu" in | ||
56 | |||
57 | changequote(,)dnl | ||
58 | i[34567]86 ) | ||
59 | changequote([,])dnl | ||
60 | gl_cv_host_cpu_c_abi=i386 | ||
61 | ;; | ||
62 | |||
63 | x86_64 ) | ||
64 | # On x86_64 systems, the C compiler may be generating code in one of | ||
65 | # these ABIs: | ||
66 | # - 64-bit instruction set, 64-bit pointers, 64-bit 'long': x86_64. | ||
67 | # - 64-bit instruction set, 64-bit pointers, 32-bit 'long': x86_64 | ||
68 | # with native Windows (mingw, MSVC). | ||
69 | # - 64-bit instruction set, 32-bit pointers, 32-bit 'long': x86_64-x32. | ||
70 | # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': i386. | ||
71 | AC_COMPILE_IFELSE( | ||
72 | [AC_LANG_SOURCE( | ||
73 | [[#if (defined __x86_64__ || defined __amd64__ \ | ||
74 | || defined _M_X64 || defined _M_AMD64) | ||
75 | int ok; | ||
76 | #else | ||
77 | error fail | ||
78 | #endif | ||
79 | ]])], | ||
80 | [AC_COMPILE_IFELSE( | ||
81 | [AC_LANG_SOURCE( | ||
82 | [[#if defined __ILP32__ || defined _ILP32 | ||
83 | int ok; | ||
84 | #else | ||
85 | error fail | ||
86 | #endif | ||
87 | ]])], | ||
88 | [gl_cv_host_cpu_c_abi=x86_64-x32], | ||
89 | [gl_cv_host_cpu_c_abi=x86_64])], | ||
90 | [gl_cv_host_cpu_c_abi=i386]) | ||
91 | ;; | ||
92 | |||
93 | changequote(,)dnl | ||
94 | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] ) | ||
95 | changequote([,])dnl | ||
96 | gl_cv_host_cpu_c_abi=alpha | ||
97 | ;; | ||
98 | |||
99 | arm* | aarch64 ) | ||
100 | # Assume arm with EABI. | ||
101 | # On arm64 systems, the C compiler may be generating code in one of | ||
102 | # these ABIs: | ||
103 | # - aarch64 instruction set, 64-bit pointers, 64-bit 'long': arm64. | ||
104 | # - aarch64 instruction set, 32-bit pointers, 32-bit 'long': arm64-ilp32. | ||
105 | # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': arm or armhf. | ||
106 | AC_COMPILE_IFELSE( | ||
107 | [AC_LANG_SOURCE( | ||
108 | [[#ifdef __aarch64__ | ||
109 | int ok; | ||
110 | #else | ||
111 | error fail | ||
112 | #endif | ||
113 | ]])], | ||
114 | [AC_COMPILE_IFELSE( | ||
115 | [AC_LANG_SOURCE( | ||
116 | [[#if defined __ILP32__ || defined _ILP32 | ||
117 | int ok; | ||
118 | #else | ||
119 | error fail | ||
120 | #endif | ||
121 | ]])], | ||
122 | [gl_cv_host_cpu_c_abi=arm64-ilp32], | ||
123 | [gl_cv_host_cpu_c_abi=arm64])], | ||
124 | [# Don't distinguish little-endian and big-endian arm, since they | ||
125 | # don't require different machine code for simple operations and | ||
126 | # since the user can distinguish them through the preprocessor | ||
127 | # defines __ARMEL__ vs. __ARMEB__. | ||
128 | # But distinguish arm which passes floating-point arguments and | ||
129 | # return values in integer registers (r0, r1, ...) - this is | ||
130 | # gcc -mfloat-abi=soft or gcc -mfloat-abi=softfp - from arm which | ||
131 | # passes them in float registers (s0, s1, ...) and double registers | ||
132 | # (d0, d1, ...) - this is gcc -mfloat-abi=hard. GCC 4.6 or newer | ||
133 | # sets the preprocessor defines __ARM_PCS (for the first case) and | ||
134 | # __ARM_PCS_VFP (for the second case), but older GCC does not. | ||
135 | echo 'double ddd; void func (double dd) { ddd = dd; }' > conftest.c | ||
136 | # Look for a reference to the register d0 in the .s file. | ||
137 | AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $gl_c_asm_opt conftest.c) >/dev/null 2>&1 | ||
138 | if LC_ALL=C grep 'd0,' conftest.$gl_asmext >/dev/null; then | ||
139 | gl_cv_host_cpu_c_abi=armhf | ||
140 | else | ||
141 | gl_cv_host_cpu_c_abi=arm | ||
142 | fi | ||
143 | rm -f conftest* | ||
144 | ]) | ||
145 | ;; | ||
146 | |||
147 | hppa1.0 | hppa1.1 | hppa2.0* | hppa64 ) | ||
148 | # On hppa, the C compiler may be generating 32-bit code or 64-bit | ||
149 | # code. In the latter case, it defines _LP64 and __LP64__. | ||
150 | AC_COMPILE_IFELSE( | ||
151 | [AC_LANG_SOURCE( | ||
152 | [[#ifdef __LP64__ | ||
153 | int ok; | ||
154 | #else | ||
155 | error fail | ||
156 | #endif | ||
157 | ]])], | ||
158 | [gl_cv_host_cpu_c_abi=hppa64], | ||
159 | [gl_cv_host_cpu_c_abi=hppa]) | ||
160 | ;; | ||
161 | |||
162 | ia64* ) | ||
163 | # On ia64 on HP-UX, the C compiler may be generating 64-bit code or | ||
164 | # 32-bit code. In the latter case, it defines _ILP32. | ||
165 | AC_COMPILE_IFELSE( | ||
166 | [AC_LANG_SOURCE( | ||
167 | [[#ifdef _ILP32 | ||
168 | int ok; | ||
169 | #else | ||
170 | error fail | ||
171 | #endif | ||
172 | ]])], | ||
173 | [gl_cv_host_cpu_c_abi=ia64-ilp32], | ||
174 | [gl_cv_host_cpu_c_abi=ia64]) | ||
175 | ;; | ||
176 | |||
177 | mips* ) | ||
178 | # We should also check for (_MIPS_SZPTR == 64), but gcc keeps this | ||
179 | # at 32. | ||
180 | AC_COMPILE_IFELSE( | ||
181 | [AC_LANG_SOURCE( | ||
182 | [[#if defined _MIPS_SZLONG && (_MIPS_SZLONG == 64) | ||
183 | int ok; | ||
184 | #else | ||
185 | error fail | ||
186 | #endif | ||
187 | ]])], | ||
188 | [gl_cv_host_cpu_c_abi=mips64], | ||
189 | [# In the n32 ABI, _ABIN32 is defined, _ABIO32 is not defined (but | ||
190 | # may later get defined by <sgidefs.h>), and _MIPS_SIM == _ABIN32. | ||
191 | # In the 32 ABI, _ABIO32 is defined, _ABIN32 is not defined (but | ||
192 | # may later get defined by <sgidefs.h>), and _MIPS_SIM == _ABIO32. | ||
193 | AC_COMPILE_IFELSE( | ||
194 | [AC_LANG_SOURCE( | ||
195 | [[#if (_MIPS_SIM == _ABIN32) | ||
196 | int ok; | ||
197 | #else | ||
198 | error fail | ||
199 | #endif | ||
200 | ]])], | ||
201 | [gl_cv_host_cpu_c_abi=mipsn32], | ||
202 | [gl_cv_host_cpu_c_abi=mips])]) | ||
203 | ;; | ||
204 | |||
205 | powerpc* ) | ||
206 | # Different ABIs are in use on AIX vs. Mac OS X vs. Linux,*BSD. | ||
207 | # No need to distinguish them here; the caller may distinguish | ||
208 | # them based on the OS. | ||
209 | # On powerpc64 systems, the C compiler may still be generating | ||
210 | # 32-bit code. And on powerpc-ibm-aix systems, the C compiler may | ||
211 | # be generating 64-bit code. | ||
212 | AC_COMPILE_IFELSE( | ||
213 | [AC_LANG_SOURCE( | ||
214 | [[#if defined __powerpc64__ || defined __LP64__ | ||
215 | int ok; | ||
216 | #else | ||
217 | error fail | ||
218 | #endif | ||
219 | ]])], | ||
220 | [# On powerpc64, there are two ABIs on Linux: The AIX compatible | ||
221 | # one and the ELFv2 one. The latter defines _CALL_ELF=2. | ||
222 | AC_COMPILE_IFELSE( | ||
223 | [AC_LANG_SOURCE( | ||
224 | [[#if defined _CALL_ELF && _CALL_ELF == 2 | ||
225 | int ok; | ||
226 | #else | ||
227 | error fail | ||
228 | #endif | ||
229 | ]])], | ||
230 | [gl_cv_host_cpu_c_abi=powerpc64-elfv2], | ||
231 | [gl_cv_host_cpu_c_abi=powerpc64]) | ||
232 | ], | ||
233 | [gl_cv_host_cpu_c_abi=powerpc]) | ||
234 | ;; | ||
235 | |||
236 | rs6000 ) | ||
237 | gl_cv_host_cpu_c_abi=powerpc | ||
238 | ;; | ||
239 | |||
240 | riscv32 | riscv64 ) | ||
241 | # There are 2 architectures (with variants): rv32* and rv64*. | ||
242 | AC_COMPILE_IFELSE( | ||
243 | [AC_LANG_SOURCE( | ||
244 | [[#if __riscv_xlen == 64 | ||
245 | int ok; | ||
246 | #else | ||
247 | error fail | ||
248 | #endif | ||
249 | ]])], | ||
250 | [cpu=riscv64], | ||
251 | [cpu=riscv32]) | ||
252 | # There are 6 ABIs: ilp32, ilp32f, ilp32d, lp64, lp64f, lp64d. | ||
253 | # Size of 'long' and 'void *': | ||
254 | AC_COMPILE_IFELSE( | ||
255 | [AC_LANG_SOURCE( | ||
256 | [[#if defined __LP64__ | ||
257 | int ok; | ||
258 | #else | ||
259 | error fail | ||
260 | #endif | ||
261 | ]])], | ||
262 | [main_abi=lp64], | ||
263 | [main_abi=ilp32]) | ||
264 | # Float ABIs: | ||
265 | # __riscv_float_abi_double: | ||
266 | # 'float' and 'double' are passed in floating-point registers. | ||
267 | # __riscv_float_abi_single: | ||
268 | # 'float' are passed in floating-point registers. | ||
269 | # __riscv_float_abi_soft: | ||
270 | # No values are passed in floating-point registers. | ||
271 | AC_COMPILE_IFELSE( | ||
272 | [AC_LANG_SOURCE( | ||
273 | [[#if defined __riscv_float_abi_double | ||
274 | int ok; | ||
275 | #else | ||
276 | error fail | ||
277 | #endif | ||
278 | ]])], | ||
279 | [float_abi=d], | ||
280 | [AC_COMPILE_IFELSE( | ||
281 | [AC_LANG_SOURCE( | ||
282 | [[#if defined __riscv_float_abi_single | ||
283 | int ok; | ||
284 | #else | ||
285 | error fail | ||
286 | #endif | ||
287 | ]])], | ||
288 | [float_abi=f], | ||
289 | [float_abi='']) | ||
290 | ]) | ||
291 | gl_cv_host_cpu_c_abi="${cpu}-${main_abi}${float_abi}" | ||
292 | ;; | ||
293 | |||
294 | s390* ) | ||
295 | # On s390x, the C compiler may be generating 64-bit (= s390x) code | ||
296 | # or 31-bit (= s390) code. | ||
297 | AC_COMPILE_IFELSE( | ||
298 | [AC_LANG_SOURCE( | ||
299 | [[#if defined __LP64__ || defined __s390x__ | ||
300 | int ok; | ||
301 | #else | ||
302 | error fail | ||
303 | #endif | ||
304 | ]])], | ||
305 | [gl_cv_host_cpu_c_abi=s390x], | ||
306 | [gl_cv_host_cpu_c_abi=s390]) | ||
307 | ;; | ||
308 | |||
309 | sparc | sparc64 ) | ||
310 | # UltraSPARCs running Linux have `uname -m` = "sparc64", but the | ||
311 | # C compiler still generates 32-bit code. | ||
312 | AC_COMPILE_IFELSE( | ||
313 | [AC_LANG_SOURCE( | ||
314 | [[#if defined __sparcv9 || defined __arch64__ | ||
315 | int ok; | ||
316 | #else | ||
317 | error fail | ||
318 | #endif | ||
319 | ]])], | ||
320 | [gl_cv_host_cpu_c_abi=sparc64], | ||
321 | [gl_cv_host_cpu_c_abi=sparc]) | ||
322 | ;; | ||
323 | |||
324 | *) | ||
325 | gl_cv_host_cpu_c_abi="$host_cpu" | ||
326 | ;; | ||
327 | esac | ||
328 | ]) | ||
329 | |||
330 | dnl In most cases, $HOST_CPU and $HOST_CPU_C_ABI are the same. | ||
331 | HOST_CPU=`echo "$gl_cv_host_cpu_c_abi" | sed -e 's/-.*//'` | ||
332 | HOST_CPU_C_ABI="$gl_cv_host_cpu_c_abi" | ||
333 | AC_SUBST([HOST_CPU]) | ||
334 | AC_SUBST([HOST_CPU_C_ABI]) | ||
335 | |||
336 | # This was | ||
337 | # AC_DEFINE_UNQUOTED([__${HOST_CPU}__]) | ||
338 | # AC_DEFINE_UNQUOTED([__${HOST_CPU_C_ABI}__]) | ||
339 | # earlier, but KAI C++ 3.2d doesn't like this. | ||
340 | sed -e 's/-/_/g' >> confdefs.h <<EOF | ||
341 | #ifndef __${HOST_CPU}__ | ||
342 | #define __${HOST_CPU}__ 1 | ||
343 | #endif | ||
344 | #ifndef __${HOST_CPU_C_ABI}__ | ||
345 | #define __${HOST_CPU_C_ABI}__ 1 | ||
346 | #endif | ||
347 | EOF | ||
348 | AH_TOP([/* CPU and C ABI indicator */ | ||
349 | #ifndef __i386__ | ||
350 | #undef __i386__ | ||
351 | #endif | ||
352 | #ifndef __x86_64_x32__ | ||
353 | #undef __x86_64_x32__ | ||
354 | #endif | ||
355 | #ifndef __x86_64__ | ||
356 | #undef __x86_64__ | ||
357 | #endif | ||
358 | #ifndef __alpha__ | ||
359 | #undef __alpha__ | ||
360 | #endif | ||
361 | #ifndef __arm__ | ||
362 | #undef __arm__ | ||
363 | #endif | ||
364 | #ifndef __armhf__ | ||
365 | #undef __armhf__ | ||
366 | #endif | ||
367 | #ifndef __arm64_ilp32__ | ||
368 | #undef __arm64_ilp32__ | ||
369 | #endif | ||
370 | #ifndef __arm64__ | ||
371 | #undef __arm64__ | ||
372 | #endif | ||
373 | #ifndef __hppa__ | ||
374 | #undef __hppa__ | ||
375 | #endif | ||
376 | #ifndef __hppa64__ | ||
377 | #undef __hppa64__ | ||
378 | #endif | ||
379 | #ifndef __ia64_ilp32__ | ||
380 | #undef __ia64_ilp32__ | ||
381 | #endif | ||
382 | #ifndef __ia64__ | ||
383 | #undef __ia64__ | ||
384 | #endif | ||
385 | #ifndef __loongarch64__ | ||
386 | #undef __loongarch64__ | ||
387 | #endif | ||
388 | #ifndef __m68k__ | ||
389 | #undef __m68k__ | ||
390 | #endif | ||
391 | #ifndef __mips__ | ||
392 | #undef __mips__ | ||
393 | #endif | ||
394 | #ifndef __mipsn32__ | ||
395 | #undef __mipsn32__ | ||
396 | #endif | ||
397 | #ifndef __mips64__ | ||
398 | #undef __mips64__ | ||
399 | #endif | ||
400 | #ifndef __powerpc__ | ||
401 | #undef __powerpc__ | ||
402 | #endif | ||
403 | #ifndef __powerpc64__ | ||
404 | #undef __powerpc64__ | ||
405 | #endif | ||
406 | #ifndef __powerpc64_elfv2__ | ||
407 | #undef __powerpc64_elfv2__ | ||
408 | #endif | ||
409 | #ifndef __riscv32__ | ||
410 | #undef __riscv32__ | ||
411 | #endif | ||
412 | #ifndef __riscv64__ | ||
413 | #undef __riscv64__ | ||
414 | #endif | ||
415 | #ifndef __riscv32_ilp32__ | ||
416 | #undef __riscv32_ilp32__ | ||
417 | #endif | ||
418 | #ifndef __riscv32_ilp32f__ | ||
419 | #undef __riscv32_ilp32f__ | ||
420 | #endif | ||
421 | #ifndef __riscv32_ilp32d__ | ||
422 | #undef __riscv32_ilp32d__ | ||
423 | #endif | ||
424 | #ifndef __riscv64_ilp32__ | ||
425 | #undef __riscv64_ilp32__ | ||
426 | #endif | ||
427 | #ifndef __riscv64_ilp32f__ | ||
428 | #undef __riscv64_ilp32f__ | ||
429 | #endif | ||
430 | #ifndef __riscv64_ilp32d__ | ||
431 | #undef __riscv64_ilp32d__ | ||
432 | #endif | ||
433 | #ifndef __riscv64_lp64__ | ||
434 | #undef __riscv64_lp64__ | ||
435 | #endif | ||
436 | #ifndef __riscv64_lp64f__ | ||
437 | #undef __riscv64_lp64f__ | ||
438 | #endif | ||
439 | #ifndef __riscv64_lp64d__ | ||
440 | #undef __riscv64_lp64d__ | ||
441 | #endif | ||
442 | #ifndef __s390__ | ||
443 | #undef __s390__ | ||
444 | #endif | ||
445 | #ifndef __s390x__ | ||
446 | #undef __s390x__ | ||
447 | #endif | ||
448 | #ifndef __sh__ | ||
449 | #undef __sh__ | ||
450 | #endif | ||
451 | #ifndef __sparc__ | ||
452 | #undef __sparc__ | ||
453 | #endif | ||
454 | #ifndef __sparc64__ | ||
455 | #undef __sparc64__ | ||
456 | #endif | ||
457 | ]) | ||
458 | |||
459 | ]) | ||
460 | |||
461 | |||
462 | dnl Sets the HOST_CPU_C_ABI_32BIT variable to 'yes' if the C language ABI | ||
463 | dnl (application binary interface) is a 32-bit one, to 'no' if it is a 64-bit | ||
464 | dnl one, or to 'unknown' if unknown. | ||
465 | dnl This is a simplified variant of gl_HOST_CPU_C_ABI. | ||
466 | AC_DEFUN([gl_HOST_CPU_C_ABI_32BIT], | ||
467 | [ | ||
468 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
469 | AC_CACHE_CHECK([32-bit host C ABI], [gl_cv_host_cpu_c_abi_32bit], | ||
470 | [if test -n "$gl_cv_host_cpu_c_abi"; then | ||
471 | case "$gl_cv_host_cpu_c_abi" in | ||
472 | i386 | x86_64-x32 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | mips | mipsn32 | powerpc | riscv*-ilp32* | s390 | sparc) | ||
473 | gl_cv_host_cpu_c_abi_32bit=yes ;; | ||
474 | x86_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 ) | ||
475 | gl_cv_host_cpu_c_abi_32bit=no ;; | ||
476 | *) | ||
477 | gl_cv_host_cpu_c_abi_32bit=unknown ;; | ||
478 | esac | ||
479 | else | ||
480 | case "$host_cpu" in | ||
481 | |||
482 | # CPUs that only support a 32-bit ABI. | ||
483 | arc \ | ||
484 | | bfin \ | ||
485 | | cris* \ | ||
486 | | csky \ | ||
487 | | epiphany \ | ||
488 | | ft32 \ | ||
489 | | h8300 \ | ||
490 | | m68k \ | ||
491 | | microblaze | microblazeel \ | ||
492 | | nds32 | nds32le | nds32be \ | ||
493 | | nios2 | nios2eb | nios2el \ | ||
494 | | or1k* \ | ||
495 | | or32 \ | ||
496 | | sh | sh[1234] | sh[1234]e[lb] \ | ||
497 | | tic6x \ | ||
498 | | xtensa* ) | ||
499 | gl_cv_host_cpu_c_abi_32bit=yes | ||
500 | ;; | ||
501 | |||
502 | # CPUs that only support a 64-bit ABI. | ||
503 | changequote(,)dnl | ||
504 | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \ | ||
505 | | mmix ) | ||
506 | changequote([,])dnl | ||
507 | gl_cv_host_cpu_c_abi_32bit=no | ||
508 | ;; | ||
509 | |||
510 | changequote(,)dnl | ||
511 | i[34567]86 ) | ||
512 | changequote([,])dnl | ||
513 | gl_cv_host_cpu_c_abi_32bit=yes | ||
514 | ;; | ||
515 | |||
516 | x86_64 ) | ||
517 | # On x86_64 systems, the C compiler may be generating code in one of | ||
518 | # these ABIs: | ||
519 | # - 64-bit instruction set, 64-bit pointers, 64-bit 'long': x86_64. | ||
520 | # - 64-bit instruction set, 64-bit pointers, 32-bit 'long': x86_64 | ||
521 | # with native Windows (mingw, MSVC). | ||
522 | # - 64-bit instruction set, 32-bit pointers, 32-bit 'long': x86_64-x32. | ||
523 | # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': i386. | ||
524 | AC_COMPILE_IFELSE( | ||
525 | [AC_LANG_SOURCE( | ||
526 | [[#if (defined __x86_64__ || defined __amd64__ \ | ||
527 | || defined _M_X64 || defined _M_AMD64) \ | ||
528 | && !(defined __ILP32__ || defined _ILP32) | ||
529 | int ok; | ||
530 | #else | ||
531 | error fail | ||
532 | #endif | ||
533 | ]])], | ||
534 | [gl_cv_host_cpu_c_abi_32bit=no], | ||
535 | [gl_cv_host_cpu_c_abi_32bit=yes]) | ||
536 | ;; | ||
537 | |||
538 | arm* | aarch64 ) | ||
539 | # Assume arm with EABI. | ||
540 | # On arm64 systems, the C compiler may be generating code in one of | ||
541 | # these ABIs: | ||
542 | # - aarch64 instruction set, 64-bit pointers, 64-bit 'long': arm64. | ||
543 | # - aarch64 instruction set, 32-bit pointers, 32-bit 'long': arm64-ilp32. | ||
544 | # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': arm or armhf. | ||
545 | AC_COMPILE_IFELSE( | ||
546 | [AC_LANG_SOURCE( | ||
547 | [[#if defined __aarch64__ && !(defined __ILP32__ || defined _ILP32) | ||
548 | int ok; | ||
549 | #else | ||
550 | error fail | ||
551 | #endif | ||
552 | ]])], | ||
553 | [gl_cv_host_cpu_c_abi_32bit=no], | ||
554 | [gl_cv_host_cpu_c_abi_32bit=yes]) | ||
555 | ;; | ||
556 | |||
557 | hppa1.0 | hppa1.1 | hppa2.0* | hppa64 ) | ||
558 | # On hppa, the C compiler may be generating 32-bit code or 64-bit | ||
559 | # code. In the latter case, it defines _LP64 and __LP64__. | ||
560 | AC_COMPILE_IFELSE( | ||
561 | [AC_LANG_SOURCE( | ||
562 | [[#ifdef __LP64__ | ||
563 | int ok; | ||
564 | #else | ||
565 | error fail | ||
566 | #endif | ||
567 | ]])], | ||
568 | [gl_cv_host_cpu_c_abi_32bit=no], | ||
569 | [gl_cv_host_cpu_c_abi_32bit=yes]) | ||
570 | ;; | ||
571 | |||
572 | ia64* ) | ||
573 | # On ia64 on HP-UX, the C compiler may be generating 64-bit code or | ||
574 | # 32-bit code. In the latter case, it defines _ILP32. | ||
575 | AC_COMPILE_IFELSE( | ||
576 | [AC_LANG_SOURCE( | ||
577 | [[#ifdef _ILP32 | ||
578 | int ok; | ||
579 | #else | ||
580 | error fail | ||
581 | #endif | ||
582 | ]])], | ||
583 | [gl_cv_host_cpu_c_abi_32bit=yes], | ||
584 | [gl_cv_host_cpu_c_abi_32bit=no]) | ||
585 | ;; | ||
586 | |||
587 | mips* ) | ||
588 | # We should also check for (_MIPS_SZPTR == 64), but gcc keeps this | ||
589 | # at 32. | ||
590 | AC_COMPILE_IFELSE( | ||
591 | [AC_LANG_SOURCE( | ||
592 | [[#if defined _MIPS_SZLONG && (_MIPS_SZLONG == 64) | ||
593 | int ok; | ||
594 | #else | ||
595 | error fail | ||
596 | #endif | ||
597 | ]])], | ||
598 | [gl_cv_host_cpu_c_abi_32bit=no], | ||
599 | [gl_cv_host_cpu_c_abi_32bit=yes]) | ||
600 | ;; | ||
601 | |||
602 | powerpc* ) | ||
603 | # Different ABIs are in use on AIX vs. Mac OS X vs. Linux,*BSD. | ||
604 | # No need to distinguish them here; the caller may distinguish | ||
605 | # them based on the OS. | ||
606 | # On powerpc64 systems, the C compiler may still be generating | ||
607 | # 32-bit code. And on powerpc-ibm-aix systems, the C compiler may | ||
608 | # be generating 64-bit code. | ||
609 | AC_COMPILE_IFELSE( | ||
610 | [AC_LANG_SOURCE( | ||
611 | [[#if defined __powerpc64__ || defined __LP64__ | ||
612 | int ok; | ||
613 | #else | ||
614 | error fail | ||
615 | #endif | ||
616 | ]])], | ||
617 | [gl_cv_host_cpu_c_abi_32bit=no], | ||
618 | [gl_cv_host_cpu_c_abi_32bit=yes]) | ||
619 | ;; | ||
620 | |||
621 | rs6000 ) | ||
622 | gl_cv_host_cpu_c_abi_32bit=yes | ||
623 | ;; | ||
624 | |||
625 | riscv32 | riscv64 ) | ||
626 | # There are 6 ABIs: ilp32, ilp32f, ilp32d, lp64, lp64f, lp64d. | ||
627 | # Size of 'long' and 'void *': | ||
628 | AC_COMPILE_IFELSE( | ||
629 | [AC_LANG_SOURCE( | ||
630 | [[#if defined __LP64__ | ||
631 | int ok; | ||
632 | #else | ||
633 | error fail | ||
634 | #endif | ||
635 | ]])], | ||
636 | [gl_cv_host_cpu_c_abi_32bit=no], | ||
637 | [gl_cv_host_cpu_c_abi_32bit=yes]) | ||
638 | ;; | ||
639 | |||
640 | s390* ) | ||
641 | # On s390x, the C compiler may be generating 64-bit (= s390x) code | ||
642 | # or 31-bit (= s390) code. | ||
643 | AC_COMPILE_IFELSE( | ||
644 | [AC_LANG_SOURCE( | ||
645 | [[#if defined __LP64__ || defined __s390x__ | ||
646 | int ok; | ||
647 | #else | ||
648 | error fail | ||
649 | #endif | ||
650 | ]])], | ||
651 | [gl_cv_host_cpu_c_abi_32bit=no], | ||
652 | [gl_cv_host_cpu_c_abi_32bit=yes]) | ||
653 | ;; | ||
654 | |||
655 | sparc | sparc64 ) | ||
656 | # UltraSPARCs running Linux have `uname -m` = "sparc64", but the | ||
657 | # C compiler still generates 32-bit code. | ||
658 | AC_COMPILE_IFELSE( | ||
659 | [AC_LANG_SOURCE( | ||
660 | [[#if defined __sparcv9 || defined __arch64__ | ||
661 | int ok; | ||
662 | #else | ||
663 | error fail | ||
664 | #endif | ||
665 | ]])], | ||
666 | [gl_cv_host_cpu_c_abi_32bit=no], | ||
667 | [gl_cv_host_cpu_c_abi_32bit=yes]) | ||
668 | ;; | ||
669 | |||
670 | *) | ||
671 | gl_cv_host_cpu_c_abi_32bit=unknown | ||
672 | ;; | ||
673 | esac | ||
674 | fi | ||
675 | ]) | ||
676 | |||
677 | HOST_CPU_C_ABI_32BIT="$gl_cv_host_cpu_c_abi_32bit" | ||
678 | ]) | ||