Math Processor Unit Library

libmpu – library of arithmetic functions for integer, real, and complex numbers of increased digit capacity

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