]> Savannah Git Hosting - gnulib.git/commitdiff
New module 'copysignf'.
authorBruno Haible <bruno@clisp.org>
Sun, 9 Oct 2011 13:42:35 +0000 (15:42 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 9 Oct 2011 13:42:35 +0000 (15:42 +0200)
* 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.

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

index be2b20bd7c7802f6a8dadc00e1ae0a55f911f05f..1ff29a68306a799809702a58c6d7d504e702ccf7 100644 (file)
--- 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.
index 01f2762c343aef851269e5d8fbd0b5ccb77d611e..5c3154f695cb33392279ee853758e4aaf3a8b00a 100644 (file)
@@ -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
+@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
-@item
-This function is missing on some platforms:
-Minix 3.1.8, AIX 5.1, IRIX 6.5, Solaris 9, MSVC 9.
 @end itemize
diff --git a/lib/copysignf.c b/lib/copysignf.c
new file mode 100644 (file)
index 0000000..82409d4
--- /dev/null
@@ -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);
+}
index e14ea15b987513a30031a41e8f6fc335d6566d59..37f9a2fb882f6a4abcb9c731221360c0aa85890f 100644 (file)
@@ -274,6 +274,35 @@ _GL_WARN_ON_USE (ceill, "ceill is unportable - "
 #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 @@ _GL_WARN_ON_USE (coshf, "coshf is unportable - "
 #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
diff --git a/m4/copysignf.m4 b/m4/copysignf.m4
new file mode 100644 (file)
index 0000000..00c1fe1
--- /dev/null
@@ -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])
+])
index 240415325916b6d5cc873f05b7a9e3ffa88ed3e0..4d5105b1231d31578c90922da02da9d29982a48a 100644 (file)
@@ -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 @@ AC_DEFUN([gl_MATH_H],
   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_MODULE_INDICATOR],
 
 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 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   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])
diff --git a/modules/copysignf b/modules/copysignf
new file mode 100644 (file)
index 0000000..a446046
--- /dev/null
@@ -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
index a76abcfbd918d9b66a4e9b0483ff48d63d1b9ffc..c0c3a88e772ec3d3dbdff470c98e0025053a4ae7 100644 (file)
@@ -39,6 +39,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -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 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -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' \
index 7ae1ea190f8067245d7682ac200ee65d9b215600..b519992f334728a9ad15704abd4c93856d7230a5 100644 (file)
@@ -41,6 +41,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::atan2f, float, (float, float));
 #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