summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_pymath.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-10-11 22:12:00 (GMT)
committerGitHub <noreply@github.com>2021-10-11 22:12:00 (GMT)
commit61190e092b8258ede92ac543bb39bad0f7168104 (patch)
treeebebc990118186a36116fe6026fe5a03d3594e8c /Include/internal/pycore_pymath.h
parent1f316ea3b4fa319eec4f375fb683467b424c964e (diff)
downloadcpython-61190e092b8258ede92ac543bb39bad0f7168104.zip
cpython-61190e092b8258ede92ac543bb39bad0f7168104.tar.gz
cpython-61190e092b8258ede92ac543bb39bad0f7168104.tar.bz2
bpo-45412: Move copysign() define to pycore_pymath.h (GH-28889)
Move definitions of copysign(), round(), hypot(), fmod(), etc. from pymath.h to pycore_pymath.h. These functions are not exported by libpython and so must not be part of the C API.
Diffstat (limited to 'Include/internal/pycore_pymath.h')
-rw-r--r--Include/internal/pycore_pymath.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/Include/internal/pycore_pymath.h b/Include/internal/pycore_pymath.h
index b1a2004..38f76d0 100644
--- a/Include/internal/pycore_pymath.h
+++ b/Include/internal/pycore_pymath.h
@@ -8,6 +8,34 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif
+
+// Python provides implementations for copysign(), round() and hypot() in
+// Python/pymath.c just in case your math library doesn't provide the
+// functions.
+//
+// Note: PC/pyconfig.h defines copysign as _copysign
+#ifndef HAVE_COPYSIGN
+extern double copysign(double, double);
+#endif
+
+#ifndef HAVE_ROUND
+extern double round(double);
+#endif
+
+#ifndef HAVE_HYPOT
+extern double hypot(double, double);
+#endif
+
+// Extra declarations
+#if !defined(_MSC_VER) && !defined(__STDC__)
+extern double fmod (double, double);
+extern double frexp (double, int *);
+extern double ldexp (double, int);
+extern double modf (double, double *);
+extern double pow(double, double);
+#endif // !defined(_MSC_VER) && !defined(__STDC__)
+
+
/* _Py_ADJUST_ERANGE1(x)
* _Py_ADJUST_ERANGE2(x, y)
* Set errno to 0 before calling a libm function, and invoke one of these