>From c3cb8a26341933b414e53e79457bb9906d07e9f3 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 17 Dec 2016 19:08:14 +0100 Subject: [PATCH 01/20] acosf: Avoid redefinition error on MSVC. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_ACOSF. * m4/acosf.m4 (gl_FUNC_ACOSF): Set REPLACE_ACOSF to 1 if the function may be defined as an inline function. * modules/math (Makefile.am): Substitute REPLACE_ACOSF. * lib/math.in.h (acosf): Override if REPLACE_ACOSF is 1. --- ChangeLog | 9 +++++++++ lib/math.in.h | 15 ++++++++++++--- m4/acosf.m4 | 6 +++++- m4/math_h.m4 | 3 ++- modules/math | 3 ++- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1ced537..9ab54ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2016-12-17 Bruno Haible + acosf: Avoid redefinition error on MSVC. + * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_ACOSF. + * m4/acosf.m4 (gl_FUNC_ACOSF): Set REPLACE_ACOSF to 1 if the function + may be defined as an inline function. + * modules/math (Makefile.am): Substitute REPLACE_ACOSF. + * lib/math.in.h (acosf): Override if REPLACE_ACOSF is 1. + +2016-12-17 Bruno Haible + Avoid redefinition errors on MSVC. * m4/snprintf.m4 (gl_REPLACE_SNPRINTF): Set REPLACE_SNPRINTF 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 e1dc970..f46d2df 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -212,11 +212,20 @@ _NaN () #if @GNULIB_ACOSF@ -# if address@hidden@ -# undef acosf +# if @REPLACE_ACOSF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef acosf +# define acosf rpl_acosf +# endif +_GL_FUNCDECL_RPL (acosf, float, (float x)); +_GL_CXXALIAS_RPL (acosf, float, (float x)); +# else +# if address@hidden@ +# undef acosf _GL_FUNCDECL_SYS (acosf, float, (float x)); -# endif +# endif _GL_CXXALIAS_SYS (acosf, float, (float x)); +# endif _GL_CXXALIASWARN (acosf); #elif defined GNULIB_POSIXCHECK # undef acosf diff --git a/m4/acosf.m4 b/m4/acosf.m4 index b5789d0..55bdd56 100644 --- a/m4/acosf.m4 +++ b/m4/acosf.m4 @@ -1,4 +1,4 @@ -# acosf.m4 serial 2 +# acosf.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_ACOSF], ACOSF_LIBM="$ACOS_LIBM" else HAVE_ACOSF=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_acosf, not acosf. + AC_CHECK_DECLS([acosf], [REPLACE_ACOSF=1], , [[#include ]]) ACOSF_LIBM="$ACOS_LIBM" fi AC_SUBST([ACOSF_LIBM]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 index 35d07ee..18d2ac8 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 114 +# math_h.m4 serial 115 dnl Copyright (C) 2007-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, @@ -256,6 +256,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC]) HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF]) HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL]) + REPLACE_ACOSF=0; AC_SUBST([REPLACE_ACOSF]) REPLACE_CBRTF=0; AC_SUBST([REPLACE_CBRTF]) REPLACE_CBRTL=0; AC_SUBST([REPLACE_CBRTL]) REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL]) diff --git a/modules/math b/modules/math index 6f924fd..0aa326b 100644 --- a/modules/math +++ b/modules/math @@ -225,7 +225,8 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \ | \ - sed -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \ + sed -e 's|@''REPLACE_ACOSF''@|$(REPLACE_ACOSF)|g' \ + -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \ -e 's|@''REPLACE_CBRTL''@|$(REPLACE_CBRTL)|g' \ -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \ -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ -- 2.6.4