>From 51150279ad36c1b1bf180ff9e81542ebf192500e Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 17 Dec 2016 20:51:33 +0100 Subject: [PATCH 19/20] tanhf: Avoid redefinition error on MSVC. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_TANHF. * m4/tanhf.m4 (gl_FUNC_TANHF): Set REPLACE_TANHF to 1 if the function may be defined as an inline function. * modules/math (Makefile.am): Substitute REPLACE_TANHF. * lib/math.in.h (tanhf): Override if REPLACE_TANHF is 1. --- ChangeLog | 9 +++++++++ lib/math.in.h | 15 ++++++++++++--- m4/math_h.m4 | 1 + m4/tanhf.m4 | 6 +++++- modules/math | 1 + 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f16b24e..7870489 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2016-12-17 Bruno Haible + tanhf: Avoid redefinition error on MSVC. + * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_TANHF. + * m4/tanhf.m4 (gl_FUNC_TANHF): Set REPLACE_TANHF to 1 if the function + may be defined as an inline function. + * modules/math (Makefile.am): Substitute REPLACE_TANHF. + * lib/math.in.h (tanhf): Override if REPLACE_TANHF is 1. + +2016-12-17 Bruno Haible + tanf: Avoid redefinition error on MSVC. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_TANF. * m4/tanf.m4 (gl_FUNC_TANF): Set REPLACE_TANF to 1 if the function diff --git a/lib/math.in.h b/lib/math.in.h index 44b4e88..494432f 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -2044,11 +2044,20 @@ _GL_WARN_ON_USE (tanl, "tanl is unportable - " #if @GNULIB_TANHF@ -# if address@hidden@ -# undef tanhf +# if @REPLACE_TANHF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef tanhf +# define tanhf rpl_tanhf +# endif +_GL_FUNCDECL_RPL (tanhf, float, (float x)); +_GL_CXXALIAS_RPL (tanhf, float, (float x)); +# else +# if address@hidden@ +# undef tanhf _GL_FUNCDECL_SYS (tanhf, float, (float x)); -# endif +# endif _GL_CXXALIAS_SYS (tanhf, float, (float x)); +# endif _GL_CXXALIASWARN (tanhf); #elif defined GNULIB_POSIXCHECK # undef tanhf diff --git a/m4/math_h.m4 b/m4/math_h.m4 index 01e23ad..d427b9b 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -327,6 +327,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], REPLACE_SQRTF=0; AC_SUBST([REPLACE_SQRTF]) REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL]) REPLACE_TANF=0; AC_SUBST([REPLACE_TANF]) + REPLACE_TANHF=0; AC_SUBST([REPLACE_TANHF]) REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC]) REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF]) REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL]) diff --git a/m4/tanhf.m4 b/m4/tanhf.m4 index 010e991..b591c41 100644 --- a/m4/tanhf.m4 +++ b/m4/tanhf.m4 @@ -1,4 +1,4 @@ -# tanhf.m4 serial 2 +# tanhf.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_TANHF], TANHF_LIBM="$TANH_LIBM" else HAVE_TANHF=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_tanhf, not tanhf. + AC_CHECK_DECLS([tanhf], [REPLACE_TANHF=1], , [[#include ]]) TANHF_LIBM="$TANH_LIBM" fi AC_SUBST([TANHF_LIBM]) diff --git a/modules/math b/modules/math index 317e688..2f553ba 100644 --- a/modules/math +++ b/modules/math @@ -297,6 +297,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''REPLACE_SQRTF''@|$(REPLACE_SQRTF)|g' \ -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \ -e 's|@''REPLACE_TANF''@|$(REPLACE_TANF)|g' \ + -e 's|@''REPLACE_TANHF''@|$(REPLACE_TANHF)|g' \ -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \ -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \ -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \ -- 2.6.4