Move some declarations from acl.h to acl-internal.h.
[gnulib.git] / m4 / strtod.m4
1 # strtod.m4 serial 9
2 dnl Copyright (C) 2002, 2003, 2006, 2007, 2008 Free Software
3 dnl 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
8 AC_DEFUN([gl_FUNC_STRTOD],
9 [
10   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
11   AC_FUNC_STRTOD
12   dnl Note: AC_FUNC_STRTOD does AC_LIBOBJ(strtod).
13   if test $ac_cv_func_strtod = no; then
14     HAVE_STRTOD=0
15     REPLACE_STRTOD=1
16     gl_PREREQ_STRTOD
17   else
18     AC_CACHE_CHECK([whether strtod obeys C99], [gl_cv_func_strtod_works],
19       [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
20 #include <stdlib.h>
21 #include <math.h>
22 /* Compare two numbers with ==.
23    This is a separate function because IRIX 6.5 "cc -O" miscompiles an
24    'x == x' test.  */
25 static int
26 numeric_equal (double x, double y)
27 {
28   return x == y;
29 }
30 ]], [[
31   {
32     /* Older glibc and Cygwin mis-parse "-0x".  */
33     const char *string = "-0x";
34     char *term;
35     double value = strtod (string, &term);
36     double zero = 0.0;
37     if (1.0 / value != -1.0 / zero || term != (string + 2))
38       return 1;
39   }
40   {
41     /* Many platforms do not parse hex floats.  */
42     const char *string = "0XaP+1";
43     char *term;
44     double value = strtod (string, &term);
45     if (value != 20.0 || term != (string + 6))
46       return 1;
47   }
48   {
49     /* Many platforms do not parse infinities.  */
50     const char *string = "inf";
51     char *term;
52     double value = strtod (string, &term);
53     if (value != HUGE_VAL || term != (string + 3))
54       return 1;
55   }
56   {
57     /* glibc 2.7 and cygwin 1.5.24 misparse "nan()".  */
58     const char *string = "nan()";
59     char *term;
60     double value = strtod (string, &term);
61     if (numeric_equal (value, value) || term != (string + 5))
62       return 1;
63   }
64 ]])],
65         [gl_cv_func_strtod_works=yes],
66         [gl_cv_func_strtod_works=no],
67         [gl_cv_func_strtod_works="guessing no"])])
68     if test "$gl_cv_func_strtod_works" != yes; then
69       REPLACE_STRTOD=1
70       gl_PREREQ_STRTOD
71       dnl Use undocumented macro to set POW_LIB correctly.
72       _AC_LIBOBJ_STRTOD
73     fi
74   fi
75 ])
76
77 # Prerequisites of lib/strtod.c.
78 # The need for pow() is already handled by AC_FUNC_STRTOD.
79 AC_DEFUN([gl_PREREQ_STRTOD], [:])