[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
copysignl: simplify simple case
From: |
Bruno Haible |
Subject: |
copysignl: simplify simple case |
Date: |
Mon, 10 Oct 2011 00:28:31 +0200 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
We know of 4 platforms where 'long double' is the same as 'double':
Linux/HPPA, Minix, AIX, MSVC 9.
On these platforms, there is no need to compile large pieces of code
for 'long double' functions. A simple redirection to the function
taking 'double's and returning a 'double' will do. This will save code
in libgnu.a.
Let me start with 'copysignl'.
2011-10-09 Bruno Haible <address@hidden>
copysignl: Simplify for platforms where 'long double' == 'double'.
* lib/copysignl.c (copysignl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New
alternative.
* m4/copysignl.m4 (gl_FUNC_COPYSIGNL): Require gl_LONG_DOUBLE_VS_DOUBLE.
Determine COPYSIGNL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE.
* modules/copysignl (Depends-on): Add copysign. Update conditions.
--- lib/copysignl.c.orig Mon Oct 10 00:21:25 2011
+++ lib/copysignl.c Mon Oct 10 00:18:39 2011
@@ -19,8 +19,20 @@
/* Specification. */
#include <math.h>
+#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
+
+long double
+copysignl (long double x, long double y)
+{
+ return copysign (x, y);
+}
+
+#else
+
long double
copysignl (long double x, long double y)
{
return (signbit (x) != signbit (y) ? - x : x);
}
+
+#endif
--- m4/copysignl.m4.orig Mon Oct 10 00:21:25 2011
+++ m4/copysignl.m4 Mon Oct 10 00:19:50 2011
@@ -1,4 +1,4 @@
-# copysignl.m4 serial 1
+# copysignl.m4 serial 2
dnl Copyright (C) 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,
@@ -7,13 +7,19 @@
AC_DEFUN([gl_FUNC_COPYSIGNL],
[
AC_REQUIRE([gl_MATH_H_DEFAULTS])
+ AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
dnl Determine COPYSIGNL_LIBM.
gl_MATHFUNC([copysignl], [long double], [(long double, long double)])
if test $gl_cv_func_copysignl_no_libm = no \
&& test $gl_cv_func_copysignl_in_libm = no; then
HAVE_COPYSIGNL=0
- COPYSIGNL_LIBM=
+ if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
+ AC_REQUIRE([gl_FUNC_COPYSIGN])
+ COPYSIGNL_LIBM="$COPYSIGN_LIBM"
+ else
+ COPYSIGNL_LIBM=
+ fi
fi
AC_SUBST([COPYSIGNL_LIBM])
])
--- modules/copysignl.orig Mon Oct 10 00:21:25 2011
+++ modules/copysignl Mon Oct 10 00:20:43 2011
@@ -8,7 +8,8 @@
Depends-on:
math
-signbit [test $HAVE_COPYSIGNL = 0]
+copysign [test $HAVE_COPYSIGNL = 0 && test
$HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
+signbit [test $HAVE_COPYSIGNL = 0 && test
$HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
configure.ac:
gl_FUNC_COPYSIGNL
--
In memoriam Oskar Schindler <http://en.wikipedia.org/wiki/Oskar_Schindler>
<http://www.shoah.dk/Courage/Schindler.htm>
- copysignl: simplify simple case,
Bruno Haible <=