changeset 15911:bc21ee3c09aa

New module 'copysignf'. * lib/math.in.h (copysignf): New declaration. * lib/copysignf.c: New file. * m4/copysignf.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether copysignf is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_COPYSIGNF, HAVE_COPYSIGNF. * modules/math (Makefile.am): Substitute GNULIB_COPYSIGNF, HAVE_COPYSIGNF. * modules/copysignf: New file. * tests/test-math-c++.cc: Check the declaration of copysignf. * doc/posix-functions/copysignf.texi: Mention the new module.
author Bruno Haible <bruno@clisp.org>
date Sun, 09 Oct 2011 15:42:35 +0200
parents 298082962c0e
children 4dc23e6fdabd
files ChangeLog doc/posix-functions/copysignf.texi lib/copysignf.c lib/math.in.h m4/copysignf.m4 m4/math_h.m4 modules/copysignf modules/math tests/test-math-c++.cc
diffstat 9 files changed, 188 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-10-09  Bruno Haible  <bruno@clisp.org>
+
+	New module 'copysignf'.
+	* lib/math.in.h (copysignf): New declaration.
+	* lib/copysignf.c: New file.
+	* m4/copysignf.m4: New file.
+	* m4/math_h.m4 (gl_MATH_H): Test whether copysignf is declared.
+	(gl_MATH_H_DEFAULTS): Initialize GNULIB_COPYSIGNF, HAVE_COPYSIGNF.
+	* modules/math (Makefile.am): Substitute GNULIB_COPYSIGNF,
+	HAVE_COPYSIGNF.
+	* modules/copysignf: New file.
+	* tests/test-math-c++.cc: Check the declaration of copysignf.
+	* doc/posix-functions/copysignf.texi: Mention the new module.
+
 2011-10-09  Bruno Haible  <bruno@clisp.org>
 
 	Ensure that HAVE_* variables are set to 1 before they are set to 0.
--- a/doc/posix-functions/copysignf.texi
+++ b/doc/posix-functions/copysignf.texi
@@ -4,15 +4,15 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/copysignf.html}
 
-Gnulib module: ---
+Gnulib module: copysignf
 
 Portability problems fixed by Gnulib:
 @itemize
-@end itemize
-
-Portability problems not fixed by Gnulib:
-@itemize
 @item
 This function is missing on some platforms:
 Minix 3.1.8, AIX 5.1, IRIX 6.5, Solaris 9, MSVC 9.
 @end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
new file mode 100644
--- /dev/null
+++ b/lib/copysignf.c
@@ -0,0 +1,26 @@
+/* Copy sign into another 'float' 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>
+
+float
+copysignf (float x, float y)
+{
+  return (signbit (x) != signbit (y) ? - x : x);
+}
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -274,6 +274,35 @@
 #endif
 
 
+#if @GNULIB_COPYSIGNF@
+# if !@HAVE_COPYSIGNF@
+_GL_FUNCDECL_SYS (copysignf, float, (float x, float y));
+# endif
+_GL_CXXALIAS_SYS (copysignf, float, (float x, float y));
+_GL_CXXALIASWARN (copysignf);
+#elif defined GNULIB_POSIXCHECK
+# undef copysignf
+# if HAVE_RAW_DECL_COPYSIGNF
+_GL_WARN_ON_USE (copysignf, "copysignf is unportable - "
+                 "use gnulib module copysignf for portability");
+# endif
+#endif
+
+#if @GNULIB_COPYSIGN@
+# if !@HAVE_COPYSIGN@
+_GL_FUNCDECL_SYS (copysign, double, (double x, double y));
+# endif
+_GL_CXXALIAS_SYS (copysign, double, (double x, double y));
+_GL_CXXALIASWARN (copysign);
+#elif defined GNULIB_POSIXCHECK
+# undef copysign
+# if HAVE_RAW_DECL_COPYSIGN
+_GL_WARN_ON_USE (copysign, "copysign is unportable - "
+                 "use gnulib module copysign for portability");
+# endif
+#endif
+
+
 #if @GNULIB_COSF@
 # if !@HAVE_COSF@
 #  undef cosf
@@ -320,21 +349,6 @@
 #endif
 
 
-#if @GNULIB_COPYSIGN@
-# if !@HAVE_COPYSIGN@
-_GL_FUNCDECL_SYS (copysign, double, (double x, double y));
-# endif
-_GL_CXXALIAS_SYS (copysign, double, (double x, double y));
-_GL_CXXALIASWARN (copysign);
-#elif defined GNULIB_POSIXCHECK
-# undef copysign
-# if HAVE_RAW_DECL_COPYSIGN
-_GL_WARN_ON_USE (copysign, "copysign is unportable - "
-                 "use gnulib module copysign for portability");
-# endif
-#endif
-
-
 #if @GNULIB_EXPF@
 # if !@HAVE_EXPF@
 #  undef expf
new file mode 100644
--- /dev/null
+++ b/m4/copysignf.m4
@@ -0,0 +1,19 @@
+# copysignf.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_COPYSIGNF],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+
+  dnl Determine COPYSIGNF_LIBM.
+  gl_MATHFUNC([copysignf], [float], [(float, float)])
+  if test $gl_cv_func_copysignf_no_libm = no \
+     && test $gl_cv_func_copysignf_in_libm = no; then
+    HAVE_COPYSIGNF=0
+    COPYSIGNF_LIBM=
+  fi
+  AC_SUBST([COPYSIGNF_LIBM])
+])
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 48
+# math_h.m4 serial 49
 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,
@@ -39,7 +39,8 @@
   dnl Check for declarations of anything we want to poison if the
   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 cosf cosl coshf
+    [acosf acosl asinf asinl atanf atanl
+     ceilf ceill copysign copysignf 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
@@ -57,59 +58,60 @@
 
 AC_DEFUN([gl_MATH_H_DEFAULTS],
 [
-  GNULIB_ACOSF=0;    AC_SUBST([GNULIB_ACOSF])
-  GNULIB_ACOSL=0;    AC_SUBST([GNULIB_ACOSL])
-  GNULIB_ASINF=0;    AC_SUBST([GNULIB_ASINF])
-  GNULIB_ASINL=0;    AC_SUBST([GNULIB_ASINL])
-  GNULIB_ATANF=0;    AC_SUBST([GNULIB_ATANF])
-  GNULIB_ATANL=0;    AC_SUBST([GNULIB_ATANL])
-  GNULIB_ATAN2F=0;   AC_SUBST([GNULIB_ATAN2F])
-  GNULIB_CEIL=0;     AC_SUBST([GNULIB_CEIL])
-  GNULIB_CEILF=0;    AC_SUBST([GNULIB_CEILF])
-  GNULIB_CEILL=0;    AC_SUBST([GNULIB_CEILL])
-  GNULIB_COPYSIGN=0; AC_SUBST([GNULIB_COPYSIGN])
-  GNULIB_COSF=0;     AC_SUBST([GNULIB_COSF])
-  GNULIB_COSL=0;     AC_SUBST([GNULIB_COSL])
-  GNULIB_COSHF=0;    AC_SUBST([GNULIB_COSHF])
-  GNULIB_EXPF=0;     AC_SUBST([GNULIB_EXPF])
-  GNULIB_EXPL=0;     AC_SUBST([GNULIB_EXPL])
-  GNULIB_FABSF=0;    AC_SUBST([GNULIB_FABSF])
-  GNULIB_FLOOR=0;    AC_SUBST([GNULIB_FLOOR])
-  GNULIB_FLOORF=0;   AC_SUBST([GNULIB_FLOORF])
-  GNULIB_FLOORL=0;   AC_SUBST([GNULIB_FLOORL])
-  GNULIB_FMODF=0;    AC_SUBST([GNULIB_FMODF])
-  GNULIB_FREXPF=0;   AC_SUBST([GNULIB_FREXPF])
-  GNULIB_FREXP=0;    AC_SUBST([GNULIB_FREXP])
-  GNULIB_FREXPL=0;   AC_SUBST([GNULIB_FREXPL])
-  GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE])
-  GNULIB_ISINF=0;    AC_SUBST([GNULIB_ISINF])
-  GNULIB_ISNAN=0;    AC_SUBST([GNULIB_ISNAN])
-  GNULIB_ISNANF=0;   AC_SUBST([GNULIB_ISNANF])
-  GNULIB_ISNAND=0;   AC_SUBST([GNULIB_ISNAND])
-  GNULIB_ISNANL=0;   AC_SUBST([GNULIB_ISNANL])
-  GNULIB_LDEXPF=0;   AC_SUBST([GNULIB_LDEXPF])
-  GNULIB_LDEXPL=0;   AC_SUBST([GNULIB_LDEXPL])
-  GNULIB_LOGB=0;     AC_SUBST([GNULIB_LOGB])
-  GNULIB_LOGF=0;     AC_SUBST([GNULIB_LOGF])
-  GNULIB_LOGL=0;     AC_SUBST([GNULIB_LOGL])
-  GNULIB_LOG10F=0;   AC_SUBST([GNULIB_LOG10F])
-  GNULIB_MODFF=0;    AC_SUBST([GNULIB_MODFF])
-  GNULIB_POWF=0;     AC_SUBST([GNULIB_POWF])
-  GNULIB_ROUND=0;    AC_SUBST([GNULIB_ROUND])
-  GNULIB_ROUNDF=0;   AC_SUBST([GNULIB_ROUNDF])
-  GNULIB_ROUNDL=0;   AC_SUBST([GNULIB_ROUNDL])
-  GNULIB_SIGNBIT=0;  AC_SUBST([GNULIB_SIGNBIT])
-  GNULIB_SINF=0;     AC_SUBST([GNULIB_SINF])
-  GNULIB_SINL=0;     AC_SUBST([GNULIB_SINL])
-  GNULIB_SINHF=0;    AC_SUBST([GNULIB_SINHF])
-  GNULIB_SQRTF=0;    AC_SUBST([GNULIB_SQRTF])
-  GNULIB_SQRTL=0;    AC_SUBST([GNULIB_SQRTL])
-  GNULIB_TANF=0;     AC_SUBST([GNULIB_TANF])
-  GNULIB_TANL=0;     AC_SUBST([GNULIB_TANL])
-  GNULIB_TANHF=0;    AC_SUBST([GNULIB_TANHF])
-  GNULIB_TRUNC=0;    AC_SUBST([GNULIB_TRUNC])
-  GNULIB_TRUNCF=0;   AC_SUBST([GNULIB_TRUNCF])
-  GNULIB_TRUNCL=0;   AC_SUBST([GNULIB_TRUNCL])
+  GNULIB_ACOSF=0;     AC_SUBST([GNULIB_ACOSF])
+  GNULIB_ACOSL=0;     AC_SUBST([GNULIB_ACOSL])
+  GNULIB_ASINF=0;     AC_SUBST([GNULIB_ASINF])
+  GNULIB_ASINL=0;     AC_SUBST([GNULIB_ASINL])
+  GNULIB_ATANF=0;     AC_SUBST([GNULIB_ATANF])
+  GNULIB_ATANL=0;     AC_SUBST([GNULIB_ATANL])
+  GNULIB_ATAN2F=0;    AC_SUBST([GNULIB_ATAN2F])
+  GNULIB_CEIL=0;      AC_SUBST([GNULIB_CEIL])
+  GNULIB_CEILF=0;     AC_SUBST([GNULIB_CEILF])
+  GNULIB_CEILL=0;     AC_SUBST([GNULIB_CEILL])
+  GNULIB_COPYSIGN=0;  AC_SUBST([GNULIB_COPYSIGN])
+  GNULIB_COPYSIGNF=0; AC_SUBST([GNULIB_COPYSIGNF])
+  GNULIB_COSF=0;      AC_SUBST([GNULIB_COSF])
+  GNULIB_COSL=0;      AC_SUBST([GNULIB_COSL])
+  GNULIB_COSHF=0;     AC_SUBST([GNULIB_COSHF])
+  GNULIB_EXPF=0;      AC_SUBST([GNULIB_EXPF])
+  GNULIB_EXPL=0;      AC_SUBST([GNULIB_EXPL])
+  GNULIB_FABSF=0;     AC_SUBST([GNULIB_FABSF])
+  GNULIB_FLOOR=0;     AC_SUBST([GNULIB_FLOOR])
+  GNULIB_FLOORF=0;    AC_SUBST([GNULIB_FLOORF])
+  GNULIB_FLOORL=0;    AC_SUBST([GNULIB_FLOORL])
+  GNULIB_FMODF=0;     AC_SUBST([GNULIB_FMODF])
+  GNULIB_FREXPF=0;    AC_SUBST([GNULIB_FREXPF])
+  GNULIB_FREXP=0;     AC_SUBST([GNULIB_FREXP])
+  GNULIB_FREXPL=0;    AC_SUBST([GNULIB_FREXPL])
+  GNULIB_ISFINITE=0;  AC_SUBST([GNULIB_ISFINITE])
+  GNULIB_ISINF=0;     AC_SUBST([GNULIB_ISINF])
+  GNULIB_ISNAN=0;     AC_SUBST([GNULIB_ISNAN])
+  GNULIB_ISNANF=0;    AC_SUBST([GNULIB_ISNANF])
+  GNULIB_ISNAND=0;    AC_SUBST([GNULIB_ISNAND])
+  GNULIB_ISNANL=0;    AC_SUBST([GNULIB_ISNANL])
+  GNULIB_LDEXPF=0;    AC_SUBST([GNULIB_LDEXPF])
+  GNULIB_LDEXPL=0;    AC_SUBST([GNULIB_LDEXPL])
+  GNULIB_LOGB=0;      AC_SUBST([GNULIB_LOGB])
+  GNULIB_LOGF=0;      AC_SUBST([GNULIB_LOGF])
+  GNULIB_LOGL=0;      AC_SUBST([GNULIB_LOGL])
+  GNULIB_LOG10F=0;    AC_SUBST([GNULIB_LOG10F])
+  GNULIB_MODFF=0;     AC_SUBST([GNULIB_MODFF])
+  GNULIB_POWF=0;      AC_SUBST([GNULIB_POWF])
+  GNULIB_ROUND=0;     AC_SUBST([GNULIB_ROUND])
+  GNULIB_ROUNDF=0;    AC_SUBST([GNULIB_ROUNDF])
+  GNULIB_ROUNDL=0;    AC_SUBST([GNULIB_ROUNDL])
+  GNULIB_SIGNBIT=0;   AC_SUBST([GNULIB_SIGNBIT])
+  GNULIB_SINF=0;      AC_SUBST([GNULIB_SINF])
+  GNULIB_SINL=0;      AC_SUBST([GNULIB_SINL])
+  GNULIB_SINHF=0;     AC_SUBST([GNULIB_SINHF])
+  GNULIB_SQRTF=0;     AC_SUBST([GNULIB_SQRTF])
+  GNULIB_SQRTL=0;     AC_SUBST([GNULIB_SQRTL])
+  GNULIB_TANF=0;      AC_SUBST([GNULIB_TANF])
+  GNULIB_TANL=0;      AC_SUBST([GNULIB_TANL])
+  GNULIB_TANHF=0;     AC_SUBST([GNULIB_TANHF])
+  GNULIB_TRUNC=0;     AC_SUBST([GNULIB_TRUNC])
+  GNULIB_TRUNCF=0;    AC_SUBST([GNULIB_TRUNCF])
+  GNULIB_TRUNCL=0;    AC_SUBST([GNULIB_TRUNCL])
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_ACOSF=1;                AC_SUBST([HAVE_ACOSF])
   HAVE_ACOSL=1;                AC_SUBST([HAVE_ACOSL])
@@ -119,6 +121,7 @@
   HAVE_ATANL=1;                AC_SUBST([HAVE_ATANL])
   HAVE_ATAN2F=1;               AC_SUBST([HAVE_ATAN2F])
   HAVE_COPYSIGN=1;             AC_SUBST([HAVE_COPYSIGN])
+  HAVE_COPYSIGNF=1;            AC_SUBST([HAVE_COPYSIGNF])
   HAVE_COSF=1;                 AC_SUBST([HAVE_COSF])
   HAVE_COSL=1;                 AC_SUBST([HAVE_COSL])
   HAVE_COSHF=1;                AC_SUBST([HAVE_COSHF])
new file mode 100644
--- /dev/null
+++ b/modules/copysignf
@@ -0,0 +1,32 @@
+Description:
+copysignf() function: copy sign into another 'float' number.
+
+Files:
+lib/copysignf.c
+m4/copysignf.m4
+m4/mathfunc.m4
+
+Depends-on:
+math
+signbit         [test $HAVE_COPYSIGNF = 0]
+
+configure.ac:
+gl_FUNC_COPYSIGNF
+if test $HAVE_COPYSIGNF = 0; then
+  AC_LIBOBJ([copysignf])
+fi
+gl_MATH_MODULE_INDICATOR([copysignf])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(COPYSIGNF_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
--- a/modules/math
+++ b/modules/math
@@ -39,6 +39,7 @@
 	      -e 's/@''GNULIB_CEILF''@/$(GNULIB_CEILF)/g' \
 	      -e 's/@''GNULIB_CEILL''@/$(GNULIB_CEILL)/g' \
 	      -e 's/@''GNULIB_COPYSIGN''@/$(GNULIB_COPYSIGN)/g' \
+	      -e 's/@''GNULIB_COPYSIGNF''@/$(GNULIB_COPYSIGNF)/g' \
 	      -e 's/@''GNULIB_COSF''@/$(GNULIB_COSF)/g' \
 	      -e 's/@''GNULIB_COSL''@/$(GNULIB_COSL)/g' \
 	      -e 's/@''GNULIB_COSHF''@/$(GNULIB_COSHF)/g' \
@@ -90,6 +91,7 @@
 	      -e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \
 	      -e 's|@''HAVE_ATAN2F''@|$(HAVE_ATAN2F)|g' \
 	      -e 's|@''HAVE_COPYSIGN''@|$(HAVE_COPYSIGN)|g' \
+	      -e 's|@''HAVE_COPYSIGNF''@|$(HAVE_COPYSIGNF)|g' \
 	      -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \
 	      -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
 	      -e 's|@''HAVE_COSHF''@|$(HAVE_COSHF)|g' \
--- a/tests/test-math-c++.cc
+++ b/tests/test-math-c++.cc
@@ -41,6 +41,9 @@
 #endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::atan2, double, (double, double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::cbrt, double, (double));
+#if GNULIB_TEST_COPYSIGNF
+SIGNATURE_CHECK (GNULIB_NAMESPACE::copysignf, float, (float, float));
+#endif
 #if GNULIB_TEST_COPYSIGN
 SIGNATURE_CHECK (GNULIB_NAMESPACE::copysign, double, (double, double));
 #endif