(gl_C99_STRTOLD): New macro.
[gnulib.git] / m4 / c-strtod.m4
1 # c-strtod.m4 serial 4
2
3 # Copyright (C) 2004 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 # Written by Paul Eggert.
20
21 AC_DEFUN([gl_C99_STRTOLD],
22 [
23   AC_CACHE_CHECK([whether strtold conforms to C99],
24     [gl_cv_func_c99_strtold],
25     [AC_COMPILE_IFELSE(
26        [AC_LANG_PROGRAM(
27           [[/* On HP-UX before 11.23, strtold returns a struct instead of
28                 long double.  Reject implementations like that, by requiring
29                 compatibility with the C99 prototype.  */
30              #include <stdlib.h>
31              static long double (*p) (char const *, char **) = strtold;
32              static long double
33              test (char const *nptr, char **endptr)
34              {
35                long double r;
36                r = strtold (nptr, endptr);
37                return r;
38              }]],
39            [[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])],
40        [gl_cv_func_c99_strtold=yes],
41        [gl_cv_func_c99_strtold=no])])
42   if test $gl_cv_func_c99_strtold = yes; then
43     AC_DEFINE([HAVE_C99_STRTOLD], 1, [Define to 1 if strtold conforms to C99.])
44   fi
45 ])
46
47 AC_DEFUN([gl_C_STRTOD],
48 [
49   dnl Prerequisites of lib/c-strtod.c.
50   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
51   :
52 ])
53
54 AC_DEFUN([gl_C_STRTOLD],
55 [
56   dnl Prerequisites of lib/c-strtold.c.
57   AC_REQUIRE([gl_C_STRTOD])
58   AC_REQUIRE([gl_C99_STRTOLD])
59   :
60 ])