From 959c1e5b08fa6d5ce99d62592ffbb9fd61a4136d Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 7 Mar 2007 01:14:04 +0000
Subject: [PATCH] Fix the test whether frexpl() and ldexpl() are declared. Move
 the declaration to <math.h>.

---
 ChangeLog             | 21 +++++++++++++++++++++
 m4/printf-frexpl.m4   | 15 ++++++++-------
 modules/printf-frexpl |  1 +
 3 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 90a18c6df9..3827171376 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2007-03-06  Bruno Haible  <bruno@clisp.org>
+
+	* lib/math_.h (acosl): Declare also if HAVE_DECL_ACOSL is set.
+	(asinl): Declare also if HAVE_DECL_ASINL is set.
+	(atanl): Declare also if HAVE_DECL_ATANL is set.
+	(ceill): Declare also if HAVE_DECL_CEILL is set.
+	(cosl): Declare also if HAVE_DECL_COSL is set.
+	(expl): Declare also if HAVE_DECL_EXPL is set.
+	(floorl): Declare also if HAVE_DECL_FLOORL is set.
+	(frexpl): Declare also if HAVE_DECL_FREXPL is set.
+	(ldexpl): Declare also if HAVE_DECL_LDEXPL is set.
+	(logl): Declare also if HAVE_DECL_LOGL is set.
+	(sinl): Declare also if HAVE_DECL_SINL is set.
+	(sqrtl): Declare also if HAVE_DECL_SQRTL is set.
+	(tanl): Declare also if HAVE_DECL_TANL is set.
+	* modules/math (Makefile.am): Substitute the values of HAVE_DECL_*.
+	* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Set HAVE_DECL_* to 1.
+	* m4/printf-frexpl.m4 (gl_FUNC_PRINTF_FREXPL): Fix tests for the
+	declaration of frexpl, ldexpl.
+	* modules/printf-frexpl (Depends-on): Add math.
+
 2007-03-05  Bruno Haible  <bruno@clisp.org>
 
 	* m4/printf-frexpl.m4 (gl_FUNC_PRINTF_FREXPL): Also test whether
diff --git a/m4/printf-frexpl.m4 b/m4/printf-frexpl.m4
index e21ae36e61..d522d0e3b8 100644
--- a/m4/printf-frexpl.m4
+++ b/m4/printf-frexpl.m4
@@ -1,4 +1,4 @@
-# printf-frexpl.m4 serial 2
+# printf-frexpl.m4 serial 3
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,6 +9,7 @@ dnl Check how to define printf_frexpl() without linking with libm.
 AC_DEFUN([gl_FUNC_PRINTF_FREXPL],
 [
   AC_REQUIRE([gt_TYPE_LONGDOUBLE])
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
   if test $gt_cv_c_long_double = yes; then
     AC_CACHE_CHECK([whether frexpl can be used without linking with libm],
       [gl_cv_func_frexpl_no_libm],
@@ -23,9 +24,9 @@ AC_DEFUN([gl_FUNC_PRINTF_FREXPL],
     if test $gl_cv_func_frexpl_no_libm = yes; then
       AC_DEFINE([HAVE_FREXPL_IN_LIBC], 1,
         [Define if the frexpl function is available in libc.])
-      dnl Also check whether it's declared. glibc (2.3..2.5 at least) and
-      dnl MacOS X 10.3 have frexpl() in libc but don't declare it in <math.h>.
-      AC_CHECK_DECLS([frexpl])
+      dnl Also check whether it's declared.
+      dnl MacOS X 10.3 has frexpl() in libc but doesn't declare it in <math.h>.
+      AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [#include <math.h>])
     fi
 
     AC_CACHE_CHECK([whether ldexpl can be used without linking with libm],
@@ -41,9 +42,9 @@ AC_DEFUN([gl_FUNC_PRINTF_FREXPL],
     if test $gl_cv_func_ldexpl_no_libm = yes; then
       AC_DEFINE([HAVE_LDEXPL_IN_LIBC], 1,
         [Define if the ldexpl function is available in libc.])
-      dnl Also check whether it's declared. glibc (2.3..2.5 at least) and
-      dnl MacOS X 10.3 have ldexpl() in libc but don't declare it in <math.h>.
-      AC_CHECK_DECLS([ldexpl])
+      dnl Also check whether it's declared.
+      dnl MacOS X 10.3 has ldexpl() in libc but doesn't declare it in <math.h>.
+      AC_CHECK_DECL([ldexpl], , [HAVE_DECL_LDEXPL=0], [#include <math.h>])
     fi
   fi
 ])
diff --git a/modules/printf-frexpl b/modules/printf-frexpl
index 3d9e382f3a..36d4f346cc 100644
--- a/modules/printf-frexpl
+++ b/modules/printf-frexpl
@@ -10,6 +10,7 @@ m4/printf-frexpl.m4
 m4/longdouble.m4
 
 Depends-on:
+math
 
 configure.ac:
 gl_FUNC_PRINTF_FREXPL
-- 
2.39.5