summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--lib/math.in.h15
-rw-r--r--m4/atan2f.m46
-rw-r--r--m4/math_h.m41
-rw-r--r--modules/math1
5 files changed, 28 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b03ae87bb1..afac64d04b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2016-12-17 Bruno Haible <bruno@clisp.org>
+ 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
+ may be defined as an inline function.
+ * modules/math (Makefile.am): Substitute REPLACE_ATAN2F.
+ * lib/math.in.h (atan2f): Override if REPLACE_ATAN2F is 1.
+
+2016-12-17 Bruno Haible <bruno@clisp.org>
+
atanf: Avoid redefinition error on MSVC.
* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_ATANF.
* m4/atanf.m4 (gl_FUNC_ATANF): Set REPLACE_ATANF to 1 if the function
diff --git a/lib/math.in.h b/lib/math.in.h
index 04bbd4ef7e..9d28a4323e 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -332,11 +332,20 @@ _GL_WARN_ON_USE (atanl, "atanl is unportable - "
#if @GNULIB_ATAN2F@
-# if !@HAVE_ATAN2F@
-# undef atan2f
+# if @REPLACE_ATAN2F@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef atan2f
+# define atan2f rpl_atan2f
+# endif
+_GL_FUNCDECL_RPL (atan2f, float, (float y, float x));
+_GL_CXXALIAS_RPL (atan2f, float, (float y, float x));
+# else
+# if !@HAVE_ATAN2F@
+# undef atan2f
_GL_FUNCDECL_SYS (atan2f, float, (float y, float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (atan2f, float, (float y, float x));
+# endif
_GL_CXXALIASWARN (atan2f);
#elif defined GNULIB_POSIXCHECK
# undef atan2f
diff --git a/m4/atan2f.m4 b/m4/atan2f.m4
index c29f4cb469..2788bf8e7b 100644
--- a/m4/atan2f.m4
+++ b/m4/atan2f.m4
@@ -1,4 +1,4 @@
-# atan2f.m4 serial 2
+# atan2f.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_ATAN2F],
ATAN2F_LIBM="$ATAN2_LIBM"
else
HAVE_ATAN2F=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_atan2f, not atan2f.
+ AC_CHECK_DECLS([atan2f], [REPLACE_ATAN2F=1], , [[#include <math.h>]])
ATAN2F_LIBM="$ATAN2_LIBM"
fi
AC_SUBST([ATAN2F_LIBM])
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index 7b2aa5ad35..ec88b2a514 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -259,6 +259,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
REPLACE_ACOSF=0; AC_SUBST([REPLACE_ACOSF])
REPLACE_ASINF=0; AC_SUBST([REPLACE_ASINF])
REPLACE_ATANF=0; AC_SUBST([REPLACE_ATANF])
+ REPLACE_ATAN2F=0; AC_SUBST([REPLACE_ATAN2F])
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 bc8bc7b03f..a9de89838e 100644
--- a/modules/math
+++ b/modules/math
@@ -228,6 +228,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
sed -e 's|@''REPLACE_ACOSF''@|$(REPLACE_ACOSF)|g' \
-e 's|@''REPLACE_ASINF''@|$(REPLACE_ASINF)|g' \
-e 's|@''REPLACE_ATANF''@|$(REPLACE_ATANF)|g' \
+ -e 's|@''REPLACE_ATAN2F''@|$(REPLACE_ATAN2F)|g' \
-e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \
-e 's|@''REPLACE_CBRTL''@|$(REPLACE_CBRTL)|g' \
-e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \