Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(161691)

Unified Diff: Modules/mathmodule.c

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Modules/makesetup ('k') | Modules/posixmodule.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Modules/mathmodule.c Tue Mar 01 10:26:10 2016 +0200
+++ b/Modules/mathmodule.c Wed Mar 02 00:01:35 2016 +0000
@@ -50,16 +50,20 @@ raised for division by zero and mod by z
the standard recommends raising 'overflow', Python should raise an
OverflowError. In all other circumstances a value should be
returned.
*/
#include "Python.h"
#include "_math.h"
+#ifdef __APPLE__
+# include "TargetConditionals.h"
+#endif /* __APPLE__ */
+
/*
sin(pi*x), giving accurate results for all finite x (especially x
integral or close to an integer). This is here for use in the
reflection formula for the gamma function. It conforms to IEEE
754-2008 for finite arguments, but not for infinities or nans.
*/
static const double pi = 3.141592653589793238462643383279502884197;
@@ -1804,16 +1808,26 @@ math_hypot(PyObject *self, PyObject *arg
y = PyFloat_AsDouble(oy);
if ((x == -1.0 || y == -1.0) && PyErr_Occurred())
return NULL;
/* hypot(x, +/-Inf) returns Inf, even if x is a NaN. */
if (Py_IS_INFINITY(x))
return PyFloat_FromDouble(fabs(x));
if (Py_IS_INFINITY(y))
return PyFloat_FromDouble(fabs(y));
+#if TARGET_OS_IPHONE
+ /* hypot(x, +/-NaN) returns NaN.
+ Most libc implementations get this right, but for some reason,
+ the iOS device implementation doesn't.
+ */
+ if (Py_IS_NAN(x))
+ return PyFloat_FromDouble(fabs(x));
+ if (Py_IS_NAN(y))
+ return PyFloat_FromDouble(fabs(y));
+#endif
errno = 0;
PyFPE_START_PROTECT("in math_hypot", return 0);
r = hypot(x, y);
PyFPE_END_PROTECT(r);
if (Py_IS_NAN(r)) {
if (!Py_IS_NAN(x) && !Py_IS_NAN(y))
errno = EDOM;
else
« no previous file with comments | « Modules/makesetup ('k') | Modules/posixmodule.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+