Blame m4/isnand.m4

Packit Service a2489d
# isnand.m4 serial 11
Packit Service a2489d
dnl Copyright (C) 2007-2018 Free Software Foundation, Inc.
Packit Service a2489d
dnl This file is free software; the Free Software Foundation
Packit Service a2489d
dnl gives unlimited permission to copy and/or distribute it,
Packit Service a2489d
dnl with or without modifications, as long as this notice is preserved.
Packit Service a2489d
Packit Service a2489d
dnl Check how to get or define isnand().
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_FUNC_ISNAND],
Packit Service a2489d
[
Packit Service a2489d
  AC_REQUIRE([gl_MATH_H_DEFAULTS])
Packit Service a2489d
  ISNAND_LIBM=
Packit Service a2489d
  gl_HAVE_ISNAND_NO_LIBM
Packit Service a2489d
  if test $gl_cv_func_isnand_no_libm = no; then
Packit Service a2489d
    gl_HAVE_ISNAND_IN_LIBM
Packit Service a2489d
    if test $gl_cv_func_isnand_in_libm = yes; then
Packit Service a2489d
      ISNAND_LIBM=-lm
Packit Service a2489d
    fi
Packit Service a2489d
  fi
Packit Service a2489d
  dnl The variable gl_func_isnand set here is used by isnan.m4.
Packit Service a2489d
  if test $gl_cv_func_isnand_no_libm = yes \
Packit Service a2489d
     || test $gl_cv_func_isnand_in_libm = yes; then
Packit Service a2489d
    gl_func_isnand=yes
Packit Service a2489d
  else
Packit Service a2489d
    gl_func_isnand=no
Packit Service a2489d
    HAVE_ISNAND=0
Packit Service a2489d
  fi
Packit Service a2489d
  AC_SUBST([ISNAND_LIBM])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
dnl Check how to get or define isnand() without linking with libm.
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_FUNC_ISNAND_NO_LIBM],
Packit Service a2489d
[
Packit Service a2489d
  gl_HAVE_ISNAND_NO_LIBM
Packit Service a2489d
  gl_func_isnand_no_libm=$gl_cv_func_isnand_no_libm
Packit Service a2489d
  if test $gl_cv_func_isnand_no_libm = yes; then
Packit Service a2489d
    AC_DEFINE([HAVE_ISNAND_IN_LIBC], [1],
Packit Service a2489d
      [Define if the isnan(double) function is available in libc.])
Packit Service a2489d
  fi
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
dnl Prerequisites of replacement isnand definition. It does not need -lm.
Packit Service a2489d
AC_DEFUN([gl_PREREQ_ISNAND],
Packit Service a2489d
[
Packit Service a2489d
  AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
dnl Test whether isnand() can be used with libm.
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_HAVE_ISNAND_IN_LIBM],
Packit Service a2489d
[
Packit Service a2489d
  AC_CACHE_CHECK([whether isnan(double) can be used with libm],
Packit Service a2489d
    [gl_cv_func_isnand_in_libm],
Packit Service a2489d
    [
Packit Service a2489d
      save_LIBS="$LIBS"
Packit Service a2489d
      LIBS="$LIBS -lm"
Packit Service a2489d
      AC_LINK_IFELSE(
Packit Service a2489d
        [AC_LANG_PROGRAM(
Packit Service a2489d
           [[#include <math.h>
Packit Service a2489d
             #if __GNUC__ >= 4
Packit Service a2489d
             # undef isnand
Packit Service a2489d
             # define isnand(x) __builtin_isnan ((double)(x))
Packit Service a2489d
             #elif defined isnan
Packit Service a2489d
             # undef isnand
Packit Service a2489d
             # define isnand(x) isnan ((double)(x))
Packit Service a2489d
             #endif
Packit Service a2489d
             double x;]],
Packit Service a2489d
           [[return isnand (x);]])],
Packit Service a2489d
        [gl_cv_func_isnand_in_libm=yes],
Packit Service a2489d
        [gl_cv_func_isnand_in_libm=no])
Packit Service a2489d
      LIBS="$save_LIBS"
Packit Service a2489d
    ])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_HAVE_ISNAND_NO_LIBM],
Packit Service a2489d
[
Packit Service a2489d
  AC_CACHE_CHECK([whether isnan(double) can be used without linking with libm],
Packit Service a2489d
    [gl_cv_func_isnand_no_libm],
Packit Service a2489d
    [
Packit Service a2489d
      AC_LINK_IFELSE(
Packit Service a2489d
        [AC_LANG_PROGRAM(
Packit Service a2489d
           [[#include <math.h>
Packit Service a2489d
             #if __GNUC__ >= 4
Packit Service a2489d
             # undef isnand
Packit Service a2489d
             # define isnand(x) __builtin_isnan ((double)(x))
Packit Service a2489d
             #else
Packit Service a2489d
             # undef isnand
Packit Service a2489d
             # define isnand(x) isnan ((double)(x))
Packit Service a2489d
             #endif
Packit Service a2489d
             double x;]],
Packit Service a2489d
           [[return isnand (x);]])],
Packit Service a2489d
        [gl_cv_func_isnand_no_libm=yes],
Packit Service a2489d
        [gl_cv_func_isnand_no_libm=no])
Packit Service a2489d
    ])
Packit Service a2489d
])