]> Savannah Git Hosting - gnulib.git/commitdiff
sinf: Avoid redefinition error on MSVC.
authorBruno Haible <bruno@clisp.org>
Sat, 17 Dec 2016 19:38:33 +0000 (20:38 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 17 Dec 2016 22:09:13 +0000 (23:09 +0100)
* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_SINF.
* m4/sinf.m4 (gl_FUNC_SINF): Set REPLACE_SINF to 1 if the function
may be defined as an inline function.
* modules/math (Makefile.am): Substitute REPLACE_SINF.
* lib/math.in.h (sinf): Override if REPLACE_SINF is 1.

ChangeLog
lib/math.in.h
m4/math_h.m4
m4/sinf.m4
modules/math

index 6f95707a7199672145f0f6ce25c2b3f080e8f414..fd9cba0712c7914c7002dbd9e4200d4e17579767 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-12-17  Bruno Haible  <bruno@clisp.org>
+
+       sinf: Avoid redefinition error on MSVC.
+       * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_SINF.
+       * m4/sinf.m4 (gl_FUNC_SINF): Set REPLACE_SINF to 1 if the function
+       may be defined as an inline function.
+       * modules/math (Makefile.am): Substitute REPLACE_SINF.
+       * lib/math.in.h (sinf): Override if REPLACE_SINF is 1.
+
 2016-12-17  Bruno Haible  <bruno@clisp.org>
 
        logf: Avoid redefinition error on MSVC.
index cc76a64ef004bd0648ee7dc72c02c3ddbb34194f..34730f71472eab004ee943ee4be86ce0420cf311 100644 (file)
@@ -1890,11 +1890,20 @@ _GL_WARN_ON_USE (roundl, "roundl is unportable - "
 
 
 #if @GNULIB_SINF@
-# if !@HAVE_SINF@
-#  undef sinf
+# if @REPLACE_SINF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef sinf
+#   define sinf rpl_sinf
+#  endif
+_GL_FUNCDECL_RPL (sinf, float, (float x));
+_GL_CXXALIAS_RPL (sinf, float, (float x));
+# else
+#  if !@HAVE_SINF@
+ #  undef sinf
 _GL_FUNCDECL_SYS (sinf, float, (float x));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (sinf, float, (float x));
+# endif
 _GL_CXXALIASWARN (sinf);
 #elif defined GNULIB_POSIXCHECK
 # undef sinf
index ac7a72d78d218a93df35b83cc68f1948cacbc3c5..538a65008c9540f33d86c9fc444c66e86012773b 100644 (file)
@@ -322,6 +322,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   REPLACE_ROUNDL=0;            AC_SUBST([REPLACE_ROUNDL])
   REPLACE_SIGNBIT=0;           AC_SUBST([REPLACE_SIGNBIT])
   REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC])
+  REPLACE_SINF=0;              AC_SUBST([REPLACE_SINF])
   REPLACE_SQRTL=0;             AC_SUBST([REPLACE_SQRTL])
   REPLACE_TRUNC=0;             AC_SUBST([REPLACE_TRUNC])
   REPLACE_TRUNCF=0;            AC_SUBST([REPLACE_TRUNCF])
index b40f97db2bc67903d6140f41804cd5b0d4c77751..5429e92f4e8209d8ace4ea9f4095d05ffdf0a5ca 100644 (file)
@@ -1,4 +1,4 @@
-# sinf.m4 serial 2
+# sinf.m4 serial 3
 dnl Copyright (C) 2011-2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -22,6 +22,10 @@ AC_DEFUN([gl_FUNC_SINF],
     SINF_LIBM="$SIN_LIBM"
   else
     HAVE_SINF=0
+    dnl If the function is declared but does not appear to exist, it may be
+    dnl defined as an inline function. In order to avoid a conflict, we have
+    dnl to define rpl_sinf, not sinf.
+    AC_CHECK_DECLS([sinf], [REPLACE_SINF=1], , [[#include <math.h>]])
     SINF_LIBM="$SIN_LIBM"
   fi
   AC_SUBST([SINF_LIBM])
index 497c692d24ebb216c09b19208f51d527e1fd1406..d4e2486a801e7019d75f290ca771cf2f8e818f6e 100644 (file)
@@ -292,6 +292,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \
              -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \
              -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \
+             -e 's|@''REPLACE_SINF''@|$(REPLACE_SINF)|g' \
              -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \
              -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \
              -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \