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