rework the verifier to prepare for loop cutting
[ajla.git] / configure.ac
blob12caa4b33e00e94f426a76515f98abef317a1255
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.2.0)
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
146 default_long_double=0
148 AC_CHECK_SIZEOF(unsigned short,"$default_short")
149 AC_CHECK_SIZEOF(unsigned, "$default_int")
150 AC_CHECK_SIZEOF(unsigned long, "$default_long")
151 AC_CHECK_SIZEOF(unsigned long long, "$default_long_long")
152 AC_CHECK_SIZEOF(unsigned __int128, "$default_unsigned__int128")
153 AC_CHECK_SIZEOF(void *, "$default_void")
154 AC_CHECK_SIZEOF(size_t, "$default_size_t")
155 AC_CHECK_SIZEOF(long double, "$default_long_double")
157 if test "$ax_pthread_ok" = yes; then
158         AC_CACHE_CHECK([for PTHREAD_MUTEX_ERRORCHECK],
159             ax_cv_PTHREAD_MUTEX_ERRORCHECK, [
160                 AC_LINK_IFELSE([
161                     AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_MUTEX_ERRORCHECK;]])],
162                     [ax_cv_PTHREAD_MUTEX_ERRORCHECK=yes],
163                     [ax_cv_PTHREAD_MUTEX_ERRORCHECK=no])
164             ])
165         AS_IF([test "x$ax_cv_PTHREAD_MUTEX_ERRORCHECK" = "xyes"],
166             AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK], 1, [Have PTHREAD_MUTEX_ERRORCHECK]))
169         AC_CACHE_CHECK([for PTHREAD_MUTEX_ERRORCHECK_NP],
170             ax_cv_PTHREAD_MUTEX_ERRORCHECK_NP, [
171                 AC_LINK_IFELSE([
172                     AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_MUTEX_ERRORCHECK_NP;]])],
173                     [ax_cv_PTHREAD_MUTEX_ERRORCHECK_NP=yes],
174                     [ax_cv_PTHREAD_MUTEX_ERRORCHECK_NP=no])
175             ])
176         AS_IF([test "x$ax_cv_PTHREAD_MUTEX_ERRORCHECK_NP" = "xyes"],
177             AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1, [Have PTHREAD_MUTEX_ERRORCHECK_NP]))
179         AC_CACHE_CHECK([if we can assign to pthread_key_t],
180             ax_cv_pthread_key_t_assign, [
181                 AC_COMPILE_IFELSE([
182                     AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_key_t key = (pthread_key_t)-1;]])],
183                     [ax_cv_pthread_key_t_assign=yes],
184                     [ax_cv_pthread_key_t_assign=no])
185             ])
186         AS_IF([test "x$ax_cv_pthread_key_t_assign" = "xyes"],
187             AC_DEFINE([HAVE_PTHREAD_KEY_T_ASSIGN], 1, [Can assign to pthread_key_t]))
191 AC_CACHE_CHECK(for __thread, ac_cv_have___thread,
192 AC_TRY_LINK([
193         __thread int i = 0;
194         static __thread int j = 0;
195 ], [
196         return i + j;
197 ], ac_cv_have___thread=yes, ac_cv_have___thread=no))
198 test "$ac_cv_have___thread" = yes && AC_DEFINE(HAVE___THREAD, __thread, Have thread local storage)
200 AC_CACHE_CHECK(for computed goto, ac_cv_have_computed_goto,
201 AC_TRY_LINK([
202 ], [
203         static const void *dispatch[[4096]] = {
204                 [[10]] = &&label_10,
205         };
206         goto *(void *)dispatch[[10]];
207 label_10:
208         return 0;
209 #if defined(__GNUC__) && __GNUC__ <= 2
210         kill me!
211 #endif
212 ], ac_cv_have_computed_goto=yes, ac_cv_have_computed_goto=no))
213 test "$ac_cv_have_computed_goto" = yes && test "$enable_computed_goto" != no && AC_DEFINE(HAVE_COMPUTED_GOTO, 1, Have computed goto)
215 if echo "$CC" | grep clang >/dev/null; then
216         AC_CACHE_CHECK(for -no-integrated-as, ac_cv_have_no_integrated_as,
217         save_CFLAGS="$CFLAGS"
218         CFLAGS="-no-integrated-as $CFLAGS"
219         AC_TRY_LINK([ ], [ ], ac_cv_have_no_integrated_as=yes, ac_cv_have_no_integrated_as=no)
220         CFLAGS="$save_CFLAGS"
221         )
222         test "$ac_cv_have_no_integrated_as" = yes && CFLAGS="-no-integrated-as $CFLAGS"
225 AC_CACHE_CHECK(for gcc assembler, ac_cv_have_gcc_assembler,
226 AC_TRY_LINK([
227 ], [
228         int src, dest;
229         src = 0;
230         __asm__ (""::"i"(63355));
231         __asm__ volatile ("":::"memory");
232         __asm__ (".if 0 \n .endif" : "=r"(dest) : "0"(src));
233 #ifdef __OPEN64__
234         kill me!
235 #endif
236         return dest;
237 ], ac_cv_have_gcc_assembler=yes, ac_cv_have_gcc_assembler=no))
238 test "$ac_cv_have_gcc_assembler" = yes && AC_DEFINE(HAVE_GCC_ASSEMBLER, 1, Have gcc assembler)
240 if test "$ac_cv_have_gcc_assembler" = yes; then
241         AC_CACHE_CHECK(for asm goto, ac_cv_have_asm_goto,
242         AC_TRY_LINK([
243         ], [
244                 __asm__ goto("" : : : : label);
245                 label:
246                 return 0;
247         ], ac_cv_have_asm_goto=yes, ac_cv_have_asm_goto=no))
248         test "$ac_cv_have_asm_goto" = yes && AC_DEFINE(HAVE_ASM_GOTO, 1, Have asm goto)
250         if test "$ac_cv_sizeof_unsigned___int128" != 0; then
251                 AC_CACHE_CHECK(for assembler __int128, ac_cv_have_assembler___int128,
252                 AC_TRY_COMPILE([
253                 ], [
254                         volatile __int128 a, b;
255                         a = 1;
256 #if defined(__aarch64__)
257                         __asm__ ("mov %H0, %H1; mov %x0, %x1" : "=&r"(b) : "r"(a));
258 #elif defined(__x86_64__)
259                         __asm__ ("" : "=A"(b) : "A"(a));
260 #else
261                         __asm__ ("" : "=r"(b) : "0"(a));
262 #endif
263                         return (int)b;
264                 ], ac_cv_have_assembler___int128=yes, ac_cv_have_assembler___int128=no))
265                 test "$ac_cv_have_assembler___int128" = yes && AC_DEFINE(HAVE_ASSEMBLER___INT128, 1, Have assembler __int128)
266         fi
268         AC_CACHE_CHECK(for X86 assembler popcnt, ac_cv_have_x86_assembler_popcnt,
269         AC_TRY_LINK([
270         ], [
271                 __asm__ volatile ("popcntw %%ax, %%bx \n popcntl %%eax, %%ebx":::"eax", "ebx", "cc");
272         ], ac_cv_have_x86_assembler_popcnt=yes, ac_cv_have_x86_assembler_popcnt=no))
273         test "$ac_cv_have_x86_assembler_popcnt" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_POPCNT, 1, Have X86 popcnt)
275         AC_CACHE_CHECK(for X86 assembler lzcnt, ac_cv_have_x86_assembler_lzcnt,
276         AC_TRY_LINK([
277         ], [
278                 __asm__ volatile ("lzcntw %%ax, %%bx \n lzcntl %%eax, %%ebx":::"eax", "ebx", "cc");
279         ], ac_cv_have_x86_assembler_lzcnt=yes, ac_cv_have_x86_assembler_lzcnt=no))
280         test "$ac_cv_have_x86_assembler_lzcnt" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_LZCNT, 1, Have X86 lzcnt)
282         AC_CACHE_CHECK(for X86 assembler sse, ac_cv_have_x86_assembler_sse,
283         AC_TRY_LINK([
284         ], [
285                 int i;
286                 float a = 0;
287                 __asm__ volatile ("cvtss2si (%1), %0":"=r"(i):"r"(&a));
288         ], ac_cv_have_x86_assembler_sse=yes, ac_cv_have_x86_assembler_sse=no))
289         test "$ac_cv_have_x86_assembler_sse" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_SSE, 1, Have X86 sse)
291         AC_CACHE_CHECK(for X86 assembler sse2, ac_cv_have_x86_assembler_sse2,
292         AC_TRY_LINK([
293         ], [
294                 int i;
295                 float a = 0;
296                 __asm__ volatile ("cvtsd2si (%1), %0":"=r"(i):"r"(&a));
297         ], ac_cv_have_x86_assembler_sse2=yes, ac_cv_have_x86_assembler_sse2=no))
298         test "$ac_cv_have_x86_assembler_sse2" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_SSE2, 1, Have X86 sse2)
300         AC_CACHE_CHECK(for X86 assembler avx, ac_cv_have_x86_assembler_avx,
301         AC_TRY_LINK([
302         ], [
303                 int i;
304                 float a = 0;
305                 __asm__ volatile ("vcvtss2si (%1), %0":"=r"(i):"r"(&a));
306         ], ac_cv_have_x86_assembler_avx=yes, ac_cv_have_x86_assembler_avx=no))
307         test "$ac_cv_have_x86_assembler_avx" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_AVX, 1, Have X86 avx)
309         AC_CACHE_CHECK(for X86 assembler f16c, ac_cv_have_x86_assembler_f16c,
310         AC_TRY_LINK([
311         ], [
312                 __asm__ volatile ("vcvtps2ph \$0, %%xmm0, %%xmm0":::"memory");
313         ], ac_cv_have_x86_assembler_f16c=yes, ac_cv_have_x86_assembler_f16c=no))
314         test "$ac_cv_have_x86_assembler_f16c" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_F16C, 1, Have X86 f16c)
316         AC_CACHE_CHECK(for X86 assembler fp16, ac_cv_have_x86_assembler_fp16,
317         AC_TRY_LINK([
318         ], [
319                 __asm__ volatile ("vmovsh (%%rax), %%xmm0":::"memory");
320         ], ac_cv_have_x86_assembler_fp16=yes, ac_cv_have_x86_assembler_fp16=no))
321         test "$ac_cv_have_x86_assembler_fp16" = yes && AC_DEFINE(HAVE_X86_ASSEMBLER_FP16, 1, Have X86 fp16)
323         AC_CACHE_CHECK(for ARM assembler, ac_cv_have_arm_assembler,
324         AC_TRY_LINK([
325         ], [
326                 __asm__ volatile (".cpu cortex-a15 \n .fpu neon-vfpv4 \n mov r1, r2":::"r1", "r2");
327         ], ac_cv_have_arm_assembler=yes, ac_cv_have_arm_assembler=no))
328         test "$ac_cv_have_arm_assembler" = yes && AC_DEFINE(HAVE_ARM_ASSEMBLER, 1, Have ARM assembler)
330         if test "$ac_cv_have_arm_assembler" = yes; then
331                 AC_CACHE_CHECK(for ARM assembler clz, ac_cv_have_arm_assembler_clz,
332                 AC_TRY_LINK([
333                 ], [
334                         __asm__ volatile (".cpu cortex-a15 \n .fpu neon-vfpv4 \n clz r1, r2":::"r1", "r2");
335                 ], ac_cv_have_arm_assembler_clz=yes, ac_cv_have_arm_assembler_clz=no))
336                 test "$ac_cv_have_arm_assembler_clz" = yes && AC_DEFINE(HAVE_ARM_ASSEMBLER_CLZ, 1, Have ARM clz)
338                 AC_CACHE_CHECK(for ARM assembler rbit, ac_cv_have_arm_assembler_rbit,
339                 AC_TRY_LINK([
340                 ], [
341                         __asm__ volatile (".cpu cortex-a15 \n .fpu neon-vfpv4 \n rbit r1, r2":::"r1", "r2");
342                 ], ac_cv_have_arm_assembler_rbit=yes, ac_cv_have_arm_assembler_rbit=no))
343                 test "$ac_cv_have_arm_assembler_rbit" = yes && AC_DEFINE(HAVE_ARM_ASSEMBLER_RBIT, 1, Have ARM rbit)
345                 AC_CACHE_CHECK(for ARM assembler sdiv udiv, ac_cv_have_arm_assembler_sdiv_udiv,
346                 AC_TRY_LINK([
347                 ], [
348                         __asm__ volatile (".cpu cortex-a15 \n .fpu neon-vfpv4 \n sdiv r1, r2, r3 \n udiv r1, r2, r3":::"r1", "r2", "r3");
349                 ], ac_cv_have_arm_assembler_sdiv_udiv=yes, ac_cv_have_arm_assembler_sdiv_udiv=no))
350                 test "$ac_cv_have_arm_assembler_sdiv_udiv" = yes && AC_DEFINE(HAVE_ARM_ASSEMBLER_SDIV_UDIV, 1, Have ARM sdiv udiv)
352                 AC_CACHE_CHECK(for ARM assembler half-precision, ac_cv_have_arm_assembler_half_precision,
353                 AC_TRY_LINK([
354                 ], [
355                         __asm__ volatile (".cpu cortex-a15 \n .fpu neon-vfpv4 \n vcvtb.f16.f32 s0, s0 \n vcvtb.f32.f16 s0, s0":::"s0");
356                 ], ac_cv_have_arm_assembler_half_precision=yes, ac_cv_have_arm_assembler_half_precision=no))
357                 test "$ac_cv_have_arm_assembler_half_precision" = yes && AC_DEFINE(HAVE_ARM_ASSEMBLER_HALF_PRECISION, 1, Have ARM half precision)
359                 AC_CACHE_CHECK(for ARM assembler vfp, ac_cv_have_arm_assembler_vfp,
360                 AC_TRY_LINK([
361                 ], [
362                         __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");
363                 ], ac_cv_have_arm_assembler_vfp=yes, ac_cv_have_arm_assembler_vfp=no))
364                 test "$ac_cv_have_arm_assembler_vfp" = yes && AC_DEFINE(HAVE_ARM_ASSEMBLER_VFP, 1, Have ARM VFP)
365         fi
368 # Checks for header files.
369 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 x86/sysarch.h)
371 # Checks for libraries.
372 AC_CHECK_LIB(m, frexp)
373 if test "$ac_cv_have___float128" = yes && test "$ac_cv_header_quadmath_h" = yes; then
374         AC_CHECK_LIB(quadmath, frexpq)
376 AC_ARG_WITH(gmp, [  --without-gmp           use built-in gmp])
377 if test "$with_gmp" != "no"; then
378         if test "$ac_cv_header_gmp_h" = yes || test "$ac_cv_header_gmp_gmp_h" = yes; then
379                 AC_CHECK_LIB(gmp, __gmpz_init2)
380         fi
382 if test "$ac_cv_header_ffi_h" = yes; then
383         AC_CHECK_LIB(ffi, ffi_prep_cif)
384         AC_CHECK_FUNCS(ffi_prep_cif_var)
385         if test "$ac_cv_have_emx" = no -a "$ac_cv_have_win32" = no; then
386                 AC_CHECK_FUNCS(dlopen)
387                 if test "$ac_cv_have_dlopen" != yes; then
388                         AC_CHECK_LIB(dl, dlopen)
389                 fi
390         fi
393 AC_FUNC_MALLOC
395 AC_CHECK_LIB(xnet, getpeername)
397 # Checks for library functions.
398 AC_CHECK_FUNCS(accept4 aligned_alloc amd64_set_gsbase 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 sysarch syscall sysconf sysctl timegm timer_create truncate64 uname unlinkat utime utimensat utimes vsnprintf _beginthreadex _fmutex_create _threadstore)
400 AC_CHECK_FUNCS(
401         copysign copysignf                                              \
402         nextafter nextafterf nextafterl                                 \
403         fabsf fabsl fabsq                                               \
404         finite finitef finitel finiteq                                  \
405         isnan isnanf isnanl isnanq                                      \
406         lrintf                                                          \
407                                                                         \
408         sqrtf sqrtl sqrtq                                               \
409         cbrt cbrtf cbrtl                                                \
410                                                                         \
411         sinf sinl                                                       \
412         cosf cosl                                                       \
413         tanf tanl                                                       \
414         asinf asinl                                                     \
415         acosf acosl                                                     \
416         atanf atanl                                                     \
417                                                                         \
418         sinhf sinhl                                                     \
419         coshf coshl                                                     \
420         tanhf tanhl                                                     \
421         asinh asinhf asinhl                                             \
422         acosh acoshf acoshl                                             \
423         atanh atanhf atanhl                                             \
424                                                                         \
425         exp2 exp2f exp2l exp2q                                          \
426         expf expl                                                       \
427         exp10 exp10f exp10l exp10q                                      \
428         log2 log2f log2l                                                \
429         logf logl                                                       \
430         log10f log10l                                                   \
431                                                                         \
432         rint rintf rintl                                                \
433         ceilf ceill                                                     \
434         floorf floorl                                                   \
435         trunc truncf truncl                                             \
436         modff modfl                                                     \
437         frexpf frexpl frexpq                                            \
438                                                                         \
439         fmodf fmodl                                                     \
440         powf powl powq                                                  \
441         ldexpf ldexpl ldexpq                                            \
442         atan2f atan2l                                                   \
445 cf_have_socket=yes
446 if test "$ac_cv_func_socket" != yes; then
447         AC_CHECK_LIB(socket, socket)
448         if test "$ac_cv_lib_socket_socket" != yes; then
449                 AC_CHECK_LIB(watt, socket)
450                 if test "$ac_cv_lib_watt_socket" != yes; then
451                         AC_CHECK_LIB(wsock32, socket)
452                         if test "$ac_cv_lib_wsock32_socket" != yes; then
453                                 if echo "$CC" | grep -i mingw >/dev/null; then
454                                         LIBS="-lwsock32 $LIBS"
455                                 else
456                                         cf_have_socket=no
457                                 fi
458                         fi
459                 fi
460         fi
462 AC_CHECK_FUNCS(gethostbyname)
463 if test "$ac_cv_func_gethostbyname" != yes; then
464         AC_CHECK_LIB(socket, gethostbyname)
465         if test "$ac_cv_lib_socket_gethostbyname" != yes; then
466                 AC_CHECK_LIB(nsl, gethostbyname)
467                 if test "$ac_cv_lib_nsl_gethostbyname" != yes; then
468                         cf_have_socket=no
469                 fi
470         fi
472 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
473         AC_DEFINE(HAVE_NETWORK, 1, Have networking)
475 AC_CHECK_FUNCS(gethostbyaddr getaddrinfo getnameinfo hstrerror h_errno)
477 AC_CACHE_CHECK(for struct timespec, ac_cv_have_struct_timespec,
478 AC_TRY_COMPILE([
479         #include <time.h>
480 ] , [
481         struct timespec ts;
482         ts.tv_sec = 0;
483         ts.tv_nsec = 0;
484         ts = ts;
485         return 0;
486 ], ac_cv_have_struct_timespec=yes, ac_cv_have_struct_timespec=no))
487 test "$ac_cv_have_struct_timespec" = yes && AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, Have struct timespec)
489 AC_CACHE_CHECK(if struct stat has st_atim, ac_cv_have_struct_stat_st_atim,
490 AC_TRY_COMPILE([
491         #include <sys/stat.h>
492 ] , [
493         volatile struct stat st;
494         volatile struct timespec a = st.st_atim;
495         return 0;
496 ], ac_cv_have_struct_stat_st_atim=yes, ac_cv_have_struct_stat_st_atim=no))
497 test "$ac_cv_have_struct_stat_st_atim" = yes && AC_DEFINE(HAVE_STRUCT_STAT_ST_ATIM, 1, Struct stat has st_atim)
499 AC_CACHE_CHECK(if struct stat has st_atimespec, ac_cv_have_struct_stat_st_atimespec,
500 AC_TRY_COMPILE([
501         #include <sys/stat.h>
502 ] , [
503         volatile struct stat st;
504         volatile struct timespec a = st.st_atimespec;
505         return 0;
506 ], ac_cv_have_struct_stat_st_atimespec=yes, ac_cv_have_struct_stat_st_atimespec=no))
507 test "$ac_cv_have_struct_stat_st_atimespec" = yes && AC_DEFINE(HAVE_STRUCT_STAT_ST_ATIMESPEC, 1, Struct stat has st_atimespec)
510 if test "$ac_cv_func_clock_gettime" = no -a "$ax_pthread_ok" = yes -a "$ac_cv_func_pthread_condattr_setclock" = yes; then
511         AC_CHECK_LIB(rt, clock_gettime)
512         if test "$ac_cv_lib_rt_clock_gettime" = yes; then
513                 AC_DEFINE(HAVE_CLOCK_GETTIME)
514         fi
517 AC_CACHE_CHECK(for struct sigevent, ac_cv_have_struct_sigevent,
518 AC_TRY_COMPILE([
519         #include <time.h>
520         #include <signal.h>
521 ] , [
522         timer_t timer_id;
523         struct sigevent sev;
524         timer_create(CLOCK_MONOTONIC, &sev, &timer_id);
525         return 0;
526 ], ac_cv_have_struct_sigevent=yes, ac_cv_have_struct_sigevent=no))
527 test "$ac_cv_have_struct_sigevent" = yes && AC_DEFINE(HAVE_STRUCT_SIGEVENT, 1, Have struct sigevent)
529 if test "$ac_cv_have_struct_sigevent" = yes -a "$ac_cv_func_timer_create" = no; then
530         AC_CHECK_LIB(rt, timer_create)
531         if test "$ac_cv_lib_rt_timer_create" = yes; then
532                 AC_DEFINE(HAVE_TIMER_CREATE)
533         fi
537 AC_CACHE_CHECK(for CLOCK_MONOTONIC, ac_cv_have_clock_monotonic,
538 AC_TRY_LINK([
539         #include <time.h>
540 ] , [
541         clockid_t id = CLOCK_MONOTONIC;
542         return 0;
543 ], ac_cv_have_clock_monotonic=yes, ac_cv_have_clock_monotonic=no))
544 test "$ac_cv_have_clock_monotonic" = yes && AC_DEFINE(HAVE_CLOCK_MONOTONIC, 1, Have CLOCK_MONOTONIC)
546 AC_CACHE_CHECK(for CLOCK_MONOTONIC_RAW, ac_cv_have_clock_monotonic_raw,
547 AC_TRY_LINK([
548         #include <time.h>
549 ] , [
550         clockid_t id = CLOCK_MONOTONIC_RAW;
551         return 0;
552 ], ac_cv_have_clock_monotonic_raw=yes, ac_cv_have_clock_monotonic_raw=no))
553 test "$ac_cv_have_clock_monotonic_raw" = yes && AC_DEFINE(HAVE_CLOCK_MONOTONIC_RAW, 1, Have CLOCK_MONOTONIC_RAW)
556 AC_CACHE_CHECK(for intX_t and u_intX_t, ac_cv_have_intx_t_u_intx_t,
557 AC_TRY_COMPILE([
558         #include <sys/types.h>
559 ] , [
560         int8_t a = 0x7f;
561         u_int8_t b = 0x7f;
562         int16_t c = 0x7f;
563         u_int16_t d = 0x7f;
564         int32_t e = 0x7f;
565         u_int32_t f = 0x7f;
566         return (int)(a + b + c + d + e + f);
567 ], ac_cv_have_intx_t_u_intx_t=yes, ac_cv_have_intx_t_u_intx_t=no))
568 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)
570 AC_CACHE_CHECK(for int64_t and u_int64_t, ac_cv_have_int64_t_u_int64_t,
571 AC_TRY_COMPILE([
572         #include <sys/types.h>
573 ] , [
574         int64_t a = 0x12345678;
575         u_int64_t b = 0x9abcdef0;
576         return (int)(a + b);
577 ], ac_cv_have_int64_t_u_int64_t=yes, ac_cv_have_int64_t_u_int64_t=no))
578 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)
580 AC_CACHE_CHECK(for int64_t and uint64_t, ac_cv_have_int64_t_uint64_t,
581 AC_TRY_COMPILE([
582         #include <stdint.h>
583 ] , [
584         int64_t a = 0x12345678;
585         uint64_t b = 0x9abcdef0;
586         return (int)(a + b);
587 ], ac_cv_have_int64_t_uint64_t=yes, ac_cv_have_int64_t_uint64_t=no))
588 test "$ac_cv_have_int64_t_uint64_t" = yes && AC_DEFINE(HAVE_INT64_T_UINT64_T, 1, Have int64_t and uint64_t)
590 AC_CACHE_CHECK([for big endian], ac_cv_big_endian,
591         AC_TRY_RUN([
592         long l;
593         char *c = (char *)&l;
594         int main(void)
595         {
596                 l = 0x12345678L;
597                 return !(c[[sizeof(long) - 1]] == 0x78 && c[[sizeof(long) - 2]] == 0x56 && c[[sizeof(long) - 3]] == 0x34 && c[[sizeof(long) - 4]] == 0x12);
598         }
599         ], ac_cv_big_endian=yes, ac_cv_big_endian=no, ac_cv_big_endian=unknown)
601 AC_CACHE_CHECK([for little endian], ac_cv_little_endian,
602         AC_TRY_RUN([
603         long l;
604         char *c = (char *)&l;
605         int main(void)
606         {
607                 l = 0x12345678L;
608                 return !(c[[0]] == 0x78 && c[[1]] == 0x56 && c[[2]] == 0x34 && c[[3]] == 0x12);
609         }
610         ], ac_cv_little_endian=yes, ac_cv_little_endian=no, ac_cv_little_endian=unknown)
613 if test "$ac_cv_big_endian" = yes -a "$ac_cv_little_endian" = yes; then
614         AC_ERROR([The endianity test is broken])
615 elif test "$ac_cv_big_endian" = yes; then
616         AC_DEFINE(CONFIG_BIG_ENDIAN, 1, Define if the system is big endian)
617 elif test "$ac_cv_little_endian" = yes; then
618         AC_DEFINE(CONFIG_LITTLE_ENDIAN, 1, Define if the system is little endian)
621 AC_CACHE_CHECK([if rwx mappings work], ac_cv_rwx_mmap,
622         AC_TRY_RUN([
623 #include <unistd.h>
624 #include <sys/mman.h>
625         int main(void)
626         {
627                 return mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) == MAP_FAILED;
628         }
629         ], ac_cv_rwx_mmap=yes, ac_cv_rwx_mmap=no, ac_cv_rwx_mmap=no))
630 test "$ac_cv_func_mmap" = yes && test "$ac_cv_rwx_mmap" = no && AC_DEFINE(DISABLE_RWX_MAPPINGS, 1, Disable rwx mappings)
632 AC_CACHE_CHECK([for pointer tags], ac_cv_pointer_tags,
633         AC_TRY_RUN([
634         int main(void)
635         {
636                 volatile unsigned val = 0x12345678U;
637                 volatile unsigned * volatile ptr, * volatile tagged_ptr;
638                 unsigned long want_tag = 0;
639 #if defined(__aarch64__) && !defined(__ILP32__)
640                 want_tag = 0xFF00000000000000UL;
641 #endif
642 #if defined(__s390__) && !defined(__LP64__)
643                 want_tag = 0x80000000UL;
644 #endif
645                 if (!want_tag)
646                         return 1;
647                 ptr = &val;
648                 if ((unsigned long)ptr & want_tag)
649                         return 1;
650                 tagged_ptr = (unsigned *)((unsigned long)ptr | want_tag);
651                 return *tagged_ptr == 0x12345678U ? 0 : 1;
652         }
653         ], ac_cv_pointer_tags=yes, ac_cv_pointer_tags=no, ac_cv_pointer_tags=unknown)
655 test "$ac_cv_pointer_tags" = yes && AC_DEFINE(HAVE_POINTER_TAGS, 1, Have pointer tags)
657 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,
658 AC_TRY_LINK(, [
659         unsigned long val = 0;
660         __sync_synchronize();
661         __sync_add_and_fetch(&val, 1);
662         __sync_bool_compare_and_swap(&val, 1, 2);
663         return __sync_sub_and_fetch(&val, 1);
664 ], ac_cv_have_sync_and_fetch=yes, ac_cv_have_sync_and_fetch=no))
665 test "$ac_cv_have_sync_and_fetch" = yes && AC_DEFINE(HAVE_SYNC_AND_FETCH, 1, Have __sync_add_and_fetch __sync_sub_and_fetch)
667 if test "$ac_cv_header_stdatomic_h" = yes; then
668         AC_CACHE_CHECK(for C11 atomics, ac_cv_have_c11_atomics,
669         AC_TRY_LINK([
670                 #include <stdint.h>
671                 #include <stdatomic.h>
672                 atomic_uintptr_t val;
673                 _Atomic uintptr_t val2;
674         ], [
675                 uintptr_t ld = atomic_load_explicit(&val, memory_order_relaxed);
676                 uintptr_t fld = atomic_fetch_add_explicit(&val, 4, memory_order_acq_rel);
677                 uintptr_t fld2 = atomic_fetch_sub_explicit(&val2, 8, memory_order_release);
678                 uintptr_t xch = atomic_exchange_explicit(&val2, 12, memory_order_acquire);
679                 atomic_thread_fence(memory_order_seq_cst);
680                 return (int)(ld + fld + fld2 + xch);
681         ], ac_cv_have_c11_atomics=yes, ac_cv_have_c11_atomics=no))
682         if test "$ac_cv_have_c11_atomics" = yes; then
683                 AC_DEFINE(HAVE_C11_ATOMICS, 1, Have C11 atomics)
684         else
685                 save_LIBS="$LIBS"
686                 LIBS="-latomic $LIBS"
687                 AC_CACHE_CHECK(for C11 atomics with -latomic, ac_cv_have_c11_atomics_latomic,
688                 AC_TRY_LINK([
689                         #include <stdint.h>
690                         #include <stdatomic.h>
691                         atomic_uintptr_t val;
692                 ], [
693                         uintptr_t ld = atomic_load_explicit(&val, memory_order_relaxed);
694                         uintptr_t fld = atomic_fetch_add_explicit(&val, 4, memory_order_acq_rel);
695                         uintptr_t fld2 = atomic_fetch_sub_explicit(&val, 8, memory_order_release);
696                         uintptr_t xch = atomic_exchange_explicit(&val, 12, memory_order_acquire);
697                         atomic_thread_fence(memory_order_seq_cst);
698                         return (int)(ld + fld + fld2 + xch);
699                 ], ac_cv_have_c11_atomics_latomic=yes, ac_cv_have_c11_atomics_latomic=no))
700                 if test "$ac_cv_have_c11_atomics_latomic" = yes; then
701                         AC_DEFINE(HAVE_C11_ATOMICS, 1, Have C11 atomics)
702                 else
703                         LIBS="$save_LIBS"
704                 fi
705         fi
708 AX_GCC_BUILTIN(__builtin_unreachable)
709 AX_GCC_BUILTIN(__builtin_bswap32)
710 AX_GCC_BUILTIN(__builtin_bswap64)
711 AX_GCC_BUILTIN(__builtin_assume_aligned)
712 AX_GCC_BUILTIN(__builtin___clear_cache)
714 AC_CACHE_CHECK(for __builtin_clz __builtin_clzl __builtin_clzll, ac_cv_have_builtin_clz,
715 AC_TRY_LINK([
716         volatile unsigned a = 0x12345678;
717         volatile unsigned long b = 0x567890ab;
718         volatile unsigned long long c = 0x9abcdef0;
719 ] , [
720         return __builtin_clz(a) + __builtin_clzl(b) + __builtin_clzll(c);
721 ], ac_cv_have_builtin_clz=yes, ac_cv_have_builtin_clz=no))
722 test "$ac_cv_have_builtin_clz" = yes && AC_DEFINE(HAVE_BUILTIN_CLZ, 1, Have __builtin_clz __builtin_clzl __builtin_clzll)
724 AC_CACHE_CHECK(for __builtin_ctz __builtin_ctzl __builtin_ctzll, ac_cv_have_builtin_ctz,
725 AC_TRY_LINK([
726         volatile unsigned a = 0x12345678;
727         volatile unsigned long b = 0x567890ab;
728         volatile unsigned long long c = 0x9abcdef0;
729 ] , [
730         return __builtin_ctz(a) + __builtin_ctzl(b) + __builtin_ctzll(c);
731 ], ac_cv_have_builtin_ctz=yes, ac_cv_have_builtin_ctz=no))
732 test "$ac_cv_have_builtin_ctz" = yes && AC_DEFINE(HAVE_BUILTIN_CTZ, 1, Have __builtin_ctz __builtin_ctzl __builtin_ctzll)
734 AC_CACHE_CHECK(for __builtin_popcount __builtin_popcountll, ac_cv_have_builtin_popcount,
735 AC_TRY_LINK([
736         volatile unsigned a = 0x12345678;
737         volatile unsigned long long b = 0x9abcdef0;
738 ] , [
739         return __builtin_popcount(a) + __builtin_popcountll(b);
740 ], ac_cv_have_builtin_popcount=yes, ac_cv_have_builtin_popcount=no))
741 test "$ac_cv_have_builtin_popcount" = yes && AC_DEFINE(HAVE_BUILTIN_POPCOUNT, 1, Have __builtin_popcount __builtin_popcountll)
744 if test "$ac_cv_sizeof_unsigned___int128" != 0; then
745         max_type=__int128
746 elif test "$ac_cv_c_long_long" = yes; then
747         max_type='long long'
748 else
749         max_type=long
752 AC_CACHE_CHECK(for __builtin_mul_overflow, ac_cv_have_builtin_mul_overflow,
753 AC_TRY_LINK([
754         volatile $max_type a = 0x12345678;
755         volatile $max_type b = 0x9abcdef;
756         volatile $max_type c;
757 ] , [
758         int o1 = __builtin_mul_overflow(a, b, &c);
759         return o1;
760 ], ac_cv_have_builtin_mul_overflow=yes, ac_cv_have_builtin_mul_overflow=no))
762 if test "$ac_cv_have_builtin_mul_overflow" = yes; then
763         AC_DEFINE(HAVE_BUILTIN_MUL_OVERFLOW, 1, Have __builtin_mul_overflow)
764 else
765         AC_CACHE_CHECK(for __builtin_mul_overflow with -rtlib=compiler-rt, ac_cv_have_builtin_mul_overflow_rtlib_compiler_rt,
766         save_LDFLAGS="$LDFLAGS"
767         LDFLAGS="-rtlib=compiler-rt $LDFLAGS"
768         AC_TRY_LINK([
769                 volatile $max_type a = 0x12345678;
770                 volatile $max_type b = 0x9abcdef;
771                 volatile $max_type c;
772         ] , [
773                 int o1 = __builtin_mul_overflow(a, b, &c);
774                 return o1;
775         ], ac_cv_have_builtin_mul_overflow_rtlib_compiler_rt=yes, ac_cv_have_builtin_mul_overflow_rtlib_compiler_rt=no)
776         LDFLAGS="$save_LDFLAGS"
777         )
779         if test "$ac_cv_have_builtin_mul_overflow_rtlib_compiler_rt" = yes; then
780                 use_compiler_rt=true
781                 if test "$ac_cv_have___float128" = yes; then
782                         AC_CHECK_LIB(gcc, __addtf3)
783                         if test "$ac_cv_lib_gcc___addtf3" != yes; then
784                                 use_compiler_rt=false
785                         fi
786                 fi
787                 if $use_compiler_rt; then
788                         LDFLAGS="-rtlib=compiler-rt $LDFLAGS"
789                         AC_DEFINE(HAVE_BUILTIN_MUL_OVERFLOW, 1, Have __builtin_mul_overflow)
790                 fi
791         fi
794 AC_CACHE_CHECK(for __builtin_add_overflow __builtin_sub_overflow, ac_cv_have_builtin_add_sub_overflow,
795 AC_TRY_LINK([
796         volatile $max_type a = 0x12345678;
797         volatile $max_type b = 0x9abcdef;
798         volatile $max_type c;
799 ] , [
800         int o1 = __builtin_add_overflow(a, b, &c);
801         int o2 = __builtin_sub_overflow(a, b, &c);
802         return o1 + o2;
803 ], ac_cv_have_builtin_add_sub_overflow=yes, ac_cv_have_builtin_add_sub_overflow=no))
804 test "$ac_cv_have_builtin_add_sub_overflow" = yes && AC_DEFINE(HAVE_BUILTIN_ADD_SUB_OVERFLOW, 1, Have __builtin_add_overflow __builtin_sub_overflow)
806 case ${host_cpu} in
807         alpha | sh*)
808                 AC_CACHE_CHECK(for -mieee, ac_cv_have_mieee,
809                 save_CFLAGS="$CFLAGS"
810                 CFLAGS="-mieee $CFLAGS"
811                 AC_TRY_LINK([ ], [ ], ac_cv_have_mieee=yes, ac_cv_have_mieee=no)
812                 CFLAGS="$save_CFLAGS"
813                 )
814                 test "$ac_cv_have_mieee" = yes && CFLAGS="-mieee $CFLAGS"
815                 ;;
816 esac
818 AC_CACHE_CHECK(if we can use union of float and uint32_t, ac_cv_union_float_uint32_t,
819 AC_TRY_RUN([
820 #include <stdint.h>
822         volatile union {
823                 float f;
824                 uint32_t i;
825         } u;
827         int main(void)
828         {
829                 u.f = -0.1640625;
830                 return !(u.i == 0xBE280000UL);
831         }
832 ], ac_cv_union_float_uint32_t=yes, ac_cv_union_float_uint32_t=no, ac_cv_union_float_uint32_t=unknown))
833 test "$ac_cv_union_float_uint32_t" = yes && AC_DEFINE(HAVE_UNION_FLOAT_UINT32_T, 1, Can use union of float and uint32_t)
835 dnl gcc-4.* on ARM has buggy infinity float to __fp16 conversion (it incorrectly returns NaN)
836 dnl clang-6 on ARM64 generates invalid instruction when storing fp16 zero
837 AC_CACHE_CHECK(for __fp16, ac_cv_have___fp16,
838 AC_TRY_RUN([
839 #include <math.h>
841         volatile float a = HUGE_VAL;
842         volatile __fp16 b;
844         static __fp16 store0(__fp16 *fp, __fp16 arg)
845         {
846                 *fp = 0;
847                 return arg;
848         }
850         __fp16 (*volatile ptr_store0)(__fp16 *, __fp16) = store0;
852         int main(void)
853         {
854                 __fp16 f;
855                 ptr_store0(&f, 0);
856                 b = (__fp16)a;
857                 return !(f == 0 && b == HUGE_VAL);
858         }
859 ], ac_cv_have___fp16=yes, ac_cv_have___fp16=no, ac_cv_have___fp16=unknown))
860 cf_have_fp16="$ac_cv_have___fp16"
862 if test "$ac_cv_have___fp16" = no; then
863         save_CFLAGS="$CFLAGS"
864         CFLAGS="-mfp16-format=ieee $CFLAGS"
865         AC_CACHE_CHECK(for __fp16 with -mfp16-format=ieee, ac_cv_have___fp16_2,
866         AC_TRY_RUN([
867         #include <math.h>
869                 volatile float a = HUGE_VAL;
870                 volatile __fp16 b;
872                 static __fp16 store0(__fp16 *fp, __fp16 arg)
873                 {
874                         *fp = 0;
875                         return arg;
876                 }
878                 __fp16 (*volatile ptr_store0)(__fp16 *, __fp16) = store0;
880                 int main(void)
881                 {
882                         __fp16 f;
883                         ptr_store0(&f, 0);
884                         b = (__fp16)a;
885                         return !(f == 0 && b == HUGE_VAL);
886                 }
887         ], ac_cv_have___fp16_2=yes, ac_cv_have___fp16_2=no, ac_cv_have___fp16_2=unknown))
888         if test "$ac_cv_have___fp16_2" = yes; then
889                 cf_have_fp16=yes
890         else
891                 CFLAGS="$save_CFLAGS"
892         fi
895 if test "$cf_have_fp16" = yes; then
896         dnl libgcc-6 on ARM64 lacks the functions __extendhftf2 and __trunctfhf2
897         dnl clang-6 on X86 lacks the function __truncxfhf2
898         AC_CACHE_CHECK(if conversion between __fp16 and long double works, ac_cv_conversion___fp16_long_double,
899         AC_TRY_LINK([
900                 volatile __fp16 a = 1.2;
901                 volatile long double b;
902                 volatile __fp16 c;
903         ] , [
904                 b = (long double)a;
905                 c = (__fp16)b;
906                 return c;
907         ], ac_cv_conversion___fp16_long_double=yes, ac_cv_conversion___fp16_long_double=no))
908         test "$ac_cv_conversion___fp16_long_double" = no && cf_have_fp16=no
910         dnl libgcc-6 on ARM64 lacks the function __floatundihf
911         AC_CACHE_CHECK(if conversion from unsigned long to __fp16 works, ac_cv_conversion_unsigned_long___fp16,
912         AC_TRY_LINK([
913                 volatile unsigned long a = 10;
914                 volatile __fp16 b = 1.2;
915         ] , [
916                 b = (__fp16)a;
917                 return b;
918         ], ac_cv_conversion_unsigned_long___fp16=yes, ac_cv_conversion_unsigned_long___fp16=no))
919         test "$ac_cv_conversion_unsigned_long___fp16" = no && cf_have_fp16=no
921         if test "$ac_cv_sizeof_unsigned___int128" != 0; then
922                 dnl libgcc-6 on ARM64 lacks the functions __fixhfti and __fixunshfti
923                 AC_CACHE_CHECK(if conversion from __fp16 to __int128 works, ac_cv_conversion___fp16___int128,
924                 AC_TRY_LINK([
925                         volatile __fp16 a = 1.2;
926                         volatile __int128 b;
927                         volatile unsigned __int128 c;
928                 ] , [
929                         b = (__int128)a;
930                         c = (unsigned __int128)a;
931                         return b + c;
932                 ], ac_cv_conversion___fp16___int128=yes, ac_cv_conversion___fp16___int128=no))
933                 test "$ac_cv_conversion___fp16___int128" = no && cf_have_fp16=no
935                 dnl libgcc-6 on ARM64 lacks the functions __floattihf and __floattihf
936                 AC_CACHE_CHECK(if conversion from __int128 to __fp16 works, ac_cv_conversion___int128___fp16,
937                 AC_TRY_LINK([
938                         volatile __int128 a = 12;
939                         volatile unsigned __int128 b = 34;
940                         __fp16 c, d;
941                 ] , [
942                         c = (__fp16)a;
943                         d = (__fp16)a;
944                         return c + d;
945                 ], ac_cv_conversion___int128___fp16=yes, ac_cv_conversion___int128___fp16=no))
946                 test "$ac_cv_conversion___int128___fp16" = no && cf_have_fp16=no
947         fi
949 test "$cf_have_fp16" = yes && AC_DEFINE(HAVE___FP16, 1, Have __fp16)
951 AC_CACHE_CHECK(if sqrt sets errno, ac_cv_have_sqrt_errno,
952 AC_TRY_RUN([
953 #include <errno.h>
954 #include <math.h>
956         volatile double a = -1;
958         int main(void)
959         {
960                 errno = 0;
961                 a = sqrt(a);
962                 return !errno;
963         }
964 ], ac_cv_have_sqrt_errno=yes, ac_cv_have_sqrt_errno=no, ac_cv_have_sqrt_errno=unknown))
966 if test "$ac_cv_have_sqrt_errno" = yes; then
967         save_CFLAGS="$CFLAGS"
968         CFLAGS="-fno-math-errno $CFLAGS"
969         AC_CACHE_CHECK(for -fno-math-errno, ac_cv_have__fno_math_errno,
970         AC_TRY_RUN([
971         #include <errno.h>
972         #include <math.h>
974                 volatile double a = -1;
976                 int main(void)
977                 {
978                         errno = 0;
979                         a = sqrt(a);
980                         return !!errno;
981                 }
982         ], ac_cv_have__fno_math_errno=yes, ac_cv_have__fno_math_errno=no, ac_cv_have__fno_math_errno=unknown))
983         if test "$ac_cv_have__fno_math_errno" != yes; then
984                 CFLAGS="$save_CFLAGS"
985         fi
988 AC_CACHE_CHECK(if fmod is buggy, ac_cv_have_buggy_fmod,
989 AC_TRY_RUN([
990 #include <math.h>
991 volatile double a = 0.;
992 volatile double b = 0.;
993 int main(void)
995         return fmod(a, b) == 0;
997 ], ac_cv_have_buggy_fmod=no, ac_cv_have_buggy_fmod=yes, ac_cv_have_buggy_fmod=unknown))
998 test "$ac_cv_have_buggy_fmod" = yes && AC_DEFINE(HAVE_BUGGY_FMOD, 1, Have buggy fmod)
1000 AC_CACHE_CHECK(if modf is buggy, ac_cv_have_buggy_modf,
1001 AC_TRY_RUN([
1002 #include <math.h>
1003 volatile double a = 1.;
1004 volatile double b = 0.;
1005 int main(void)
1007         double d;
1008         return !(modf(a / b, &d) == 0);
1010 ], ac_cv_have_buggy_modf=no, ac_cv_have_buggy_modf=yes, ac_cv_have_buggy_modf=unknown))
1011 test "$ac_cv_have_buggy_modf" = yes && AC_DEFINE(HAVE_BUGGY_MODF, 1, Have buggy modf)
1013 AC_CACHE_CHECK(if ldexp is buggy, ac_cv_have_buggy_ldexp,
1014 AC_TRY_RUN([
1015 #include <math.h>
1016 int main(void)
1018         volatile double s = 1;
1019         volatile double lx = ldexp(s, 1024);
1020         volatile double ly = ldexp(lx, -1024);
1021         return lx != ly;
1023 ], ac_cv_have_buggy_ldexp=no, ac_cv_have_buggy_ldexp=yes, ac_cv_have_buggy_ldexp=unknown))
1024 test "$ac_cv_have_buggy_ldexp" = yes && AC_DEFINE(HAVE_BUGGY_LDEXP, 1, Have buggy ldexp)
1027 AC_CONFIG_FILES(Makefile)
1028 AC_OUTPUT
1030 if test "$ac_cv_lib_ffi_ffi_prep_cif" != yes; then
1031         AC_MSG_WARN([libffi is not present, ffi functionality will be disabled])
1033 if test "$ac_cv_lib_gmp___gmpz_init2" != yes; then
1034         AC_MSG_WARN([libgmp is not present, slow built-in emulation will be used])