| author | |
| committer | |
| log | 02b221051a180a252bb3a092b1cc054469c6fa15 |
| tree | 5105489a81f50526e6cbff3232541769dcf949b6 |
| parent | b483c796c66e3a415a7590bfe62f316fa8fa70e6 |
We were missing some math functions. After this enhancement I verified
that I was able to cross-compile ninja.exe for aarch64-windows and
produce a viable binary.32 files changed, 780 insertions(+), 5 deletions(-)
lib/libc/mingw/math/arm-common/acosh.c created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | double acosh(double x) | ||
| 10 | { | ||
| 11 | if (x < 1.0) | ||
| 12 | return NAN; | ||
| 13 | if (isinf(x*x)) | ||
| 14 | return log(2) + log(x); | ||
| 15 | return log(x + sqrt(x*x - 1)); | ||
| 16 | } | ||
lib/libc/mingw/math/arm-common/acoshf.c created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | float acoshf(float x) | ||
| 10 | { | ||
| 11 | if (x < 1.0) | ||
| 12 | return NAN; | ||
| 13 | if (isinf(x*x)) | ||
| 14 | return logf(2) + logf(x); | ||
| 15 | return logf(x + sqrtf(x*x - 1)); | ||
| 16 | } | ||
lib/libc/mingw/math/arm-common/acoshl.c created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | long double acoshl(long double x) | ||
| 10 | { | ||
| 11 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 12 | return acosh(x); | ||
| 13 | #else | ||
| 14 | #error Not supported on your platform yet | ||
| 15 | #endif | ||
| 16 | } | ||
lib/libc/mingw/math/arm-common/asinh.c created+18| ... | @@ -0,0 +1,18 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | double asinh(double x) | ||
| 10 | { | ||
| 11 | if (isinf(x*x + 1)) { | ||
| 12 | if (x > 0) | ||
| 13 | return log(2) + log(x); | ||
| 14 | else | ||
| 15 | return -log(2) - log(-x); | ||
| 16 | } | ||
| 17 | return log(x + sqrt(x*x + 1)); | ||
| 18 | } | ||
lib/libc/mingw/math/arm-common/asinhf.c created+18| ... | @@ -0,0 +1,18 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | float asinhf(float x) | ||
| 10 | { | ||
| 11 | if (isinf(x*x + 1)) { | ||
| 12 | if (x > 0) | ||
| 13 | return logf(2) + logf(x); | ||
| 14 | else | ||
| 15 | return -logf(2) - logf(-x); | ||
| 16 | } | ||
| 17 | return logf(x + sqrtf(x*x + 1)); | ||
| 18 | } | ||
lib/libc/mingw/math/arm-common/asinhl.c created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | long double asinhl(long double x) | ||
| 10 | { | ||
| 11 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 12 | return asinh(x); | ||
| 13 | #else | ||
| 14 | #error Not supported on your platform yet | ||
| 15 | #endif | ||
| 16 | } | ||
lib/libc/mingw/math/arm-common/atanh.c created+17| ... | @@ -0,0 +1,17 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | double atanh(double x) | ||
| 10 | { | ||
| 11 | if (x > 1 || x < -1) | ||
| 12 | return NAN; | ||
| 13 | if (-1e-6 < x && x < 1e-6) | ||
| 14 | return x + x*x*x/3; | ||
| 15 | else | ||
| 16 | return (log(1 + x) - log(1 - x)) / 2; | ||
| 17 | } | ||
lib/libc/mingw/math/arm-common/atanhf.c created+17| ... | @@ -0,0 +1,17 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | float atanhf(float x) | ||
| 10 | { | ||
| 11 | if (x > 1 || x < -1) | ||
| 12 | return NAN; | ||
| 13 | if (-1e-6 < x && x < 1e-6) | ||
| 14 | return x + x*x*x/3; | ||
| 15 | else | ||
| 16 | return (logf(1 + x) - logf(1 - x)) / 2; | ||
| 17 | } | ||
lib/libc/mingw/math/arm-common/atanhl.c created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | long double atanhl(long double x) | ||
| 10 | { | ||
| 11 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 12 | return atanh(x); | ||
| 13 | #else | ||
| 14 | #error Not supported on your platform yet | ||
| 15 | #endif | ||
| 16 | } | ||
lib/libc/mingw/math/arm-common/copysignl.c created+11| ... | @@ -0,0 +1,11 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | #include <math.h> | ||
| 7 | |||
| 8 | long double copysignl(long double x, long double y) | ||
| 9 | { | ||
| 10 | return copysign(x, y); | ||
| 11 | } | ||
lib/libc/mingw/math/arm-common/expm1.c created+12| ... | @@ -0,0 +1,12 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | double expm1(double x) | ||
| 10 | { | ||
| 11 | return exp(x) - 1.0; | ||
| 12 | } | ||
lib/libc/mingw/math/arm-common/expm1f.c created+15| ... | @@ -0,0 +1,15 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | float expm1f(float x) | ||
| 10 | { | ||
| 11 | // Intentionally using double version of exp() here in the float version of | ||
| 12 | // expm1, to preserve as much accuracy as possible in the intermediate | ||
| 13 | // result. | ||
| 14 | return exp(x) - 1.0; | ||
| 15 | } | ||
lib/libc/mingw/math/arm-common/expm1l.c created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | long double expm1l(long double x) | ||
| 10 | { | ||
| 11 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 12 | return expm1(x); | ||
| 13 | #else | ||
| 14 | #error Not supported on your platform yet | ||
| 15 | #endif | ||
| 16 | } | ||
lib/libc/mingw/math/arm-common/ilogb.c created+19| ... | @@ -0,0 +1,19 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | #include <limits.h> | ||
| 9 | |||
| 10 | int ilogb(double x) | ||
| 11 | { | ||
| 12 | if (x == 0.0) | ||
| 13 | return FP_ILOGB0; | ||
| 14 | if (isinf(x)) | ||
| 15 | return INT_MAX; | ||
| 16 | if (isnan(x)) | ||
| 17 | return FP_ILOGBNAN; | ||
| 18 | return (int) logb(x); | ||
| 19 | } | ||
lib/libc/mingw/math/arm-common/ilogbf.c created+19| ... | @@ -0,0 +1,19 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | #include <limits.h> | ||
| 9 | |||
| 10 | int ilogbf(float x) | ||
| 11 | { | ||
| 12 | if (x == 0.0) | ||
| 13 | return FP_ILOGB0; | ||
| 14 | if (isinf(x)) | ||
| 15 | return INT_MAX; | ||
| 16 | if (isnan(x)) | ||
| 17 | return FP_ILOGBNAN; | ||
| 18 | return (int) logbf(x); | ||
| 19 | } | ||
lib/libc/mingw/math/arm-common/ilogbl.c created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | int ilogbl(long double x) | ||
| 10 | { | ||
| 11 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 12 | return ilogb(x); | ||
| 13 | #else | ||
| 14 | #error Not supported on your platform yet | ||
| 15 | #endif | ||
| 16 | } | ||
lib/libc/mingw/math/arm-common/ldexpl.c created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | long double ldexpl(long double x, int n) | ||
| 10 | { | ||
| 11 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 12 | return ldexp(x, n); | ||
| 13 | #else | ||
| 14 | #error Not supported on your platform yet | ||
| 15 | #endif | ||
| 16 | } | ||
lib/libc/mingw/math/arm-common/log1p.c created+12| ... | @@ -0,0 +1,12 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | double log1p(double x) | ||
| 10 | { | ||
| 11 | return log(x + 1.0); | ||
| 12 | } | ||
lib/libc/mingw/math/arm-common/log1pf.c created+15| ... | @@ -0,0 +1,15 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | float log1pf(float x) | ||
| 10 | { | ||
| 11 | // Intentionally using double version of log() here in the float version of | ||
| 12 | // log1p, to preserve as much accuracy as possible in the intermediate | ||
| 13 | // parameter. | ||
| 14 | return log(x + 1.0); | ||
| 15 | } | ||
lib/libc/mingw/math/arm-common/log1pl.c created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | long double log1pl(long double x) | ||
| 10 | { | ||
| 11 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 12 | return log1p(x); | ||
| 13 | #else | ||
| 14 | #error Not supported on your platform yet | ||
| 15 | #endif | ||
| 16 | } | ||
lib/libc/mingw/math/arm-common/logb.c created+17| ... | @@ -0,0 +1,17 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | #include <limits.h> | ||
| 9 | |||
| 10 | extern double (* __MINGW_IMP_SYMBOL(_logb))(double); | ||
| 11 | |||
| 12 | double logb(double x) | ||
| 13 | { | ||
| 14 | if (isinf(x)) | ||
| 15 | return INFINITY; | ||
| 16 | return __MINGW_IMP_SYMBOL(_logb)(x); | ||
| 17 | } | ||
lib/libc/mingw/math/arm-common/logbf.c created+17| ... | @@ -0,0 +1,17 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | #include <limits.h> | ||
| 9 | |||
| 10 | extern float (* __MINGW_IMP_SYMBOL(_logbf))(float); | ||
| 11 | |||
| 12 | float logbf(float x) | ||
| 13 | { | ||
| 14 | if (isinf(x)) | ||
| 15 | return INFINITY; | ||
| 16 | return __MINGW_IMP_SYMBOL(_logbf)(x); | ||
| 17 | } | ||
lib/libc/mingw/math/arm-common/logbl.c created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | long double logbl(long double x) | ||
| 10 | { | ||
| 11 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 12 | return logb(x); | ||
| 13 | #else | ||
| 14 | #error Not supported on your platform yet | ||
| 15 | #endif | ||
| 16 | } | ||
lib/libc/mingw/math/arm-common/powf.c created+21| ... | @@ -0,0 +1,21 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | #include <limits.h> | ||
| 9 | |||
| 10 | extern float (* __MINGW_IMP_SYMBOL(powf))(float, float); | ||
| 11 | |||
| 12 | float powf(float x, float y) | ||
| 13 | { | ||
| 14 | if (x == 1.0f) | ||
| 15 | return 1.0f; | ||
| 16 | if (y == 0.0f) | ||
| 17 | return 1.0f; | ||
| 18 | if (x == -1.0f && isinf(y)) | ||
| 19 | return 1.0f; | ||
| 20 | return __MINGW_IMP_SYMBOL(powf)(x, y); | ||
| 21 | } | ||
lib/libc/mingw/math/arm-common/powl.c created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | long double powl(long double x, long double y) | ||
| 10 | { | ||
| 11 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 12 | return pow(x, y); | ||
| 13 | #else | ||
| 14 | #error Not supported on your platform yet | ||
| 15 | #endif | ||
| 16 | } | ||
lib/libc/mingw/math/arm-common/remainder.c created+14| ... | @@ -0,0 +1,14 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | #include <errno.h> | ||
| 9 | |||
| 10 | double remainder(double x, double y) | ||
| 11 | { | ||
| 12 | int iret; | ||
| 13 | return remquo(x, y, &iret); | ||
| 14 | } | ||
lib/libc/mingw/math/arm-common/remainderf.c created+14| ... | @@ -0,0 +1,14 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | #include <errno.h> | ||
| 9 | |||
| 10 | float remainderf(float x, float y) | ||
| 11 | { | ||
| 12 | int iret; | ||
| 13 | return remquof(x, y, &iret); | ||
| 14 | } | ||
lib/libc/mingw/math/arm-common/remainderl.c created+17| ... | @@ -0,0 +1,17 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | #include <errno.h> | ||
| 9 | |||
| 10 | long double remainderl(long double x, long double y) | ||
| 11 | { | ||
| 12 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 13 | return remainder(x, y); | ||
| 14 | #else | ||
| 15 | #error Not supported on your platform yet | ||
| 16 | #endif | ||
| 17 | } | ||
lib/libc/mingw/math/arm-common/remquol.c created+17| ... | @@ -0,0 +1,17 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | #include <errno.h> | ||
| 9 | |||
| 10 | long double remquol(long double x, long double y, int *quo) | ||
| 11 | { | ||
| 12 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 13 | return remquo(x, y, quo); | ||
| 14 | #else | ||
| 15 | #error Not supported on your platform yet | ||
| 16 | #endif | ||
| 17 | } | ||
lib/libc/mingw/math/arm-common/s_remquo.c created+154| ... | @@ -0,0 +1,154 @@ | ||
| 1 | /* @(#)e_fmod.c 1.3 95/01/18 */ | ||
| 2 | /*- | ||
| 3 | * ==================================================== | ||
| 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 5 | * | ||
| 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. | ||
| 7 | * Permission to use, copy, modify, and distribute this | ||
| 8 | * software is freely granted, provided that this notice | ||
| 9 | * is preserved. | ||
| 10 | * ==================================================== | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <sys/cdefs.h> | ||
| 14 | |||
| 15 | #include <float.h> | ||
| 16 | |||
| 17 | #include <math.h> | ||
| 18 | #include "../bsd_private_base.h" | ||
| 19 | |||
| 20 | static const double Zero[] = {0.0, -0.0,}; | ||
| 21 | |||
| 22 | /* | ||
| 23 | * Return the IEEE remainder and set *quo to the last n bits of the | ||
| 24 | * quotient, rounded to the nearest integer. We choose n=31 because | ||
| 25 | * we wind up computing all the integer bits of the quotient anyway as | ||
| 26 | * a side-effect of computing the remainder by the shift and subtract | ||
| 27 | * method. In practice, this is far more bits than are needed to use | ||
| 28 | * remquo in reduction algorithms. | ||
| 29 | */ | ||
| 30 | double | ||
| 31 | remquo(double x, double y, int *quo) | ||
| 32 | { | ||
| 33 | 	int32_t n,hx,hy,hz,ix,iy,sx,i; | ||
| 34 | 	u_int32_t lx,ly,lz,q,sxy; | ||
| 35 | |||
| 36 | 	EXTRACT_WORDS(hx,lx,x); | ||
| 37 | 	EXTRACT_WORDS(hy,ly,y); | ||
| 38 | 	sxy = (hx ^ hy) & 0x80000000; | ||
| 39 | 	sx = hx&0x80000000;		/* sign of x */ | ||
| 40 | 	hx ^=sx;		/* |x| */ | ||
| 41 | 	hy &= 0x7fffffff;	/* |y| */ | ||
| 42 | |||
| 43 | /* purge off exception values */ | ||
| 44 | 	if((hy|ly)==0||(hx>=0x7ff00000)||	/* y=0,or x not finite */ | ||
| 45 | 	 ((hy|((ly|-ly)>>31))>0x7ff00000))	/* or y is NaN */ | ||
| 46 | 	 return nan_mix_op(x, y, *)/nan_mix_op(x, y, *); | ||
| 47 | 	if(hx<=hy) { | ||
| 48 | 	 if((hx<hy)||(lx<ly)) { | ||
| 49 | 		q = 0; | ||
| 50 | 		goto fixup;	/* |x|<|y| return x or x-y */ | ||
| 51 | 	 } | ||
| 52 | 	 if(lx==ly) { | ||
| 53 | 		*quo = (sxy ? -1 : 1); | ||
| 54 | 		return Zero[(u_int32_t)sx>>31];	/* |x|=|y| return x*0*/ | ||
| 55 | 	 } | ||
| 56 | 	} | ||
| 57 | |||
| 58 | /* determine ix = ilogb(x) */ | ||
| 59 | 	if(hx<0x00100000) {	/* subnormal x */ | ||
| 60 | 	 if(hx==0) { | ||
| 61 | 		for (ix = -1043, i=lx; i>0; i<<=1) ix -=1; | ||
| 62 | 	 } else { | ||
| 63 | 		for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1; | ||
| 64 | 	 } | ||
| 65 | 	} else ix = (hx>>20)-1023; | ||
| 66 | |||
| 67 | /* determine iy = ilogb(y) */ | ||
| 68 | 	if(hy<0x00100000) {	/* subnormal y */ | ||
| 69 | 	 if(hy==0) { | ||
| 70 | 		for (iy = -1043, i=ly; i>0; i<<=1) iy -=1; | ||
| 71 | 	 } else { | ||
| 72 | 		for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1; | ||
| 73 | 	 } | ||
| 74 | 	} else iy = (hy>>20)-1023; | ||
| 75 | |||
| 76 | /* set up {hx,lx}, {hy,ly} and align y to x */ | ||
| 77 | 	if(ix >= -1022) | ||
| 78 | 	 hx = 0x00100000|(0x000fffff&hx); | ||
| 79 | 	else {		/* subnormal x, shift x to normal */ | ||
| 80 | 	 n = -1022-ix; | ||
| 81 | 	 if(n<=31) { | ||
| 82 | 	 hx = (hx<<n)|(lx>>(32-n)); | ||
| 83 | 	 lx <<= n; | ||
| 84 | 	 } else { | ||
| 85 | 		hx = lx<<(n-32); | ||
| 86 | 		lx = 0; | ||
| 87 | 	 } | ||
| 88 | 	} | ||
| 89 | 	if(iy >= -1022) | ||
| 90 | 	 hy = 0x00100000|(0x000fffff&hy); | ||
| 91 | 	else {		/* subnormal y, shift y to normal */ | ||
| 92 | 	 n = -1022-iy; | ||
| 93 | 	 if(n<=31) { | ||
| 94 | 	 hy = (hy<<n)|(ly>>(32-n)); | ||
| 95 | 	 ly <<= n; | ||
| 96 | 	 } else { | ||
| 97 | 		hy = ly<<(n-32); | ||
| 98 | 		ly = 0; | ||
| 99 | 	 } | ||
| 100 | 	} | ||
| 101 | |||
| 102 | /* fix point fmod */ | ||
| 103 | 	n = ix - iy; | ||
| 104 | 	q = 0; | ||
| 105 | 	while(n--) { | ||
| 106 | 	 hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1; | ||
| 107 | 	 if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;} | ||
| 108 | 	 else {hx = hz+hz+(lz>>31); lx = lz+lz; q++;} | ||
| 109 | 	 q <<= 1; | ||
| 110 | 	} | ||
| 111 | 	hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1; | ||
| 112 | 	if(hz>=0) {hx=hz;lx=lz;q++;} | ||
| 113 | |||
| 114 | /* convert back to floating value and restore the sign */ | ||
| 115 | 	if((hx|lx)==0) {			/* return sign(x)*0 */ | ||
| 116 | 	 q &= 0x7fffffff; | ||
| 117 | 	 *quo = (sxy ? -q : q); | ||
| 118 | 	 return Zero[(u_int32_t)sx>>31]; | ||
| 119 | 	} | ||
| 120 | 	while(hx<0x00100000) {		/* normalize x */ | ||
| 121 | 	 hx = hx+hx+(lx>>31); lx = lx+lx; | ||
| 122 | 	 iy -= 1; | ||
| 123 | 	} | ||
| 124 | 	if(iy>= -1022) {	/* normalize output */ | ||
| 125 | 	 hx = ((hx-0x00100000)|((iy+1023)<<20)); | ||
| 126 | 	} else {		/* subnormal output */ | ||
| 127 | 	 n = -1022 - iy; | ||
| 128 | 	 if(n<=20) { | ||
| 129 | 		lx = (lx>>n)|((u_int32_t)hx<<(32-n)); | ||
| 130 | 		hx >>= n; | ||
| 131 | 	 } else if (n<=31) { | ||
| 132 | 		lx = (hx<<(32-n))|(lx>>n); hx = 0; | ||
| 133 | 	 } else { | ||
| 134 | 		lx = hx>>(n-32); hx = 0; | ||
| 135 | 	 } | ||
| 136 | 	} | ||
| 137 | fixup: | ||
| 138 | 	INSERT_WORDS(x,hx,lx); | ||
| 139 | 	y = fabs(y); | ||
| 140 | 	if (y < 0x1p-1021) { | ||
| 141 | 	 if (x+x>y || (x+x==y && (q & 1))) { | ||
| 142 | 		q++; | ||
| 143 | 		x-=y; | ||
| 144 | 	 } | ||
| 145 | 	} else if (x>0.5*y || (x==0.5*y && (q & 1))) { | ||
| 146 | 	 q++; | ||
| 147 | 	 x-=y; | ||
| 148 | 	} | ||
| 149 | 	GET_HIGH_WORD(hx,x); | ||
| 150 | 	SET_HIGH_WORD(x,hx^sx); | ||
| 151 | 	q &= 0x7fffffff; | ||
| 152 | 	*quo = (sxy ? -q : q); | ||
| 153 | 	return x; | ||
| 154 | } | ||
lib/libc/mingw/math/arm-common/s_remquof.c created+121| ... | @@ -0,0 +1,121 @@ | ||
| 1 | /* @(#)e_fmod.c 1.3 95/01/18 */ | ||
| 2 | /*- | ||
| 3 | * ==================================================== | ||
| 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | ||
| 5 | * | ||
| 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. | ||
| 7 | * Permission to use, copy, modify, and distribute this | ||
| 8 | * software is freely granted, provided that this notice | ||
| 9 | * is preserved. | ||
| 10 | * ==================================================== | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <sys/cdefs.h> | ||
| 14 | |||
| 15 | #include <math.h> | ||
| 16 | #include "../bsd_private_base.h" | ||
| 17 | |||
| 18 | static const float Zero[] = {0.0, -0.0,}; | ||
| 19 | |||
| 20 | /* | ||
| 21 | * Return the IEEE remainder and set *quo to the last n bits of the | ||
| 22 | * quotient, rounded to the nearest integer. We choose n=31 because | ||
| 23 | * we wind up computing all the integer bits of the quotient anyway as | ||
| 24 | * a side-effect of computing the remainder by the shift and subtract | ||
| 25 | * method. In practice, this is far more bits than are needed to use | ||
| 26 | * remquo in reduction algorithms. | ||
| 27 | */ | ||
| 28 | float | ||
| 29 | remquof(float x, float y, int *quo) | ||
| 30 | { | ||
| 31 | 	int32_t n,hx,hy,hz,ix,iy,sx,i; | ||
| 32 | 	u_int32_t q,sxy; | ||
| 33 | |||
| 34 | 	GET_FLOAT_WORD(hx,x); | ||
| 35 | 	GET_FLOAT_WORD(hy,y); | ||
| 36 | 	sxy = (hx ^ hy) & 0x80000000; | ||
| 37 | 	sx = hx&0x80000000;		/* sign of x */ | ||
| 38 | 	hx ^=sx;		/* |x| */ | ||
| 39 | 	hy &= 0x7fffffff;	/* |y| */ | ||
| 40 | |||
| 41 | /* purge off exception values */ | ||
| 42 | 	if(hy==0||hx>=0x7f800000||hy>0x7f800000) /* y=0,NaN;or x not finite */ | ||
| 43 | 	 return nan_mix_op(x, y, *)/nan_mix_op(x, y, *); | ||
| 44 | 	if(hx<hy) { | ||
| 45 | 	 q = 0; | ||
| 46 | 	 goto fixup;	/* |x|<|y| return x or x-y */ | ||
| 47 | 	} else if(hx==hy) { | ||
| 48 | 	 *quo = (sxy ? -1 : 1); | ||
| 49 | 	 return Zero[(u_int32_t)sx>>31];	/* |x|=|y| return x*0*/ | ||
| 50 | 	} | ||
| 51 | |||
| 52 | /* determine ix = ilogb(x) */ | ||
| 53 | 	if(hx<0x00800000) {	/* subnormal x */ | ||
| 54 | 	 for (ix = -126,i=(hx<<8); i>0; i<<=1) ix -=1; | ||
| 55 | 	} else ix = (hx>>23)-127; | ||
| 56 | |||
| 57 | /* determine iy = ilogb(y) */ | ||
| 58 | 	if(hy<0x00800000) {	/* subnormal y */ | ||
| 59 | 	 for (iy = -126,i=(hy<<8); i>0; i<<=1) iy -=1; | ||
| 60 | 	} else iy = (hy>>23)-127; | ||
| 61 | |||
| 62 | /* set up {hx,lx}, {hy,ly} and align y to x */ | ||
| 63 | 	if(ix >= -126) | ||
| 64 | 	 hx = 0x00800000|(0x007fffff&hx); | ||
| 65 | 	else {		/* subnormal x, shift x to normal */ | ||
| 66 | 	 n = -126-ix; | ||
| 67 | 	 hx <<= n; | ||
| 68 | 	} | ||
| 69 | 	if(iy >= -126) | ||
| 70 | 	 hy = 0x00800000|(0x007fffff&hy); | ||
| 71 | 	else {		/* subnormal y, shift y to normal */ | ||
| 72 | 	 n = -126-iy; | ||
| 73 | 	 hy <<= n; | ||
| 74 | 	} | ||
| 75 | |||
| 76 | /* fix point fmod */ | ||
| 77 | 	n = ix - iy; | ||
| 78 | 	q = 0; | ||
| 79 | 	while(n--) { | ||
| 80 | 	 hz=hx-hy; | ||
| 81 | 	 if(hz<0) hx = hx << 1; | ||
| 82 | 	 else {hx = hz << 1; q++;} | ||
| 83 | 	 q <<= 1; | ||
| 84 | 	} | ||
| 85 | 	hz=hx-hy; | ||
| 86 | 	if(hz>=0) {hx=hz;q++;} | ||
| 87 | |||
| 88 | /* convert back to floating value and restore the sign */ | ||
| 89 | 	if(hx==0) {				/* return sign(x)*0 */ | ||
| 90 | 	 q &= 0x7fffffff; | ||
| 91 | 	 *quo = (sxy ? -q : q); | ||
| 92 | 	 return Zero[(u_int32_t)sx>>31]; | ||
| 93 | 	} | ||
| 94 | 	while(hx<0x00800000) {		/* normalize x */ | ||
| 95 | 	 hx <<= 1; | ||
| 96 | 	 iy -= 1; | ||
| 97 | 	} | ||
| 98 | 	if(iy>= -126) {		/* normalize output */ | ||
| 99 | 	 hx = ((hx-0x00800000)|((iy+127)<<23)); | ||
| 100 | 	} else {		/* subnormal output */ | ||
| 101 | 	 n = -126 - iy; | ||
| 102 | 	 hx >>= n; | ||
| 103 | 	} | ||
| 104 | fixup: | ||
| 105 | 	SET_FLOAT_WORD(x,hx); | ||
| 106 | 	y = fabsf(y); | ||
| 107 | 	if (y < 0x1p-125f) { | ||
| 108 | 	 if (x+x>y || (x+x==y && (q & 1))) { | ||
| 109 | 		q++; | ||
| 110 | 		x-=y; | ||
| 111 | 	 } | ||
| 112 | 	} else if (x>0.5f*y || (x==0.5f*y && (q & 1))) { | ||
| 113 | 	 q++; | ||
| 114 | 	 x-=y; | ||
| 115 | 	} | ||
| 116 | 	GET_FLOAT_WORD(hx,x); | ||
| 117 | 	SET_FLOAT_WORD(x,hx^sx); | ||
| 118 | 	q &= 0x7fffffff; | ||
| 119 | 	*quo = (sxy ? -q : q); | ||
| 120 | 	return x; | ||
| 121 | } | ||
src/mingw.zig+39-5| ... | @@ -1018,7 +1018,44 @@ const mingwex_x86_src = [_][]const u8{ | ... | @@ -1018,7 +1018,44 @@ const mingwex_x86_src = [_][]const u8{ |
| 1018 | "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "trunc.S", | 1018 | "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "trunc.S", |
| 1019 | }; | 1019 | }; |
| 1020 | 1020 | ||
| 1021 | const mingwex_arm32_src = [_][]const u8{ | 1021 | const arm_common = [_][]const u8{ |
| 1022 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "acosh.c", | ||
| 1023 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "acoshf.c", | ||
| 1024 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "acoshl.c", | ||
| 1025 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "asinh.c", | ||
| 1026 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "asinhf.c", | ||
| 1027 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "asinhl.c", | ||
| 1028 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "atanh.c", | ||
| 1029 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "atanhf.c", | ||
| 1030 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "atanhl.c", | ||
| 1031 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "copysignl.c", | ||
| 1032 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "expm1.c", | ||
| 1033 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "expm1f.c", | ||
| 1034 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "expm1l.c", | ||
| 1035 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "ilogb.c", | ||
| 1036 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "ilogbf.c", | ||
| 1037 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "ilogbl.c", | ||
| 1038 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "ldexpl.c", | ||
| 1039 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "log1p.c", | ||
| 1040 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "log1pf.c", | ||
| 1041 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "log1pl.c", | ||
| 1042 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "log2.c", | ||
| 1043 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "logb.c", | ||
| 1044 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "logbf.c", | ||
| 1045 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "logbl.c", | ||
| 1046 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "pow.c", | ||
| 1047 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "powf.c", | ||
| 1048 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "powl.c", | ||
| 1049 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "remainder.c", | ||
| 1050 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "remainderf.c", | ||
| 1051 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "remainderl.c", | ||
| 1052 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "remquol.c", | ||
| 1053 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "s_remquo.c", | ||
| 1054 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "s_remquof.c", | ||
| 1055 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "scalbn.c", | ||
| 1056 | }; | ||
| 1057 | |||
| 1058 | const mingwex_arm32_src = arm_common ++ [_][]const u8{ | ||
| 1022 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "_chgsignl.S", | 1059 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "_chgsignl.S", |
| 1023 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rint.c", | 1060 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rint.c", |
| 1024 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rintf.c", | 1061 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rintf.c", |
| ... | @@ -1033,11 +1070,8 @@ const mingwex_arm32_src = [_][]const u8{ | ... | @@ -1033,11 +1070,8 @@ const mingwex_arm32_src = [_][]const u8{ |
| 1033 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_truncf.c", | 1070 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_truncf.c", |
| 1034 | }; | 1071 | }; |
| 1035 | 1072 | ||
| 1036 | const mingwex_arm64_src = [_][]const u8{ | 1073 | const mingwex_arm64_src = arm_common ++ [_][]const u8{ |
| 1037 | "misc" ++ path.sep_str ++ "initenv.c", | 1074 | "misc" ++ path.sep_str ++ "initenv.c", |
| 1038 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "log2.c", | ||
| 1039 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "pow.c", | ||
| 1040 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "scalbn.c", | ||
| 1041 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "_chgsignl.S", | 1075 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "_chgsignl.S", |
| 1042 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rint.c", | 1076 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rint.c", |
| 1043 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rintf.c", | 1077 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rintf.c", |