>From a8cff6cb02078518e50965da9e165d2d5ad495d1 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 17 Dec 2016 20:38:33 +0100 Subject: [PATCH 15/20] 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. --- ChangeLog | 9 +++++++++ lib/math.in.h | 15 ++++++++++++--- m4/math_h.m4 | 1 + m4/sinf.m4 | 6 +++++- modules/math | 1 + 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f95707..fd9cba0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2016-12-17 Bruno Haible + 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 + logf: Avoid redefinition error on MSVC. * m4/logf.m4 (gl_FUNC_LOGF): Set REPLACE_LOGF to 1 if the function may be defined as an inline function. diff --git a/lib/math.in.h b/lib/math.in.h index cc76a64..34730f7 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -1890,11 +1890,20 @@ _GL_WARN_ON_USE (roundl, "roundl is unportable - " #if @GNULIB_SINF@ -# if address@hidden@ -# 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 address@hidden@ + # 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 diff --git a/m4/math_h.m4 b/m4/math_h.m4 index ac7a72d..538a650 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -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]) diff --git a/m4/sinf.m4 b/m4/sinf.m4 index b40f97d..5429e92 100644 --- a/m4/sinf.m4 +++ b/m4/sinf.m4 @@ -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 ]]) SINF_LIBM="$SIN_LIBM" fi AC_SUBST([SINF_LIBM]) diff --git a/modules/math b/modules/math index 497c692..d4e2486 100644 --- a/modules/math +++ b/modules/math @@ -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' \ -- 2.6.4