| 1 |
# isnand.m4 |
| 2 |
# serial 15 |
| 3 |
dnl Copyright (C) 2007-2026 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
dnl Check how to get or define isnand(). |
| 10 |
|
| 11 |
AC_DEFUN_ONCE([gl_FUNC_ISNAND], |
| 12 |
[ |
| 13 |
AC_REQUIRE([gl_MATH_H_DEFAULTS]) |
| 14 |
ISNAND_LIBM= |
| 15 |
gl_HAVE_ISNAND_NO_LIBM |
| 16 |
if test $gl_cv_func_isnand_no_libm = no; then |
| 17 |
gl_HAVE_ISNAND_IN_LIBM |
| 18 |
if test $gl_cv_func_isnand_in_libm = yes; then |
| 19 |
ISNAND_LIBM=-lm |
| 20 |
fi |
| 21 |
fi |
| 22 |
dnl The variable gl_func_isnand set here is used by isnan.m4. |
| 23 |
if test $gl_cv_func_isnand_no_libm = yes || test -n "$ISNAND_LIBM"; then |
| 24 |
gl_func_isnand=yes |
| 25 |
else |
| 26 |
gl_func_isnand=no |
| 27 |
HAVE_ISNAND=0 |
| 28 |
fi |
| 29 |
AC_SUBST([ISNAND_LIBM]) |
| 30 |
]) |
| 31 |
|
| 32 |
dnl Check how to get or define isnand() without linking with libm. |
| 33 |
|
| 34 |
AC_DEFUN([gl_FUNC_ISNAND_NO_LIBM], |
| 35 |
[ |
| 36 |
gl_HAVE_ISNAND_NO_LIBM |
| 37 |
gl_func_isnand_no_libm=$gl_cv_func_isnand_no_libm |
| 38 |
if test $gl_cv_func_isnand_no_libm = yes; then |
| 39 |
AC_DEFINE([HAVE_ISNAND_IN_LIBC], [1], |
| 40 |
[Define if the isnan(double) function is available in libc.]) |
| 41 |
fi |
| 42 |
]) |
| 43 |
|
| 44 |
dnl Prerequisites of replacement isnand definition. It does not need -lm. |
| 45 |
AC_DEFUN([gl_PREREQ_ISNAND], |
| 46 |
[ |
| 47 |
AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION]) |
| 48 |
]) |
| 49 |
|
| 50 |
dnl Test whether isnand() can be used with libm. |
| 51 |
|
| 52 |
AC_DEFUN([gl_HAVE_ISNAND_IN_LIBM], |
| 53 |
[ |
| 54 |
AC_CACHE_CHECK([whether isnan(double) can be used with libm], |
| 55 |
[gl_cv_func_isnand_in_libm], |
| 56 |
[ |
| 57 |
saved_LIBS="$LIBS" |
| 58 |
LIBS="$LIBS -lm" |
| 59 |
AC_LINK_IFELSE( |
| 60 |
[AC_LANG_PROGRAM( |
| 61 |
[[#include <math.h> |
| 62 |
#if (__GNUC__ >= 4) || (__clang_major__ >= 4) |
| 63 |
# undef isnand |
| 64 |
# define isnand(x) __builtin_isnan ((double)(x)) |
| 65 |
#elif defined isnan |
| 66 |
# undef isnand |
| 67 |
# define isnand(x) isnan ((double)(x)) |
| 68 |
#endif |
| 69 |
double x;]], |
| 70 |
[[return isnand (x);]])], |
| 71 |
[gl_cv_func_isnand_in_libm=yes], |
| 72 |
[gl_cv_func_isnand_in_libm=no]) |
| 73 |
LIBS="$saved_LIBS" |
| 74 |
]) |
| 75 |
]) |
| 76 |
|
| 77 |
AC_DEFUN([gl_HAVE_ISNAND_NO_LIBM], |
| 78 |
[ |
| 79 |
AC_CACHE_CHECK([whether isnan(double) can be used without linking with libm], |
| 80 |
[gl_cv_func_isnand_no_libm], |
| 81 |
[ |
| 82 |
AC_LINK_IFELSE( |
| 83 |
[AC_LANG_PROGRAM( |
| 84 |
[[#include <math.h> |
| 85 |
#if (__GNUC__ >= 4) || (__clang_major__ >= 4) |
| 86 |
# undef isnand |
| 87 |
# define isnand(x) __builtin_isnan ((double)(x)) |
| 88 |
#else |
| 89 |
# undef isnand |
| 90 |
# define isnand(x) isnan ((double)(x)) |
| 91 |
#endif |
| 92 |
double x;]], |
| 93 |
[[return isnand (x);]])], |
| 94 |
[gl_cv_func_isnand_no_libm=yes], |
| 95 |
[gl_cv_func_isnand_no_libm=no]) |
| 96 |
]) |
| 97 |
]) |