ssa: delete unused label skip_must_be_flat
[ajla.git] / configure.ac
blobd48cf910a8f9229519793608b9de28412bab69c6
1 # Copyright (C) 2024 Mikulas Patocka
3 # This file is part of Ajla.
5 # Ajla is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation, either version 3 of the License, or (at your option) any later
8 # version.
10 # Ajla is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Ajla. If not, see <https://www.gnu.org/licenses/>.
17 #                                               -*- Autoconf -*-
18 # Process this file with autoconf to produce a configure script.
20 AC_PREREQ(2.59)
21 AC_INIT(ajla, 0.1.5)
22 AC_CONFIG_SRCDIR(ajla.c)
23 AC_CONFIG_HEADERS(config.h)
24 AM_INIT_AUTOMAKE(-Wall -Werror)
26 if uname 2>/dev/null | grep -i OS/2 >/dev/null || uname 2>/dev/null | grep -i Dos >/dev/null; then
27         ac_cv_path_GREP=grep
30 ACLOCAL="touch aclocal.m4; echo >/dev/null"
31 AUTOCONF="touch configure; echo >/dev/null"
32 AUTOMAKE="touch Makefile.in; echo >/dev/null"
33 AUTOHEADER="touch config.h.in; echo >/dev/null"
35 AC_CANONICAL_HOST
37 # Checks for programs.
38 AC_PROG_CC
40 CPPFLAGS="-D_GNU_SOURCE -D_ALL_SOURCE $CPPFLAGS"
42 case ${host_os} in
43         *bsd*)
44                 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
45                 LDFLAGS="$LDFLAGS -L/usr/local/lib"
46                 ;;
47 esac
49 AC_CACHE_CHECK([for EMX], ac_cv_have_emx,
50         AC_TRY_COMPILE(, [#ifndef __EMX__
51         kill me!
52         #endif ], ac_cv_have_emx=yes, ac_cv_have_emx=no)
54 AC_CACHE_CHECK([for WIN32], ac_cv_have_win32,
55         AC_TRY_COMPILE(, [#ifndef _WIN32
56         kill me!
57         #endif ], ac_cv_have_win32=yes, ac_cv_have_win32=no)
59 AC_CACHE_CHECK([for Minix 3], ac_cv_have_minix3,
60         AC_TRY_COMPILE(, [#ifndef __minix__
61         kill me!
62         #endif ], ac_cv_have_minix3=yes, ac_cv_have_minix3=no)
65 AC_ARG_ENABLE(threads, [  --disable-threads       disable threads], enable_threads="$enableval", enable_threads=yes)
67 if test "$enable_threads" != no && test "$ac_cv_have_minix3" = no; then
68         if test "$enable_threads" = pthread || test "$ac_cv_have_emx" != yes -a "$ac_cv_have_win32" != yes; then
69                 AX_PTHREAD
70                 LIBS="$PTHREAD_LIBS $LIBS"
71                 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
72                 CC="$PTHREAD_CC"
73         fi
74         if test "$ax_pthread_ok" != yes -a "$ac_cv_have_emx" = yes; then
75                 CFLAGS="$CFLAGS -Zmt"
76         fi
77         if test "$ax_pthread_ok" = yes -a "$enable_threads" = pthread; then
78                 AC_DEFINE([HAVE_PTHREAD_PREFER], 1, [Prefer pthreads])
79         fi
82 AC_ARG_ENABLE(computed-goto, [  --disable-computed-goto disable computed goto], enable_computed_goto="$enableval", enable_computed_goto=yes)
84 AC_ARG_ENABLE(bitwise-frame, [  --enable-bitwise-frame  use bitwise tags on the frame], enable_bitwise_frame="$enableval", enable_bitwise_frame=no)
85 test "$enable_bitwise_frame" = yes && AC_DEFINE(HAVE_BITWISE_FRAME, 1, Use bitwise frame)
87 AC_ARG_ENABLE(debuglevel, [  --enable-debuglevel     set internal checking level
88         0 - no checks
89         1 - checks that don't degrade performane (default)
90         2 - checks that degrade performance
91         3 - checks that degrade performance seriously], enable_debuglevel="$enableval", enable_debuglevel=1)
92 if test "$enable_debuglevel" = no; then enable_debuglevel=0; fi
93 if test "$enable_debuglevel" = yes; then enable_debuglevel=2; fi
94 AC_DEFINE_UNQUOTED(HAVE_DEBUGLEVEL, $enable_debuglevel, Debugging level)
96 # Checks for typedefs, structures, and compiler characteristics.
97 AC_HEADER_STDBOOL
98 AC_C_INLINE
99 AC_TYPE_SIZE_T
100 AX_C_LONG_LONG
101 AC_C_LONG_DOUBLE
102 AC_CACHE_CHECK(for __float128, ac_cv_have___float128,
103 AC_TRY_LINK([
104         volatile __float128 a = 0.1;
105         volatile __float128 b = 0.2;
106         volatile __float128 c, d, e, f;
107         volatile int g, h, i, j;
108 ], [
109         c = a + b;
110         d = a - b;
111         e = a * b;
112         f = a / b;
113         g = e == f;
114         h = e != f;
115         i = e < f;
116         j = e <= f;
117 ], ac_cv_have___float128=yes, ac_cv_have___float128=no))
118 test "$ac_cv_have___float128" = yes && AC_DEFINE(HAVE___FLOAT128, 1, Have __float128)
120 AC_CACHE_CHECK(for signbit(__float128), ac_cv_have_signbit__float128,
121 AC_TRY_RUN([
122 #include <math.h>
123 volatile __float128 a = 0.1;
124 int main(void)
126         return signbit(a);
128 ], ac_cv_have_signbit__float128=yes, ac_cv_have_signbit__float128=no, ac_cv_have_signbit__float128=no))
129 test "$ac_cv_have_signbit__float128" = yes && AC_DEFINE(HAVE_SIGNBIT___FLOAT128, 1, Have signbit(__float128))
131 AC_CHECK_TYPES([max_align_t], [], [], [[#include <stddef.h>]])
132 AC_CHECK_TYPES([sig_atomic_t], [], [], [[#include <signal.h>]])
133 AC_CHECK_TYPES([sigset_t], [], [], [[#include <signal.h>]])
134 AC_CHECK_TYPES([socklen_t], [], [], [[
135 #include <sys/types.h>
136 #include <sys/socket.h>]])
137 AC_CHECK_TYPES([_Float16], [], [], [])
139 default_short=0
140 default_int=0
141 default_long=0
142 default_long_long=0
143 default_unsigned__int128=0
144 default_void=0
145 default_size_t=0
147 AC_CHECK_SIZEOF(unsigned short,"$default_short")
148 AC_CHECK_SIZEOF(unsigned, "$default_int")
149 AC_CHECK_SIZEOF(unsigned long, "$default_long")
150 AC_CHECK_SIZEOF(unsigned long long, "$default_long_long")
151 AC_CHECK_SIZEOF(unsigned __int128, "$default_unsigned__int128")
152 AC_CHECK_SIZEOF(void *, "$default_void")
153 AC_CHECK_SIZEOF(size_t, "$default_size_t")
155 if test "$ax_pthread_ok" = yes; then
156         AC_CACHE_CHECK([for PTHREAD_MUTEX_ERRORCHECK],
157             ax_cv_PTHREAD_MUTEX_ERRORCHECK, [
158                 AC_LINK_IFELSE([
159                     AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_MUTEX_ERRORCHECK;]])],
160                     [ax_cv_PTHREAD_MUTEX_ERRORCHECK=yes],
161                     [ax_cv_PTHREAD_MUTEX_ERRORCHECK=no])
162             ])
163         AS_IF([test "x$ax_cv_PTHREAD_MUTEX_ERRORCHECK" = "xyes"],
164             AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK], 1, [Have PTHREAD_MUTEX_ERRORCHECK]))
167         AC_CACHE_CHECK([for PTHREAD_MUTEX_ERRORCHECK_NP],
168             ax_cv_PTHREAD_MUTEX_ERRORCHECK_NP, [
169                 AC_LINK_IFELSE([
170                     AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_MUTEX_ERRORCHECK_NP;]])],
171                     [ax_cv_PTHREAD_MUTEX_ERRORCHECK_NP=yes],
172                     [ax_cv_PTHREAD_MUTEX_ERRORCHECK_NP=no])
173             ])
174         AS_IF([test "x$ax_cv_PTHREAD_MUTEX_ERRORCHECK_NP" = "xyes"],
175             AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1, [Have PTHREAD_MUTEX_ERRORCHECK_NP]))
177         AC_CACHE_CHECK([if we can assign to pthread_key_t],
178             ax_cv_pthread_key_t_assign, [
179                 AC_COMPILE_IFELSE([
180                     AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_key_t key = (pthread_key_t)-1;]])],
181                     [ax_cv_pthread_key_t_assign=yes],
182                     [ax_cv_pthread_key_t_assign=no])
183             ])
184         AS_IF([test "x$ax_cv_pthread_key_t_assign" = "xyes"],
185             AC_DEFINE([HAVE_PTHREAD_KEY_T_ASSIGN], 1, [Can assign to pthread_key_t]))
189 AC_CACHE_CHECK(for __thread, ac_cv_have___thread,
190 AC_TRY_LINK([
191         __thread int i = 0;
192         static __thread int j = 0;
193 ], [
194         return i + j;
195 ], ac_cv_have___thread=yes, ac_cv_have___thread=no))
196 test "$ac_cv_have___thread" = yes && AC_DEFINE(HAVE___THREAD, __thread, Have thread local storage)
198 AC_CACHE_CHECK(for computed goto, ac_cv_have_computed_goto,
199 AC_TRY_LINK([
200 ], [
201         static const void *dispatch[[4096]] = {
202                 [[10]] = &&label_10,
203         };
204         goto *(void *)dispatch[[10]];
205 label_10:
206         return 0;
207 #if defined(__GNUC__) && __GNUC__ <= 2
208         kill me!
209 #endif
210 ], ac_cv_have_computed_goto=yes, ac_cv_have_computed_goto=no))
211 test "$ac_cv_have_computed_goto" = yes && test "$enable_computed_goto" != no && AC_DEFINE(HAVE_COMPUTED_GOTO, 1, Have computed goto)
213 if echo "$CC" | grep clang >/dev/null; then
214         AC_CACHE_CHECK(for -no-integrated-as, ac_cv_have_no_integrated_as,
215         save_CFLAGS="$CFLAGS"
216         CFLAGS="-no-integrated-as $CFLAGS"
217         AC_TRY_LINK([ ], [ ], ac_cv_have_no_integrated_as=yes, ac_cv_have_no_integrated_as=no)
218         CFLAGS="$save_CFLAGS"
219         )
220         test "$ac_cv_have_no_integrated_as" = yes && CFLAGS="-no-integrated-as $CFLAGS"
223 AC_CACHE_CHECK(for gcc assembler, ac_cv_have_gcc_assembler,
224 AC_TRY_LINK([
225 ], [
226         int src, dest;
227         src = 0;
228         __asm__ (""::"i"(63355));
229         __asm__ volatile ("":::"memory");
230         __asm__ (".if 0 \n .endif" : "=r"(dest) : "0"(src));
231 #ifdef __OPEN64__
232         kill me!
233 #endif
234         return dest;
235 ], ac_cv_have_gcc_assembler=yes, ac_cv_have_gcc_assembler=no))
236 test "$ac_cv_have_gcc_assembler" = yes && AC_DEFINE(HAVE_GCC_ASSEMBLER, 1, Have gcc assembler)
238 if test "$ac_cv_have_gcc_assembler" = yes; then
239         AC_CACHE_CHECK(for asm goto, ac_cv_have_asm_goto,
240         AC_TRY_LINK([
241         ], [
242                 __asm__ goto("" : : : : label);
243                 label:
244                 return 0;
245         ], ac_cv_have_asm_goto=yes, ac_cv_have_asm_goto=no))
246         test "$ac_cv_have_asm_goto" = yes && AC_DEFINE(HAVE_ASM_GOTO, 1, Have asm goto)
248         if test "$ac_cv_sizeof_unsigned___int128" != 0; then
249                 AC_CACHE_CHECK(for assembler __int128, ac_cv_have_assembler___int128,
250                 AC_TRY_COMPILE([
251                 ], [
252                         volatile __int128 a, b;
253                         a = 1;
254 #if defined(__aarch64__)
255                         __asm__ ("mov %H0, %H1; mov %x0, %x1" : "=&r"(b) : "r"(a));
256 #elif defined(__x86_64__)
257                         __asm__ ("" : "=A"(b) : "A"(a));
258 #else
259                         __asm__ ("" : "=r"(b) : "0"(a));
260 #endif
261                         return (int)b;
262                 ], ac_cv_have_assembler___int128=yes, ac_cv_have_assembler___int128=no))
263                 test "$ac_cv_have_assembler___int128" = yes && AC_DEFINE(HAVE_ASSEMBLER___INT128, 1, Have assembler __int128)
264         fi
266         AC_CACHE_CHECK(for X86 assembler popcnt, ac_cv_have_x86_assembler_popcnt,
267         AC_TRY_LINK([
268         ], [
269                 __asm__ volatile ("popcntw %%ax, %%bx \n popcntl %%eax, %%ebx":::"eax", "ebx", "cc");
270         ], ac_cv_have_x86_assembler_popcnt=yes, ac_cv_have_x86_assembler_popcnt=no))
271         test "$ac_cv_have_x86_assembler_popcnt" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_POPCNT, 1, Have X86 popcnt)
273         AC_CACHE_CHECK(for X86 assembler lzcnt, ac_cv_have_x86_assembler_lzcnt,
274         AC_TRY_LINK([
275         ], [
276                 __asm__ volatile ("lzcntw %%ax, %%bx \n lzcntl %%eax, %%ebx":::"eax", "ebx", "cc");
277         ], ac_cv_have_x86_assembler_lzcnt=yes, ac_cv_have_x86_assembler_lzcnt=no))
278         test "$ac_cv_have_x86_assembler_lzcnt" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_LZCNT, 1, Have X86 lzcnt)
280         AC_CACHE_CHECK(for X86 assembler sse, ac_cv_have_x86_assembler_sse,
281         AC_TRY_LINK([
282         ], [
283                 int i;
284                 float a = 0;
285                 __asm__ volatile ("cvtss2si (%1), %0":"=r"(i):"r"(&a));
286         ], ac_cv_have_x86_assembler_sse=yes, ac_cv_have_x86_assembler_sse=no))
287         test "$ac_cv_have_x86_assembler_sse" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_SSE, 1, Have X86 sse)
289         AC_CACHE_CHECK(for X86 assembler sse2, ac_cv_have_x86_assembler_sse2,
290         AC_TRY_LINK([
291         ], [
292                 int i;
293                 float a = 0;
294                 __asm__ volatile ("cvtsd2si (%1), %0":"=r"(i):"r"(&a));
295         ], ac_cv_have_x86_assembler_sse2=yes, ac_cv_have_x86_assembler_sse2=no))
296         test "$ac_cv_have_x86_assembler_sse2" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_SSE2, 1, Have X86 sse2)
298         AC_CACHE_CHECK(for X86 assembler avx, ac_cv_have_x86_assembler_avx,
299         AC_TRY_LINK([
300         ], [
301                 int i;
302                 float a = 0;
303                 __asm__ volatile ("vcvtss2si (%1), %0":"=r"(i):"r"(&a));
304         ], ac_cv_have_x86_assembler_avx=yes, ac_cv_have_x86_assembler_avx=no))
305         test "$ac_cv_have_x86_assembler_avx" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_AVX, 1, Have X86 avx)
307         AC_CACHE_CHECK(for X86 assembler f16c, ac_cv_have_x86_assembler_f16c,
308         AC_TRY_LINK([
309         ], [
310                 __asm__ volatile ("vcvtps2ph \$0, %%xmm0, %%xmm0":::"memory");
311         ], ac_cv_have_x86_assembler_f16c=yes, ac_cv_have_x86_assembler_f16c=no))
312         test "$ac_cv_have_x86_assembler_f16c" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_F16C, 1, Have X86 f16c)
314         AC_CACHE_CHECK(for ARM assembler, ac_cv_have_arm_assembler,
315         AC_TRY_LINK([
316         ], [
317                 __asm__ volatile (".cpu cortex-a15 \n .fpu neon-vfpv4 \n mov r1, r2":::"r1", "r2");
318         ], ac_cv_have_arm_assembler=yes, ac_cv_have_arm_assembler=no))
319         test "$ac_cv_have_arm_assembler" = yes && AC_DEFINE(HAVE_ARM_ASSEMBLER, 1, Have ARM assembler)
321         if test "$ac_cv_have_arm_assembler" = yes; then
322                 AC_CACHE_CHECK(for ARM assembler clz, ac_cv_have_arm_assembler_clz,
323                 AC_TRY_LINK([
324                 ], [
325                         __asm__ volatile (".cpu cortex-a15 \n .fpu neon-vfpv4 \n clz r1, r2":::"r1", "r2");
326                 ], ac_cv_have_arm_assembler_clz=yes, ac_cv_have_arm_assembler_clz=no))
327                 test "$ac_cv_have_arm_assembler_clz" = yes && AC_DEFINE(HAVE_ARM_ASSEMBLER_CLZ, 1, Have ARM clz)
329                 AC_CACHE_CHECK(for ARM assembler rbit, ac_cv_have_arm_assembler_rbit,
330                 AC_TRY_LINK([
331                 ], [
332                         __asm__ volatile (".cpu cortex-a15 \n .fpu neon-vfpv4 \n rbit r1, r2":::"r1", "r2");
333                 ], ac_cv_have_arm_assembler_rbit=yes, ac_cv_have_arm_assembler_rbit=no))
334                 test "$ac_cv_have_arm_assembler_rbit" = yes && AC_DEFINE(HAVE_ARM_ASSEMBLER_RBIT, 1, Have ARM rbit)
336                 AC_CACHE_CHECK(for ARM assembler sdiv udiv, ac_cv_have_arm_assembler_sdiv_udiv,
337                 AC_TRY_LINK([
338                 ], [
339                         __asm__ volatile (".cpu cortex-a15 \n .fpu neon-vfpv4 \n sdiv r1, r2, r3 \n udiv r1, r2, r3":::"r1", "r2", "r3");
340                 ], ac_cv_have_arm_assembler_sdiv_udiv=yes, ac_cv_have_arm_assembler_sdiv_udiv=no))
341                 test "$ac_cv_have_arm_assembler_sdiv_udiv" = yes && AC_DEFINE(HAVE_ARM_ASSEMBLER_SDIV_UDIV, 1, Have ARM sdiv udiv)
343                 AC_CACHE_CHECK(for ARM assembler half-precision, ac_cv_have_arm_assembler_half_precision,
344                 AC_TRY_LINK([
345                 ], [
346                         __asm__ volatile (".cpu cortex-a15 \n .fpu neon-vfpv4 \n vcvtb.f16.f32 s0, s0 \n vcvtb.f32.f16 s0, s0":::"s0");
347                 ], ac_cv_have_arm_assembler_half_precision=yes, ac_cv_have_arm_assembler_half_precision=no))
348                 test "$ac_cv_have_arm_assembler_half_precision" = yes && AC_DEFINE(HAVE_ARM_ASSEMBLER_HALF_PRECISION, 1, Have ARM half precision)
350                 AC_CACHE_CHECK(for ARM assembler vfp, ac_cv_have_arm_assembler_vfp,
351                 AC_TRY_LINK([
352                 ], [
353                         __asm__ volatile (".cpu cortex-a15 \n .fpu neon-vfpv4 \n vld1.8 d0[[0]], [[r1]] \n vcnt.8 d0, d0 \n vpaddl.u8 d0, d0 \n vst1.8 d0[[0]], [[r1]]":::"r1", "d0");
354                 ], ac_cv_have_arm_assembler_vfp=yes, ac_cv_have_arm_assembler_vfp=no))
355                 test "$ac_cv_have_arm_assembler_vfp" = yes && AC_DEFINE(HAVE_ARM_ASSEMBLER_VFP, 1, Have ARM VFP)
356         fi
359 # Checks for header files.
360 AC_CHECK_HEADERS(asm/prctl.h ffi.h gmp.h gmp/gmp.h linux/falloc.h linux/fs.h malloc.h netdb.h netinet/in.h os2thunk.h quadmath.h signal.h stdalign.h stdatomic.h stdnoreturn.h sys/auxv.h sys/builtin.h sys/epoll.h sys/event.h sys/fmutex.h sys/inotify.h sys/mman.h sys/mount.h sys/netinet.in sys/param.h sys/pstat.h sys/select.h sys/socket.h sys/statvfs.h sys/syscall.h sys/sysctl.h sys/sysmacros.h sys/time.h sys/ucred.h sys/utsname.h sys/vfs.h ucontext.h)
362 # Checks for libraries.
363 AC_CHECK_LIB(m, frexp)
364 if test "$ac_cv_have___float128" = yes && test "$ac_cv_header_quadmath_h" = yes; then
365         AC_CHECK_LIB(quadmath, frexpq)
367 AC_ARG_WITH(gmp, [  --without-gmp           use built-in gmp])
368 if test "$with_gmp" != "no"; then
369         if test "$ac_cv_header_gmp_h" = yes || test "$ac_cv_header_gmp_gmp_h" = yes; then
370                 AC_CHECK_LIB(gmp, __gmpz_init2)
371         fi
373 if test "$ac_cv_header_ffi_h" = yes; then
374         AC_CHECK_LIB(ffi, ffi_prep_cif)
375         AC_CHECK_FUNCS(ffi_prep_cif_var)
376         if test "$ac_cv_have_emx" = no -a "$ac_cv_have_win32" = no; then
377                 AC_CHECK_FUNCS(dlopen)
378                 if test "$ac_cv_have_dlopen" != yes; then
379                         AC_CHECK_LIB(dl, dlopen)
380                 fi
381         fi
384 AC_FUNC_MALLOC
386 AC_CHECK_LIB(xnet, getpeername)
388 # Checks for library functions.
389 AC_CHECK_FUNCS(accept4 aligned_alloc cfmakeraw chown clock_gettime epoll_create fallocate fchdir fchmodat fchownat fdatasync ffs ffsl ffsll fls flsl flsll fstat64 fstatat fstatfs fstatvfs fstatvfs64 ftruncate64 getauxval getenv getfsstat gethostname getpagesize getpeername getvfsstat gmtime_r inotify_init isatty kqueue lchown link linkat localtime_r lseek64 lstat lstat64 madvise memalign mempcpy mkdirat mknod mknodat mkostemp mmap mmap64 mprotect mremap open64 openat pipe2 posix_memalign pread pread64 pstat_getdynamic pthread_condattr_setclock pthread_sigmask pthread_spin_init pwrite pwrite64 raise readlink readlinkat renameat setitimer setvbuf sigaction sigblock sigfillset sigprocmask sigsetmask socket stat64 statfs statvfs statvfs64 strerror strerror_r strnlen strverscmp symlink symlinkat syncfs syscall sysconf sysctl timegm timer_create truncate64 uname unlinkat utime utimensat utimes vsnprintf _beginthreadex _fmutex_create _threadstore)
391 AC_CHECK_FUNCS(
392         copysign copysignf                                              \
393         nextafter nextafterf nextafterl                                 \
394         fabsf fabsl fabsq                                               \
395         finite finitef finitel finiteq                                  \
396         isnan isnanf isnanl isnanq                                      \
397         lrintf                                                          \
398                                                                         \
399         sqrtf sqrtl sqrtq                                               \
400         cbrt cbrtf cbrtl                                                \
401                                                                         \
402         sinf sinl                                                       \
403         cosf cosl                                                       \
404         tanf tanl                                                       \
405         asinf asinl                                                     \
406         acosf acosl                                                     \
407         atanf atanl                                                     \
408                                                                         \
409         sinhf sinhl                                                     \
410         coshf coshl                                                     \
411         tanhf tanhl                                                     \
412         asinh asinhf asinhl                                             \
413         acosh acoshf acoshl                                             \
414         atanh atanhf atanhl                                             \
415                                                                         \
416         exp2 exp2f exp2l exp2q                                          \
417         expf expl                                                       \
418         exp10 exp10f exp10l exp10q                                      \
419         log2 log2f log2l                                                \
420         logf logl                                                       \
421         log10f log10l                                                   \
422                                                                         \
423         rint rintf rintl                                                \
424         ceilf ceill                                                     \
425         floorf floorl                                                   \
426         trunc truncf truncl                                             \
427         modff modfl                                                     \
428         frexpf frexpl frexpq                                            \
429                                                                         \
430         fmodf fmodl                                                     \
431         powf powl powq                                                  \
432         ldexpf ldexpl ldexpq                                            \
433         atan2f atan2l                                                   \
436 cf_have_socket=yes
437 if test "$ac_cv_func_socket" != yes; then
438         AC_CHECK_LIB(socket, socket)
439         if test "$ac_cv_lib_socket_socket" != yes; then
440                 AC_CHECK_LIB(watt, socket)
441                 if test "$ac_cv_lib_watt_socket" != yes; then
442                         AC_CHECK_LIB(wsock32, socket)
443                         if test "$ac_cv_lib_wsock32_socket" != yes; then
444                                 if echo "$CC" | grep -i mingw >/dev/null; then
445                                         LIBS="-lwsock32 $LIBS"
446                                 else
447                                         cf_have_socket=no
448                                 fi
449                         fi
450                 fi
451         fi
453 AC_CHECK_FUNCS(gethostbyname)
454 if test "$ac_cv_func_gethostbyname" != yes; then
455         AC_CHECK_LIB(socket, gethostbyname)
456         if test "$ac_cv_lib_socket_gethostbyname" != yes; then
457                 AC_CHECK_LIB(nsl, gethostbyname)
458                 if test "$ac_cv_lib_nsl_gethostbyname" != yes; then
459                         cf_have_socket=no
460                 fi
461         fi
463 if test "$cf_have_socket" = yes && test "$ac_cv_header_sys_socket_h" = yes && test "$ac_cv_header_netinet_in_h" = yes && test "$ac_cv_header_netdb_h" = yes; then
464         AC_DEFINE(HAVE_NETWORK, 1, Have networking)
466 AC_CHECK_FUNCS(gethostbyaddr getaddrinfo getnameinfo hstrerror h_errno)
468 AC_CACHE_CHECK(for struct timespec, ac_cv_have_struct_timespec,
469 AC_TRY_COMPILE([
470         #include <time.h>
471 ] , [
472         struct timespec ts;
473         ts.tv_sec = 0;
474         ts.tv_nsec = 0;
475         ts = ts;
476         return 0;
477 ], ac_cv_have_struct_timespec=yes, ac_cv_have_struct_timespec=no))
478 test "$ac_cv_have_struct_timespec" = yes && AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, Have struct timespec)
480 AC_CACHE_CHECK(if struct stat has st_atim, ac_cv_have_struct_stat_st_atim,
481 AC_TRY_COMPILE([
482         #include <sys/stat.h>
483 ] , [
484         volatile struct stat st;
485         volatile struct timespec a = st.st_atim;
486         return 0;
487 ], ac_cv_have_struct_stat_st_atim=yes, ac_cv_have_struct_stat_st_atim=no))
488 test "$ac_cv_have_struct_stat_st_atim" = yes && AC_DEFINE(HAVE_STRUCT_STAT_ST_ATIM, 1, Struct stat has st_atim)
490 AC_CACHE_CHECK(if struct stat has st_atimespec, ac_cv_have_struct_stat_st_atimespec,
491 AC_TRY_COMPILE([
492         #include <sys/stat.h>
493 ] , [
494         volatile struct stat st;
495         volatile struct timespec a = st.st_atimespec;
496         return 0;
497 ], ac_cv_have_struct_stat_st_atimespec=yes, ac_cv_have_struct_stat_st_atimespec=no))
498 test "$ac_cv_have_struct_stat_st_atimespec" = yes && AC_DEFINE(HAVE_STRUCT_STAT_ST_ATIMESPEC, 1, Struct stat has st_atimespec)
501 if test "$ac_cv_func_clock_gettime" = no -a "$ax_pthread_ok" = yes -a "$ac_cv_func_pthread_condattr_setclock" = yes; then
502         AC_CHECK_LIB(rt, clock_gettime)
503         if test "$ac_cv_lib_rt_clock_gettime" = yes; then
504                 AC_DEFINE(HAVE_CLOCK_GETTIME)
505         fi
508 AC_CACHE_CHECK(for struct sigevent, ac_cv_have_struct_sigevent,
509 AC_TRY_COMPILE([
510         #include <time.h>
511         #include <signal.h>
512 ] , [
513         timer_t timer_id;
514         struct sigevent sev;
515         timer_create(CLOCK_MONOTONIC, &sev, &timer_id);
516         return 0;
517 ], ac_cv_have_struct_sigevent=yes, ac_cv_have_struct_sigevent=no))
518 test "$ac_cv_have_struct_sigevent" = yes && AC_DEFINE(HAVE_STRUCT_SIGEVENT, 1, Have struct sigevent)
520 if test "$ac_cv_have_struct_sigevent" = yes -a "$ac_cv_func_timer_create" = no; then
521         AC_CHECK_LIB(rt, timer_create)
522         if test "$ac_cv_lib_rt_timer_create" = yes; then
523                 AC_DEFINE(HAVE_TIMER_CREATE)
524         fi
528 AC_CACHE_CHECK(for CLOCK_MONOTONIC, ac_cv_have_clock_monotonic,
529 AC_TRY_LINK([
530         #include <time.h>
531 ] , [
532         clockid_t id = CLOCK_MONOTONIC;
533         return 0;
534 ], ac_cv_have_clock_monotonic=yes, ac_cv_have_clock_monotonic=no))
535 test "$ac_cv_have_clock_monotonic" = yes && AC_DEFINE(HAVE_CLOCK_MONOTONIC, 1, Have CLOCK_MONOTONIC)
537 AC_CACHE_CHECK(for CLOCK_MONOTONIC_RAW, ac_cv_have_clock_monotonic_raw,
538 AC_TRY_LINK([
539         #include <time.h>
540 ] , [
541         clockid_t id = CLOCK_MONOTONIC_RAW;
542         return 0;
543 ], ac_cv_have_clock_monotonic_raw=yes, ac_cv_have_clock_monotonic_raw=no))
544 test "$ac_cv_have_clock_monotonic_raw" = yes && AC_DEFINE(HAVE_CLOCK_MONOTONIC_RAW, 1, Have CLOCK_MONOTONIC_RAW)
547 AC_CACHE_CHECK(for intX_t and u_intX_t, ac_cv_have_intx_t_u_intx_t,
548 AC_TRY_COMPILE([
549         #include <sys/types.h>
550 ] , [
551         int8_t a = 0x7f;
552         u_int8_t b = 0x7f;
553         int16_t c = 0x7f;
554         u_int16_t d = 0x7f;
555         int32_t e = 0x7f;
556         u_int32_t f = 0x7f;
557         return (int)(a + b + c + d + e + f);
558 ], ac_cv_have_intx_t_u_intx_t=yes, ac_cv_have_intx_t_u_intx_t=no))
559 test "$ac_cv_have_intx_t_u_intx_t" = yes && AC_DEFINE(HAVE_INT_T_U_INT_T, 1, Have intX_t and u_intX_t)
561 AC_CACHE_CHECK(for int64_t and u_int64_t, ac_cv_have_int64_t_u_int64_t,
562 AC_TRY_COMPILE([
563         #include <sys/types.h>
564 ] , [
565         int64_t a = 0x12345678;
566         u_int64_t b = 0x9abcdef0;
567         return (int)(a + b);
568 ], ac_cv_have_int64_t_u_int64_t=yes, ac_cv_have_int64_t_u_int64_t=no))
569 test "$ac_cv_have_int64_t_u_int64_t" = yes && AC_DEFINE(HAVE_INT64_T_U_INT64_T, 1, Have int64_t and u_int64_t)
571 AC_CACHE_CHECK(for int64_t and uint64_t, ac_cv_have_int64_t_uint64_t,
572 AC_TRY_COMPILE([
573         #include <stdint.h>
574 ] , [
575         int64_t a = 0x12345678;
576         uint64_t b = 0x9abcdef0;
577         return (int)(a + b);
578 ], ac_cv_have_int64_t_uint64_t=yes, ac_cv_have_int64_t_uint64_t=no))
579 test "$ac_cv_have_int64_t_uint64_t" = yes && AC_DEFINE(HAVE_INT64_T_UINT64_T, 1, Have int64_t and uint64_t)
581 AC_CACHE_CHECK([for big endian], ac_cv_big_endian,
582         AC_TRY_RUN([
583         long l;
584         char *c = (char *)&l;
585         int main(void)
586         {
587                 l = 0x12345678L;
588                 return !(c[[sizeof(long) - 1]] == 0x78 && c[[sizeof(long) - 2]] == 0x56 && c[[sizeof(long) - 3]] == 0x34 && c[[sizeof(long) - 4]] == 0x12);
589         }
590         ], ac_cv_big_endian=yes, ac_cv_big_endian=no, ac_cv_big_endian=unknown)
592 AC_CACHE_CHECK([for little endian], ac_cv_little_endian,
593         AC_TRY_RUN([
594         long l;
595         char *c = (char *)&l;
596         int main(void)
597         {
598                 l = 0x12345678L;
599                 return !(c[[0]] == 0x78 && c[[1]] == 0x56 && c[[2]] == 0x34 && c[[3]] == 0x12);
600         }
601         ], ac_cv_little_endian=yes, ac_cv_little_endian=no, ac_cv_little_endian=unknown)
604 if test "$ac_cv_big_endian" = yes -a "$ac_cv_little_endian" = yes; then
605         AC_ERROR([The endianity test is broken])
606 elif test "$ac_cv_big_endian" = yes; then
607         AC_DEFINE(CONFIG_BIG_ENDIAN, 1, Define if the system is big endian)
608 elif test "$ac_cv_little_endian" = yes; then
609         AC_DEFINE(CONFIG_LITTLE_ENDIAN, 1, Define if the system is little endian)
612 AC_CACHE_CHECK([if rwx mappings work], ac_cv_rwx_mmap,
613         AC_TRY_RUN([
614 #include <unistd.h>
615 #include <sys/mman.h>
616         int main(void)
617         {
618                 return mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) == MAP_FAILED;
619         }
620         ], ac_cv_rwx_mmap=yes, ac_cv_rwx_mmap=no, ac_cv_rwx_mmap=no))
621 test "$ac_cv_func_mmap" = yes && test "$ac_cv_rwx_mmap" = no && AC_DEFINE(DISABLE_RWX_MAPPINGS, 1, Disable rwx mappings)
623 AC_CACHE_CHECK([for pointer tags], ac_cv_pointer_tags,
624         AC_TRY_RUN([
625         int main(void)
626         {
627                 volatile unsigned val = 0x12345678U;
628                 volatile unsigned * volatile ptr, * volatile tagged_ptr;
629                 unsigned long want_tag = 0;
630 #if defined(__aarch64__) && !defined(__ILP32__)
631                 want_tag = 0xFF00000000000000UL;
632 #endif
633 #if defined(__s390__) && !defined(__LP64__)
634                 want_tag = 0x80000000UL;
635 #endif
636                 if (!want_tag)
637                         return 1;
638                 ptr = &val;
639                 if ((unsigned long)ptr & want_tag)
640                         return 1;
641                 tagged_ptr = (unsigned *)((unsigned long)ptr | want_tag);
642                 return *tagged_ptr == 0x12345678U ? 0 : 1;
643         }
644         ], ac_cv_pointer_tags=yes, ac_cv_pointer_tags=no, ac_cv_pointer_tags=unknown)
646 test "$ac_cv_pointer_tags" = yes && AC_DEFINE(HAVE_POINTER_TAGS, 1, Have pointer tags)
648 AC_CACHE_CHECK(for __sync_add_and_fetch __sync_sub_and_fetch __sync_bool_compare_and_swap __sync_synchronize, ac_cv_have_sync_and_fetch,
649 AC_TRY_LINK(, [
650         unsigned long val = 0;
651         __sync_synchronize();
652         __sync_add_and_fetch(&val, 1);
653         __sync_bool_compare_and_swap(&val, 1, 2);
654         return __sync_sub_and_fetch(&val, 1);
655 ], ac_cv_have_sync_and_fetch=yes, ac_cv_have_sync_and_fetch=no))
656 test "$ac_cv_have_sync_and_fetch" = yes && AC_DEFINE(HAVE_SYNC_AND_FETCH, 1, Have __sync_add_and_fetch __sync_sub_and_fetch)
658 if test "$ac_cv_header_stdatomic_h" = yes; then
659         AC_CACHE_CHECK(for C11 atomics, ac_cv_have_c11_atomics,
660         AC_TRY_LINK([
661                 #include <stdint.h>
662                 #include <stdatomic.h>
663                 atomic_uintptr_t val;
664                 _Atomic uintptr_t val2;
665         ], [
666                 uintptr_t ld = atomic_load_explicit(&val, memory_order_relaxed);
667                 uintptr_t fld = atomic_fetch_add_explicit(&val, 4, memory_order_acq_rel);
668                 uintptr_t fld2 = atomic_fetch_sub_explicit(&val2, 8, memory_order_release);
669                 uintptr_t xch = atomic_exchange_explicit(&val2, 12, memory_order_acquire);
670                 atomic_thread_fence(memory_order_seq_cst);
671                 return (int)(ld + fld + fld2 + xch);
672         ], ac_cv_have_c11_atomics=yes, ac_cv_have_c11_atomics=no))
673         if test "$ac_cv_have_c11_atomics" = yes; then
674                 AC_DEFINE(HAVE_C11_ATOMICS, 1, Have C11 atomics)
675         else
676                 save_LIBS="$LIBS"
677                 LIBS="-latomic $LIBS"
678                 AC_CACHE_CHECK(for C11 atomics with -latomic, ac_cv_have_c11_atomics_latomic,
679                 AC_TRY_LINK([
680                         #include <stdint.h>
681                         #include <stdatomic.h>
682                         atomic_uintptr_t val;
683                 ], [
684                         uintptr_t ld = atomic_load_explicit(&val, memory_order_relaxed);
685                         uintptr_t fld = atomic_fetch_add_explicit(&val, 4, memory_order_acq_rel);
686                         uintptr_t fld2 = atomic_fetch_sub_explicit(&val, 8, memory_order_release);
687                         uintptr_t xch = atomic_exchange_explicit(&val, 12, memory_order_acquire);
688                         atomic_thread_fence(memory_order_seq_cst);
689                         return (int)(ld + fld + fld2 + xch);
690                 ], ac_cv_have_c11_atomics_latomic=yes, ac_cv_have_c11_atomics_latomic=no))
691                 if test "$ac_cv_have_c11_atomics_latomic" = yes; then
692                         AC_DEFINE(HAVE_C11_ATOMICS, 1, Have C11 atomics)
693                 else
694                         LIBS="$save_LIBS"
695                 fi
696         fi
699 AX_GCC_BUILTIN(__builtin_unreachable)
700 AX_GCC_BUILTIN(__builtin_bswap32)
701 AX_GCC_BUILTIN(__builtin_bswap64)
702 AX_GCC_BUILTIN(__builtin_assume_aligned)
703 AX_GCC_BUILTIN(__builtin___clear_cache)
705 AC_CACHE_CHECK(for __builtin_clz __builtin_clzl __builtin_clzll, ac_cv_have_builtin_clz,
706 AC_TRY_LINK([
707         volatile unsigned a = 0x12345678;
708         volatile unsigned long b = 0x567890ab;
709         volatile unsigned long long c = 0x9abcdef0;
710 ] , [
711         return __builtin_clz(a) + __builtin_clzl(b) + __builtin_clzll(c);
712 ], ac_cv_have_builtin_clz=yes, ac_cv_have_builtin_clz=no))
713 test "$ac_cv_have_builtin_clz" = yes && AC_DEFINE(HAVE_BUILTIN_CLZ, 1, Have __builtin_clz __builtin_clzl __builtin_clzll)
715 AC_CACHE_CHECK(for __builtin_ctz __builtin_ctzl __builtin_ctzll, ac_cv_have_builtin_ctz,
716 AC_TRY_LINK([
717         volatile unsigned a = 0x12345678;
718         volatile unsigned long b = 0x567890ab;
719         volatile unsigned long long c = 0x9abcdef0;
720 ] , [
721         return __builtin_ctz(a) + __builtin_ctzl(b) + __builtin_ctzll(c);
722 ], ac_cv_have_builtin_ctz=yes, ac_cv_have_builtin_ctz=no))
723 test "$ac_cv_have_builtin_ctz" = yes && AC_DEFINE(HAVE_BUILTIN_CTZ, 1, Have __builtin_ctz __builtin_ctzl __builtin_ctzll)
725 AC_CACHE_CHECK(for __builtin_popcount __builtin_popcountll, ac_cv_have_builtin_popcount,
726 AC_TRY_LINK([
727         volatile unsigned a = 0x12345678;
728         volatile unsigned long long b = 0x9abcdef0;
729 ] , [
730         return __builtin_popcount(a) + __builtin_popcountll(b);
731 ], ac_cv_have_builtin_popcount=yes, ac_cv_have_builtin_popcount=no))
732 test "$ac_cv_have_builtin_popcount" = yes && AC_DEFINE(HAVE_BUILTIN_POPCOUNT, 1, Have __builtin_popcount __builtin_popcountll)
735 if test "$ac_cv_sizeof_unsigned___int128" != 0; then
736         max_type=__int128
737 elif test "$ac_cv_c_long_long" = yes; then
738         max_type='long long'
739 else
740         max_type=long
743 AC_CACHE_CHECK(for __builtin_mul_overflow, ac_cv_have_builtin_mul_overflow,
744 AC_TRY_LINK([
745         volatile $max_type a = 0x12345678;
746         volatile $max_type b = 0x9abcdef;
747         volatile $max_type c;
748 ] , [
749         int o1 = __builtin_mul_overflow(a, b, &c);
750         return o1;
751 ], ac_cv_have_builtin_mul_overflow=yes, ac_cv_have_builtin_mul_overflow=no))
753 if test "$ac_cv_have_builtin_mul_overflow" = yes; then
754         AC_DEFINE(HAVE_BUILTIN_MUL_OVERFLOW, 1, Have __builtin_mul_overflow)
755 else
756         AC_CACHE_CHECK(for __builtin_mul_overflow with -rtlib=compiler-rt, ac_cv_have_builtin_mul_overflow_rtlib_compiler_rt,
757         save_LDFLAGS="$LDFLAGS"
758         LDFLAGS="-rtlib=compiler-rt $LDFLAGS"
759         AC_TRY_LINK([
760                 volatile $max_type a = 0x12345678;
761                 volatile $max_type b = 0x9abcdef;
762                 volatile $max_type c;
763         ] , [
764                 int o1 = __builtin_mul_overflow(a, b, &c);
765                 return o1;
766         ], ac_cv_have_builtin_mul_overflow_rtlib_compiler_rt=yes, ac_cv_have_builtin_mul_overflow_rtlib_compiler_rt=no)
767         LDFLAGS="$save_LDFLAGS"
768         )
770         if test "$ac_cv_have_builtin_mul_overflow_rtlib_compiler_rt" = yes; then
771                 use_compiler_rt=true
772                 if test "$ac_cv_have___float128" = yes; then
773                         AC_CHECK_LIB(gcc, __addtf3)
774                         if test "$ac_cv_lib_gcc___addtf3" != yes; then
775                                 use_compiler_rt=false
776                         fi
777                 fi
778                 if $use_compiler_rt; then
779                         LDFLAGS="-rtlib=compiler-rt $LDFLAGS"
780                         AC_DEFINE(HAVE_BUILTIN_MUL_OVERFLOW, 1, Have __builtin_mul_overflow)
781                 fi
782         fi
785 AC_CACHE_CHECK(for __builtin_add_overflow __builtin_sub_overflow, ac_cv_have_builtin_add_sub_overflow,
786 AC_TRY_LINK([
787         volatile $max_type a = 0x12345678;
788         volatile $max_type b = 0x9abcdef;
789         volatile $max_type c;
790 ] , [
791         int o1 = __builtin_add_overflow(a, b, &c);
792         int o2 = __builtin_sub_overflow(a, b, &c);
793         return o1 + o2;
794 ], ac_cv_have_builtin_add_sub_overflow=yes, ac_cv_have_builtin_add_sub_overflow=no))
795 test "$ac_cv_have_builtin_add_sub_overflow" = yes && AC_DEFINE(HAVE_BUILTIN_ADD_SUB_OVERFLOW, 1, Have __builtin_add_overflow __builtin_sub_overflow)
797 case ${host_cpu} in
798         alpha | sh*)
799                 AC_CACHE_CHECK(for -mieee, ac_cv_have_mieee,
800                 save_CFLAGS="$CFLAGS"
801                 CFLAGS="-mieee $CFLAGS"
802                 AC_TRY_LINK([ ], [ ], ac_cv_have_mieee=yes, ac_cv_have_mieee=no)
803                 CFLAGS="$save_CFLAGS"
804                 )
805                 test "$ac_cv_have_mieee" = yes && CFLAGS="-mieee $CFLAGS"
806                 ;;
807 esac
809 AC_CACHE_CHECK(if we can use union of float and uint32_t, ac_cv_union_float_uint32_t,
810 AC_TRY_RUN([
811 #include <stdint.h>
813         volatile union {
814                 float f;
815                 uint32_t i;
816         } u;
818         int main(void)
819         {
820                 u.f = -0.1640625;
821                 return !(u.i == 0xBE280000UL);
822         }
823 ], ac_cv_union_float_uint32_t=yes, ac_cv_union_float_uint32_t=no, ac_cv_union_float_uint32_t=unknown))
824 test "$ac_cv_union_float_uint32_t" = yes && AC_DEFINE(HAVE_UNION_FLOAT_UINT32_T, 1, Can use union of float and uint32_t)
826 dnl gcc-4.* on ARM has buggy infinity float to __fp16 conversion (it incorrectly returns NaN)
827 dnl clang-6 on ARM64 generates invalid instruction when storing fp16 zero
828 AC_CACHE_CHECK(for __fp16, ac_cv_have___fp16,
829 AC_TRY_RUN([
830 #include <math.h>
832         volatile float a = HUGE_VAL;
833         volatile __fp16 b;
835         static __fp16 store0(__fp16 *fp, __fp16 arg)
836         {
837                 *fp = 0;
838                 return arg;
839         }
841         __fp16 (*volatile ptr_store0)(__fp16 *, __fp16) = store0;
843         int main(void)
844         {
845                 __fp16 f;
846                 ptr_store0(&f, 0);
847                 b = (__fp16)a;
848                 return !(f == 0 && b == HUGE_VAL);
849         }
850 ], ac_cv_have___fp16=yes, ac_cv_have___fp16=no, ac_cv_have___fp16=unknown))
851 cf_have_fp16="$ac_cv_have___fp16"
853 if test "$ac_cv_have___fp16" = no; then
854         save_CFLAGS="$CFLAGS"
855         CFLAGS="-mfp16-format=ieee $CFLAGS"
856         AC_CACHE_CHECK(for __fp16 with -mfp16-format=ieee, ac_cv_have___fp16_2,
857         AC_TRY_RUN([
858         #include <math.h>
860                 volatile float a = HUGE_VAL;
861                 volatile __fp16 b;
863                 static __fp16 store0(__fp16 *fp, __fp16 arg)
864                 {
865                         *fp = 0;
866                         return arg;
867                 }
869                 __fp16 (*volatile ptr_store0)(__fp16 *, __fp16) = store0;
871                 int main(void)
872                 {
873                         __fp16 f;
874                         ptr_store0(&f, 0);
875                         b = (__fp16)a;
876                         return !(f == 0 && b == HUGE_VAL);
877                 }
878         ], ac_cv_have___fp16_2=yes, ac_cv_have___fp16_2=no, ac_cv_have___fp16_2=unknown))
879         if test "$ac_cv_have___fp16_2" = yes; then
880                 cf_have_fp16=yes
881         else
882                 CFLAGS="$save_CFLAGS"
883         fi
886 if test "$cf_have_fp16" = yes; then
887         dnl libgcc-6 on ARM64 lacks the functions __extendhftf2 and __trunctfhf2
888         dnl clang-6 on X86 lacks the function __truncxfhf2
889         AC_CACHE_CHECK(if conversion between __fp16 and long double works, ac_cv_conversion___fp16_long_double,
890         AC_TRY_LINK([
891                 volatile __fp16 a = 1.2;
892                 volatile long double b;
893                 volatile __fp16 c;
894         ] , [
895                 b = (long double)a;
896                 c = (__fp16)b;
897                 return c;
898         ], ac_cv_conversion___fp16_long_double=yes, ac_cv_conversion___fp16_long_double=no))
899         test "$ac_cv_conversion___fp16_long_double" = no && cf_have_fp16=no
901         dnl libgcc-6 on ARM64 lacks the function __floatundihf
902         AC_CACHE_CHECK(if conversion from unsigned long to __fp16 works, ac_cv_conversion_unsigned_long___fp16,
903         AC_TRY_LINK([
904                 volatile unsigned long a = 10;
905                 volatile __fp16 b = 1.2;
906         ] , [
907                 b = (__fp16)a;
908                 return b;
909         ], ac_cv_conversion_unsigned_long___fp16=yes, ac_cv_conversion_unsigned_long___fp16=no))
910         test "$ac_cv_conversion_unsigned_long___fp16" = no && cf_have_fp16=no
912         if test "$ac_cv_sizeof_unsigned___int128" != 0; then
913                 dnl libgcc-6 on ARM64 lacks the functions __fixhfti and __fixunshfti
914                 AC_CACHE_CHECK(if conversion from __fp16 to __int128 works, ac_cv_conversion___fp16___int128,
915                 AC_TRY_LINK([
916                         volatile __fp16 a = 1.2;
917                         volatile __int128 b;
918                         volatile unsigned __int128 c;
919                 ] , [
920                         b = (__int128)a;
921                         c = (unsigned __int128)a;
922                         return b + c;
923                 ], ac_cv_conversion___fp16___int128=yes, ac_cv_conversion___fp16___int128=no))
924                 test "$ac_cv_conversion___fp16___int128" = no && cf_have_fp16=no
926                 dnl libgcc-6 on ARM64 lacks the functions __floattihf and __floattihf
927                 AC_CACHE_CHECK(if conversion from __int128 to __fp16 works, ac_cv_conversion___int128___fp16,
928                 AC_TRY_LINK([
929                         volatile __int128 a = 12;
930                         volatile unsigned __int128 b = 34;
931                         __fp16 c, d;
932                 ] , [
933                         c = (__fp16)a;
934                         d = (__fp16)a;
935                         return c + d;
936                 ], ac_cv_conversion___int128___fp16=yes, ac_cv_conversion___int128___fp16=no))
937                 test "$ac_cv_conversion___int128___fp16" = no && cf_have_fp16=no
938         fi
940 test "$cf_have_fp16" = yes && AC_DEFINE(HAVE___FP16, 1, Have __fp16)
942 AC_CACHE_CHECK(if sqrt sets errno, ac_cv_have_sqrt_errno,
943 AC_TRY_RUN([
944 #include <errno.h>
945 #include <math.h>
947         volatile double a = -1;
949         int main(void)
950         {
951                 errno = 0;
952                 a = sqrt(a);
953                 return !errno;
954         }
955 ], ac_cv_have_sqrt_errno=yes, ac_cv_have_sqrt_errno=no, ac_cv_have_sqrt_errno=unknown))
957 if test "$ac_cv_have_sqrt_errno" = yes; then
958         save_CFLAGS="$CFLAGS"
959         CFLAGS="-fno-math-errno $CFLAGS"
960         AC_CACHE_CHECK(for -fno-math-errno, ac_cv_have__fno_math_errno,
961         AC_TRY_RUN([
962         #include <errno.h>
963         #include <math.h>
965                 volatile double a = -1;
967                 int main(void)
968                 {
969                         errno = 0;
970                         a = sqrt(a);
971                         return !!errno;
972                 }
973         ], ac_cv_have__fno_math_errno=yes, ac_cv_have__fno_math_errno=no, ac_cv_have__fno_math_errno=unknown))
974         if test "$ac_cv_have__fno_math_errno" != yes; then
975                 CFLAGS="$save_CFLAGS"
976         fi
979 AC_CACHE_CHECK(if fmod is buggy, ac_cv_have_buggy_fmod,
980 AC_TRY_RUN([
981 #include <math.h>
982 volatile double a = 0.;
983 volatile double b = 0.;
984 int main(void)
986         return fmod(a, b) == 0;
988 ], ac_cv_have_buggy_fmod=no, ac_cv_have_buggy_fmod=yes, ac_cv_have_buggy_fmod=yes))
989 test "$ac_cv_have_buggy_fmod" = yes && AC_DEFINE(HAVE_BUGGY_FMOD, 1, Have buggy fmod)
991 AC_CACHE_CHECK(if modf is buggy, ac_cv_have_buggy_modf,
992 AC_TRY_RUN([
993 #include <math.h>
994 volatile double a = 1.;
995 volatile double b = 0.;
996 int main(void)
998         double d;
999         return !(modf(a / b, &d) == 0);
1001 ], ac_cv_have_buggy_modf=no, ac_cv_have_buggy_modf=yes, ac_cv_have_buggy_modf=yes))
1002 test "$ac_cv_have_buggy_modf" = yes && AC_DEFINE(HAVE_BUGGY_MODF, 1, Have buggy modf)
1005 AC_CONFIG_FILES(Makefile)
1006 AC_OUTPUT
1008 if test "$ac_cv_lib_ffi_ffi_prep_cif" != yes; then
1009         AC_MSG_WARN([libffi is not present, ffi functionality will be disabled])
1011 if test "$ac_cv_lib_gmp___gmpz_init2" != yes; then
1012         AC_MSG_WARN([libgmp is not present, slow built-in emulation will be used])