]> Savannah Git Hosting - gnulib.git/commitdiff
ceill: Simplify for platforms where 'long double' == 'double'.
authorBruno Haible <bruno@clisp.org>
Sun, 9 Oct 2011 23:04:13 +0000 (01:04 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 9 Oct 2011 23:04:13 +0000 (01:04 +0200)
* lib/ceill.c: Include <config.h>.
(ceill) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New function.
* lib/ceil.c [!USE_LONG_DOUBLE]: Don't include <config.h> a second
time.
* m4/ceill.m4 (gl_FUNC_CEILL): Require gl_LONG_DOUBLE_VS_DOUBLE.
Determine CEILL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE.
* modules/ceill (Depends-on): Add ceil. Update conditions.

ChangeLog
lib/ceil.c
lib/ceill.c
m4/ceill.m4
modules/ceill

index 11dc4bb0820ed81711cfdb193b9f06e27ce7cf05..909a202b5fede115d37da23add613843fac3fb7a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-10-09  Bruno Haible  <bruno@clisp.org>
+
+       ceill: Simplify for platforms where 'long double' == 'double'.
+       * lib/ceill.c: Include <config.h>.
+       (ceill) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New function.
+       * lib/ceil.c [!USE_LONG_DOUBLE]: Don't include <config.h> a second
+       time.
+       * m4/ceill.m4 (gl_FUNC_CEILL): Require gl_LONG_DOUBLE_VS_DOUBLE.
+       Determine CEILL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE.
+       * modules/ceill (Depends-on): Add ceil. Update conditions.
+
 2011-10-09  Bruno Haible  <bruno@clisp.org>
 
        floorl: Simplify for platforms where 'long double' == 'double'.
index b30902cbfd6dc059e2afbc7d1cf974da67fc29a9..4e0354e1cc4c7bebaf11709537c125a4f68b869a 100644 (file)
@@ -16,7 +16,9 @@
 
 /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 
-#include <config.h>
+#if ! defined USE_LONG_DOUBLE
+# include <config.h>
+#endif
 
 /* Specification.  */
 #include <math.h>
index 54a4b50c59c5284d832e66ab0ec4187e58338aaa..6181c91d423edd8de1e4721cbe74b6c31eab66c9 100644 (file)
 
 /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 
-#define USE_LONG_DOUBLE
-#include "ceil.c"
+#include <config.h>
+
+#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
+
+/* Specification.  */
+# include <math.h>
+
+long double
+ceill (long double x)
+{
+  return ceil (x);
+}
+
+#else
+
+# define USE_LONG_DOUBLE
+# include "ceil.c"
+
+#endif
index 40adaf12f183859ed5f5deba467572103a4821ee..5f56df32125d2b7d7445762888ef7abb56a26bf7 100644 (file)
@@ -1,4 +1,4 @@
-# ceill.m4 serial 11
+# ceill.m4 serial 12
 dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,8 +8,11 @@ AC_DEFUN([gl_FUNC_CEILL],
 [
   m4_divert_text([DEFAULTS], [gl_ceill_required=plain])
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
+
   dnl Persuade glibc <math.h> to declare ceill().
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
   dnl Test whether ceill() is declared.
   AC_CHECK_DECLS([ceill], , , [[#include <math.h>]])
   if test "$ac_cv_have_decl_ceill" = yes; then
@@ -60,8 +63,13 @@ int main (int argc, char *argv[])
     HAVE_DECL_CEILL=0
   fi
   if test $HAVE_DECL_CEILL = 0 || test $REPLACE_CEILL = 1; then
-    dnl No libraries are needed to link lib/ceill.c.
-    CEILL_LIBM=
+    dnl Find libraries needed to link lib/ceill.c.
+    if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
+      AC_REQUIRE([gl_FUNC_CEIL])
+      CEILL_LIBM="$CEIL_LIBM"
+    else
+      CEILL_LIBM=
+    fi
   fi
   AC_SUBST([CEILL_LIBM])
 ])
index 4ab7f3857552ba9fcfc5b699eafaaf87b4c16d0e..a5d860fc2080cf25e97870ef1460ca28c64e7202 100644 (file)
@@ -9,7 +9,8 @@ m4/ceill.m4
 Depends-on:
 math
 extensions
-float           [test $HAVE_DECL_CEILL = 0 || test $REPLACE_CEILL = 1]
+ceil            [{ test $HAVE_DECL_CEILL = 0 || test $REPLACE_CEILL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
+float           [{ test $HAVE_DECL_CEILL = 0 || test $REPLACE_CEILL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
 
 configure.ac:
 gl_FUNC_CEILL