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