>From 9113a6db3f4efd150bfa77188e1277ff83aadc1b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 17 Dec 2016 19:31:58 +0100 Subject: [PATCH 05/20] cosf: Avoid redefinition error on MSVC. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_COSF. * m4/cosf.m4 (gl_FUNC_COSF): Set REPLACE_COSF to 1 if the function may be defined as an inline function. * modules/math (Makefile.am): Substitute REPLACE_COSF. * lib/math.in.h (cosf): Override if REPLACE_COSF is 1. --- ChangeLog | 9 +++++++++ lib/math.in.h | 15 ++++++++++++--- m4/cosf.m4 | 6 +++++- m4/math_h.m4 | 1 + modules/math | 1 + 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index afac64d..b802d75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2016-12-17 Bruno Haible + cosf: Avoid redefinition error on MSVC. + * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_COSF. + * m4/cosf.m4 (gl_FUNC_COSF): Set REPLACE_COSF to 1 if the function + may be defined as an inline function. + * modules/math (Makefile.am): Substitute REPLACE_COSF. + * lib/math.in.h (cosf): Override if REPLACE_COSF is 1. + +2016-12-17 Bruno Haible + atan2f: Avoid redefinition error on MSVC. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_ATAN2F. * m4/atan2f.m4 (gl_FUNC_ATAN2F): Set REPLACE_ATAN2F to 1 if the function diff --git a/lib/math.in.h b/lib/math.in.h index 9d28a43..6065cfa 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -524,11 +524,20 @@ _GL_WARN_ON_USE (copysign, "copysignl is unportable - " #if @GNULIB_COSF@ -# if address@hidden@ -# undef cosf +# if @REPLACE_COSF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef cosf +# define cosf rpl_cosf +# endif +_GL_FUNCDECL_RPL (cosf, float, (float x)); +_GL_CXXALIAS_RPL (cosf, float, (float x)); +# else +# if address@hidden@ +# undef cosf _GL_FUNCDECL_SYS (cosf, float, (float x)); -# endif +# endif _GL_CXXALIAS_SYS (cosf, float, (float x)); +# endif _GL_CXXALIASWARN (cosf); #elif defined GNULIB_POSIXCHECK # undef cosf diff --git a/m4/cosf.m4 b/m4/cosf.m4 index 8315aa0..757d9b7 100644 --- a/m4/cosf.m4 +++ b/m4/cosf.m4 @@ -1,4 +1,4 @@ -# cosf.m4 serial 2 +# cosf.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_COSF], COSF_LIBM="$COS_LIBM" else HAVE_COSF=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_cosf, not cosf. + AC_CHECK_DECLS([cosf], [REPLACE_COSF=1], , [[#include ]]) COSF_LIBM="$COS_LIBM" fi AC_SUBST([COSF_LIBM]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 index ec88b2a..89d3ab2 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -265,6 +265,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL]) REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF]) REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL]) + REPLACE_COSF=0; AC_SUBST([REPLACE_COSF]) REPLACE_EXPM1=0; AC_SUBST([REPLACE_EXPM1]) REPLACE_EXPM1F=0; AC_SUBST([REPLACE_EXPM1F]) REPLACE_EXP2=0; AC_SUBST([REPLACE_EXP2]) diff --git a/modules/math b/modules/math index a9de898..abe1db4 100644 --- a/modules/math +++ b/modules/math @@ -234,6 +234,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \ -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \ + -e 's|@''REPLACE_COSF''@|$(REPLACE_COSF)|g' \ -e 's|@''REPLACE_EXPM1''@|$(REPLACE_EXPM1)|g' \ -e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \ -e 's|@''REPLACE_EXP2''@|$(REPLACE_EXP2)|g' \ -- 2.6.4