]> git.gag.com Git - debian/gzip/blob - m4/isnand.m4
resolve merge noise in favor of new upstream. note that this tosses out the
[debian/gzip] / m4 / isnand.m4
1 # isnand.m4 serial 6
2 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl Check how to get or define isnand().
8
9 AC_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     gl_BUILD_ISNAND
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   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   else
41     gl_BUILD_ISNAND
42   fi
43 ])
44
45 dnl Pull in replacement isnand definition. It does not need -lm.
46 AC_DEFUN([gl_BUILD_ISNAND],
47 [
48   AC_LIBOBJ([isnand])
49   gl_DOUBLE_EXPONENT_LOCATION
50 ])
51
52 dnl Test whether isnand() can be used with libm.
53
54 AC_DEFUN([gl_HAVE_ISNAND_IN_LIBM],
55 [
56   AC_CACHE_CHECK([whether isnan(double) can be used with libm],
57     [gl_cv_func_isnand_in_libm],
58     [
59       save_LIBS="$LIBS"
60       LIBS="$LIBS -lm"
61       AC_TRY_LINK([#include <math.h>
62                    #if __GNUC__ >= 4
63                    # undef isnand
64                    # define isnand(x) __builtin_isnand ((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="$save_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_TRY_LINK([#include <math.h>
83                    #if __GNUC__ >= 4
84                    # undef isnand
85                    # define isnand(x) __builtin_isnan ((double)(x))
86                    #else
87                    # undef isnand
88                    # define isnand(x) isnan ((double)(x))
89                    #endif
90                    double x;],
91                   [return isnand (x);],
92         [gl_cv_func_isnand_no_libm=yes],
93         [gl_cv_func_isnand_no_libm=no])
94     ])
95 ])