mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
bpo-45440: Remove pymath.c fallbacks (GH-28977)
Remove fallbacks for missing round(), copysign() and hypot() in Python/pymath.c. Python now requires these functions to build. These fallbacks were needed on Visual Studio 2012 and older. They are no longer needed since Visual Stuido 2013. Python is now built with Visual Studio 2017 or newer since Python 3.6.
This commit is contained in:
parent
51f8196d05
commit
00ffc4513d
8 changed files with 9 additions and 90 deletions
|
@ -17,51 +17,3 @@ void _Py_set_387controlword(unsigned short cw) {
|
|||
__asm__ __volatile__ ("fldcw %0" : : "m" (cw));
|
||||
}
|
||||
#endif // HAVE_GCC_ASM_FOR_X87
|
||||
|
||||
|
||||
#ifndef HAVE_HYPOT
|
||||
double hypot(double x, double y)
|
||||
{
|
||||
double yx;
|
||||
|
||||
x = fabs(x);
|
||||
y = fabs(y);
|
||||
if (x < y) {
|
||||
double temp = x;
|
||||
x = y;
|
||||
y = temp;
|
||||
}
|
||||
if (x == 0.)
|
||||
return 0.;
|
||||
else {
|
||||
yx = y/x;
|
||||
return x*sqrt(1.+yx*yx);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_HYPOT */
|
||||
|
||||
#ifndef HAVE_COPYSIGN
|
||||
double
|
||||
copysign(double x, double y)
|
||||
{
|
||||
/* use atan2 to distinguish -0. from 0. */
|
||||
if (y > 0. || (y == 0. && atan2(y, -1.) > 0.)) {
|
||||
return fabs(x);
|
||||
} else {
|
||||
return -fabs(x);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_COPYSIGN */
|
||||
|
||||
#ifndef HAVE_ROUND
|
||||
double
|
||||
round(double x)
|
||||
{
|
||||
double absx, y;
|
||||
absx = fabs(x);
|
||||
y = floor(absx);
|
||||
if (absx - y >= 0.5)
|
||||
y += 1.0;
|
||||
return copysign(y, x);
|
||||
}
|
||||
#endif /* HAVE_ROUND */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue