mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Perform build and magnum tuning
Building o//third_party/python now takes 5 seconds on my PC This change works towards modifying Python to use runtime dispatching when appropriate. For example, when loading the magnums in the socket module, it's a good idea to check if the magnum is zero, because that means the local system platform doesn't support it.
This commit is contained in:
parent
ee7e296339
commit
d26d7ae0e4
1028 changed files with 6576 additions and 172777 deletions
54
third_party/python/Python/pymath.c
vendored
54
third_party/python/Python/pymath.c
vendored
|
@ -1,4 +1,5 @@
|
|||
#include "Python.h"
|
||||
/* clang-format off */
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
#ifdef X87_DOUBLE_ROUNDING
|
||||
/* On x86 platforms using an x87 FPU, this function is called from the
|
||||
|
@ -14,7 +15,6 @@ double _Py_force_double(double x)
|
|||
#endif
|
||||
|
||||
#ifdef HAVE_GCC_ASM_FOR_X87
|
||||
|
||||
/* inline assembly for getting and setting the 387 FPU control word on
|
||||
gcc/x86 */
|
||||
#ifdef _Py_MEMORY_SANITIZER
|
||||
|
@ -25,57 +25,7 @@ unsigned short _Py_get_387controlword(void) {
|
|||
__asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
|
||||
return cw;
|
||||
}
|
||||
|
||||
void _Py_set_387controlword(unsigned short cw) {
|
||||
__asm__ __volatile__ ("fldcw %0" : : "m" (cw));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#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