>From 9ef2e6d2053ea4d0068ecc1761f2ec81d4971790 Mon Sep 17 00:00:00 2001 From: Bruno Haible
Date: Sat, 17 Dec 2016 20:48:34 +0100 Subject: [PATCH 18/20] 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 may be defined as an inline function. * modules/math (Makefile.am): Substitute REPLACE_TANF. * lib/math.in.h (tanf): Override if REPLACE_TANF is 1. --- ChangeLog | 9 +++++++++ lib/math.in.h | 15 ++++++++++++--- m4/math_h.m4 | 1 + m4/tanf.m4 | 6 +++++- modules/math | 1 + 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a6593b1..f16b24e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 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 + may be defined as an inline function. + * modules/math (Makefile.am): Substitute REPLACE_TANF. + * lib/math.in.h (tanf): Override if REPLACE_TANF is 1. + +2016-12-17 Bruno Haible + sqrtf: Avoid redefinition error on MSVC. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_SQRTF. * m4/sqrtf.m4 (gl_FUNC_SQRTF): Set REPLACE_SQRTF to 1 if the function diff --git a/lib/math.in.h b/lib/math.in.h index 842a636..44b4e88 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -2004,11 +2004,20 @@ _GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - " #if @GNULIB_TANF@ -# if address@hidden@ -# undef tanf +# if @REPLACE_TANF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef tanf +# define tanf rpl_tanf +# endif +_GL_FUNCDECL_RPL (tanf, float, (float x)); +_GL_CXXALIAS_RPL (tanf, float, (float x)); +# else +# if address@hidden@ +# undef tanf _GL_FUNCDECL_SYS (tanf, float, (float x)); -# endif +# endif _GL_CXXALIAS_SYS (tanf, float, (float x)); +# endif _GL_CXXALIASWARN (tanf); #elif defined GNULIB_POSIXCHECK # undef tanf diff --git a/m4/math_h.m4 b/m4/math_h.m4 index cb41593..01e23ad 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -326,6 +326,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], REPLACE_SINHF=0; AC_SUBST([REPLACE_SINHF]) REPLACE_SQRTF=0; AC_SUBST([REPLACE_SQRTF]) REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL]) + REPLACE_TANF=0; AC_SUBST([REPLACE_TANF]) 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/tanf.m4 b/m4/tanf.m4 index fe48da5..92a5f23 100644 --- a/m4/tanf.m4 +++ b/m4/tanf.m4 @@ -1,4 +1,4 @@ -# tanf.m4 serial 2 +# tanf.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_TANF], TANF_LIBM="$TAN_LIBM" else HAVE_TANF=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_tanf, not tanf. + AC_CHECK_DECLS([tanf], [REPLACE_TANF=1], , [[#include