]> Savannah Git Hosting - gnulib.git/commitdiff
New module 'copysignl'.
authorBruno Haible <bruno@clisp.org>
Sun, 9 Oct 2011 13:53:49 +0000 (15:53 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 9 Oct 2011 14:21:26 +0000 (16:21 +0200)
* lib/math.in.h (copysignl): New declaration.
* lib/copysignl.c: New file.
* m4/copysignl.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether copysignl is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_COPYSIGNL, HAVE_COPYSIGNL.
* modules/math (Makefile.am): Substitute GNULIB_COPYSIGNL,
HAVE_COPYSIGNL.
* modules/copysignl: New file.
* tests/test-math-c++.cc: Check the declaration of copysignl.
* modules/math-c++-tests (Makefile.am): Link test-math-c++ against
$(COPYSIGNL_LIBM). Needed on IRIX 6.5 with cc.
* doc/posix-functions/copysignl.texi: Mention the new module.

ChangeLog
doc/posix-functions/copysignl.texi
lib/copysignl.c [new file with mode: 0644]
lib/math.in.h
m4/copysignl.m4 [new file with mode: 0644]
m4/math_h.m4
modules/copysignl [new file with mode: 0644]
modules/math
modules/math-c++-tests
tests/test-math-c++.cc

index 22ffe8e9665b78033924a3e6abc9d8e08ab72deb..ef3f7c6e8d7d52238527ac5dd91fe88360ed189c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2011-10-09  Bruno Haible  <bruno@clisp.org>
+
+       New module 'copysignl'.
+       * lib/math.in.h (copysignl): New declaration.
+       * lib/copysignl.c: New file.
+       * m4/copysignl.m4: New file.
+       * m4/math_h.m4 (gl_MATH_H): Test whether copysignl is declared.
+       (gl_MATH_H_DEFAULTS): Initialize GNULIB_COPYSIGNL, HAVE_COPYSIGNL.
+       * modules/math (Makefile.am): Substitute GNULIB_COPYSIGNL,
+       HAVE_COPYSIGNL.
+       * modules/copysignl: New file.
+       * tests/test-math-c++.cc: Check the declaration of copysignl.
+       * modules/math-c++-tests (Makefile.am): Link test-math-c++ against
+       $(COPYSIGNL_LIBM). Needed on IRIX 6.5 with cc.
+       * doc/posix-functions/copysignl.texi: Mention the new module.
+
 2011-10-09  Bruno Haible  <bruno@clisp.org>
 
        Tests for module 'copysignf'.
index 874e45eb8164d8e81ee3e5179e30a50e923bb776..838051b13418da3acafb9ea00c633f3afa2631ea 100644 (file)
@@ -4,15 +4,15 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/copysignl.html}
 
-Gnulib module: ---
+Gnulib module: copysignl
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+FreeBSD 5.2.1, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, older IRIX 6.5, Solaris 9, Cygwin, MSVC 9, Interix 3.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function is missing on some platforms:
-FreeBSD 5.2.1, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin, MSVC 9, Interix 3.5.
 @end itemize
diff --git a/lib/copysignl.c b/lib/copysignl.c
new file mode 100644 (file)
index 0000000..95947f4
--- /dev/null
@@ -0,0 +1,26 @@
+/* Copy sign into another 'long double' number.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <math.h>
+
+long double
+copysignl (long double x, long double y)
+{
+  return (signbit (x) != signbit (y) ? - x : x);
+}
index 37f9a2fb882f6a4abcb9c731221360c0aa85890f..cc8060e24baec49ab2e772da619d3572eb641d03 100644 (file)
@@ -302,6 +302,20 @@ _GL_WARN_ON_USE (copysign, "copysign is unportable - "
 # endif
 #endif
 
+#if @GNULIB_COPYSIGNL@
+# if !@HAVE_COPYSIGNL@
+_GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y));
+# endif
+_GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y));
+_GL_CXXALIASWARN (copysignl);
+#elif defined GNULIB_POSIXCHECK
+# undef copysignl
+# if HAVE_RAW_DECL_COPYSIGNL
+_GL_WARN_ON_USE (copysign, "copysignl is unportable - "
+                 "use gnulib module copysignl for portability");
+# endif
+#endif
+
 
 #if @GNULIB_COSF@
 # if !@HAVE_COSF@
diff --git a/m4/copysignl.m4 b/m4/copysignl.m4
new file mode 100644 (file)
index 0000000..4b5329f
--- /dev/null
@@ -0,0 +1,19 @@
+# copysignl.m4 serial 1
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_COPYSIGNL],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+
+  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=
+  fi
+  AC_SUBST([COPYSIGNL_LIBM])
+])
index 4d5105b1231d31578c90922da02da9d29982a48a..bcc6a3f96e488dd049f84ade028c881d9a6aabd1 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 49
+# math_h.m4 serial 50
 dnl Copyright (C) 2007-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,
@@ -40,7 +40,7 @@ AC_DEFUN([gl_MATH_H],
   dnl corresponding gnulib module is not in use.
   gl_WARN_ON_USE_PREPARE([[#include <math.h>]],
     [acosf acosl asinf asinl atanf atanl
-     ceilf ceill copysign copysignf cosf cosl coshf
+     ceilf ceill copysign copysignf copysignl cosf cosl coshf
      expf expl fabsf floorf floorl fmodf frexpf frexpl
      ldexpf ldexpl logb logf logl log10f modff powf
      round roundf roundl sinf sinl sinhf sqrtf sqrtl
@@ -70,6 +70,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   GNULIB_CEILL=0;     AC_SUBST([GNULIB_CEILL])
   GNULIB_COPYSIGN=0;  AC_SUBST([GNULIB_COPYSIGN])
   GNULIB_COPYSIGNF=0; AC_SUBST([GNULIB_COPYSIGNF])
+  GNULIB_COPYSIGNL=0; AC_SUBST([GNULIB_COPYSIGNL])
   GNULIB_COSF=0;      AC_SUBST([GNULIB_COSF])
   GNULIB_COSL=0;      AC_SUBST([GNULIB_COSL])
   GNULIB_COSHF=0;     AC_SUBST([GNULIB_COSHF])
@@ -122,6 +123,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   HAVE_ATAN2F=1;               AC_SUBST([HAVE_ATAN2F])
   HAVE_COPYSIGN=1;             AC_SUBST([HAVE_COPYSIGN])
   HAVE_COPYSIGNF=1;            AC_SUBST([HAVE_COPYSIGNF])
+  HAVE_COPYSIGNL=1;            AC_SUBST([HAVE_COPYSIGNL])
   HAVE_COSF=1;                 AC_SUBST([HAVE_COSF])
   HAVE_COSL=1;                 AC_SUBST([HAVE_COSL])
   HAVE_COSHF=1;                AC_SUBST([HAVE_COSHF])
diff --git a/modules/copysignl b/modules/copysignl
new file mode 100644 (file)
index 0000000..048a815
--- /dev/null
@@ -0,0 +1,32 @@
+Description:
+copysignl() function: copy sign into another 'long double' number.
+
+Files:
+lib/copysignl.c
+m4/copysignl.m4
+m4/mathfunc.m4
+
+Depends-on:
+math
+signbit         [test $HAVE_COPYSIGNL = 0]
+
+configure.ac:
+gl_FUNC_COPYSIGNL
+if test $HAVE_COPYSIGNL = 0; then
+  AC_LIBOBJ([copysignl])
+fi
+gl_MATH_MODULE_INDICATOR([copysignl])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(COPYSIGNL_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
index c0c3a88e772ec3d3dbdff470c98e0025053a4ae7..0e0f4eae295ffa70150e9c82063dc04b7a04c121 100644 (file)
@@ -40,6 +40,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's/@''GNULIB_CEILL''@/$(GNULIB_CEILL)/g' \
              -e 's/@''GNULIB_COPYSIGN''@/$(GNULIB_COPYSIGN)/g' \
              -e 's/@''GNULIB_COPYSIGNF''@/$(GNULIB_COPYSIGNF)/g' \
+             -e 's/@''GNULIB_COPYSIGNL''@/$(GNULIB_COPYSIGNL)/g' \
              -e 's/@''GNULIB_COSF''@/$(GNULIB_COSF)/g' \
              -e 's/@''GNULIB_COSL''@/$(GNULIB_COSL)/g' \
              -e 's/@''GNULIB_COSHF''@/$(GNULIB_COSHF)/g' \
@@ -92,6 +93,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''HAVE_ATAN2F''@|$(HAVE_ATAN2F)|g' \
              -e 's|@''HAVE_COPYSIGN''@|$(HAVE_COPYSIGN)|g' \
              -e 's|@''HAVE_COPYSIGNF''@|$(HAVE_COPYSIGNF)|g' \
+             -e 's|@''HAVE_COPYSIGNL''@|$(HAVE_COPYSIGNL)|g' \
              -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \
              -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
              -e 's|@''HAVE_COSHF''@|$(HAVE_COSHF)|g' \
index 24aa81078e9c953a625b51514303aede90e9f958..6e2d003437a7a1c24e03bab5a0a1ded9db7a39db 100644 (file)
@@ -16,4 +16,5 @@ if ANSICXX
 TESTS += test-math-c++
 check_PROGRAMS += test-math-c++
 test_math_c___SOURCES = test-math-c++.cc test-math-c++2.cc
+test_math_c___LDADD = $(LDADD) $(COPYSIGNL_LIBM)
 endif
index b519992f334728a9ad15704abd4c93856d7230a5..371249246e34e85ea79ce2ff69d9998365131407 100644 (file)
@@ -153,6 +153,11 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::ceil, double, (double));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::ceill, long double, (long double));
 #endif
 
+#if GNULIB_TEST_COPYSIGNL
+SIGNATURE_CHECK (GNULIB_NAMESPACE::copysignl, long double,
+                 (long double, long double));
+#endif
+
 #if GNULIB_TEST_COSL
 SIGNATURE_CHECK (GNULIB_NAMESPACE::cosl, long double, (long double));
 #endif