https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9e8ed3f817898cbee3c6e7...
commit 9e8ed3f817898cbee3c6e753fd74dd0a9ac949a8 Author: Timo Kreuzer timo.kreuzer@reactos.org AuthorDate: Sun Jun 12 14:16:22 2022 +0300 Commit: Timo Kreuzer timo.kreuzer@reactos.org CommitDate: Thu Dec 1 15:21:59 2022 +0200
[LIBM] Fix build --- sdk/lib/crt/math/libm_sse2/_chgsign.c | 2 +- sdk/lib/crt/math/libm_sse2/_copysign.c | 2 +- sdk/lib/crt/math/libm_sse2/_finite.c | 2 +- sdk/lib/crt/math/libm_sse2/acos.c | 7 ++-- sdk/lib/crt/math/libm_sse2/acosf.c | 3 +- sdk/lib/crt/math/libm_sse2/asin.c | 6 ++- sdk/lib/crt/math/libm_sse2/asinf.c | 3 +- sdk/lib/crt/math/libm_sse2/atan.c | 4 +- sdk/lib/crt/math/libm_sse2/atan2.c | 4 +- sdk/lib/crt/math/libm_sse2/atan2f.c | 4 +- sdk/lib/crt/math/libm_sse2/atanf.c | 4 +- sdk/lib/crt/math/libm_sse2/ceil.c | 4 +- sdk/lib/crt/math/libm_sse2/cosh.c | 8 ++-- sdk/lib/crt/math/libm_sse2/coshf.c | 6 ++- sdk/lib/crt/math/libm_sse2/exp2.c | 4 +- sdk/lib/crt/math/libm_sse2/floor.c | 4 +- sdk/lib/crt/math/libm_sse2/fma3_available.c | 12 +++--- sdk/lib/crt/math/libm_sse2/hypot.c | 7 +++- sdk/lib/crt/math/libm_sse2/hypotf.c | 2 +- sdk/lib/crt/math/libm_sse2/libm_inlines.h | 58 +++++++++++++-------------- sdk/lib/crt/math/libm_sse2/libm_util.h | 18 +++------ sdk/lib/crt/math/libm_sse2/logb.c | 4 +- sdk/lib/crt/math/libm_sse2/modf.c | 4 +- sdk/lib/crt/math/libm_sse2/remainder.c | 12 +++--- sdk/lib/crt/math/libm_sse2/remainder_piby2.c | 10 ++--- sdk/lib/crt/math/libm_sse2/remainder_piby2f.c | 10 ++--- sdk/lib/crt/math/libm_sse2/remainderf.c | 6 +-- sdk/lib/crt/math/libm_sse2/simd.h | 6 +-- sdk/lib/crt/math/libm_sse2/sinh.c | 6 ++- sdk/lib/crt/math/libm_sse2/sinhf.c | 5 ++- sdk/lib/crt/math/libm_sse2/sqrt.c | 2 +- sdk/lib/crt/math/libm_sse2/tan.c | 8 ++-- sdk/lib/crt/math/libm_sse2/tanf.c | 6 ++- sdk/lib/crt/math/libm_sse2/tanh.c | 6 ++- sdk/lib/crt/math/libm_sse2/tanhf.c | 2 + 35 files changed, 139 insertions(+), 112 deletions(-)
diff --git a/sdk/lib/crt/math/libm_sse2/_chgsign.c b/sdk/lib/crt/math/libm_sse2/_chgsign.c index f22ce58a743..4ecafd8ba8f 100644 --- a/sdk/lib/crt/math/libm_sse2/_chgsign.c +++ b/sdk/lib/crt/math/libm_sse2/_chgsign.c @@ -32,7 +32,7 @@ double FN_PROTOTYPE(_chgsign)(double x) /* Returns x with its sign reversed. NaNs are not considered special; their sign bits are handled the same as for any other number */ - unsigned long u; + unsigned long long u; GET_BITS_DP64(x, u); u ^= SIGNBIT_DP64; PUT_BITS_DP64(u, x); diff --git a/sdk/lib/crt/math/libm_sse2/_copysign.c b/sdk/lib/crt/math/libm_sse2/_copysign.c index c3944276567..b8c9aeabf0e 100644 --- a/sdk/lib/crt/math/libm_sse2/_copysign.c +++ b/sdk/lib/crt/math/libm_sse2/_copysign.c @@ -34,7 +34,7 @@ THE SOFTWARE. double FN_PROTOTYPE(_copysign)(double x, double y) {
- unsigned long ux, uy; + unsigned long long ux, uy; GET_BITS_DP64(x, ux); GET_BITS_DP64(y, uy); if ((ux ^ uy) & SIGNBIT_DP64) diff --git a/sdk/lib/crt/math/libm_sse2/_finite.c b/sdk/lib/crt/math/libm_sse2/_finite.c index c3ca86f4b05..243ab12ae4e 100644 --- a/sdk/lib/crt/math/libm_sse2/_finite.c +++ b/sdk/lib/crt/math/libm_sse2/_finite.c @@ -33,7 +33,7 @@ int FN_PROTOTYPE(_finite)(double x) {
- unsigned long ux; + unsigned long long ux; GET_BITS_DP64(x, ux); return (int)(((ux & ~SIGNBIT_DP64) - PINFBITPATT_DP64) >> 63); } diff --git a/sdk/lib/crt/math/libm_sse2/acos.c b/sdk/lib/crt/math/libm_sse2/acos.c index cb46803e536..2e5a5f55033 100644 --- a/sdk/lib/crt/math/libm_sse2/acos.c +++ b/sdk/lib/crt/math/libm_sse2/acos.c @@ -37,8 +37,9 @@ THE SOFTWARE.
#include "libm_errno.h"
- +#ifdef _MSC_VER #pragma function(acos) +#endif
double FN_PROTOTYPE(acos)(double x) { @@ -69,7 +70,7 @@ double FN_PROTOTYPE(acos)(double x) double u, y, s=0.0, r; int xexp, xnan, transform=0;
- unsigned long ux, aux, xneg; + unsigned long long ux, aux, xneg; GET_BITS_DP64(x, ux); aux = ux & ~SIGNBIT_DP64; xneg = (ux & SIGNBIT_DP64); @@ -133,7 +134,7 @@ double FN_PROTOTYPE(acos)(double x) else { double c, s1; - unsigned long us; + unsigned long long us; GET_BITS_DP64(s, us); PUT_BITS_DP64(0xffffffff00000000 & us, s1); c = (r-s1*s1)/(s+s1); diff --git a/sdk/lib/crt/math/libm_sse2/acosf.c b/sdk/lib/crt/math/libm_sse2/acosf.c index 5422177b317..f39f5f74ab3 100644 --- a/sdk/lib/crt/math/libm_sse2/acosf.c +++ b/sdk/lib/crt/math/libm_sse2/acosf.c @@ -37,11 +37,12 @@ THE SOFTWARE.
#include "libm_errno.h"
+#ifdef _MSC_VER // Disable "C4163: not available as intrinsic function" warning that older // compilers may issue here. #pragma warning(disable:4163) #pragma function(acosf) - +#endif
float FN_PROTOTYPE(acosf)(float x) { diff --git a/sdk/lib/crt/math/libm_sse2/asin.c b/sdk/lib/crt/math/libm_sse2/asin.c index 31e652b73c6..d80448ec777 100644 --- a/sdk/lib/crt/math/libm_sse2/asin.c +++ b/sdk/lib/crt/math/libm_sse2/asin.c @@ -37,7 +37,9 @@ THE SOFTWARE.
#include "libm_errno.h"
+#ifdef _MSC_VER #pragma function(asin) +#endif
double FN_PROTOTYPE(asin)(double x) { @@ -65,7 +67,7 @@ double FN_PROTOTYPE(asin)(double x) double u, v, y, s=0.0, r; int xexp, xnan, transform=0;
- unsigned long ux, aux, xneg; + unsigned long long ux, aux, xneg; GET_BITS_DP64(x, ux); aux = ux & ~SIGNBIT_DP64; xneg = (ux & SIGNBIT_DP64); @@ -127,7 +129,7 @@ double FN_PROTOTYPE(asin)(double x) { /* Reconstruct asin carefully in transformed region */ { double c, s1, p, q; - unsigned long us; + unsigned long long us; GET_BITS_DP64(s, us); PUT_BITS_DP64(0xffffffff00000000 & us, s1); c = (r-s1*s1)/(s+s1); diff --git a/sdk/lib/crt/math/libm_sse2/asinf.c b/sdk/lib/crt/math/libm_sse2/asinf.c index 89dba1059ff..2dc16bc3984 100644 --- a/sdk/lib/crt/math/libm_sse2/asinf.c +++ b/sdk/lib/crt/math/libm_sse2/asinf.c @@ -37,11 +37,12 @@ THE SOFTWARE.
#include "libm_errno.h"
+#ifdef _MSC_VER // Disable "C4163: not available as intrinsic function" warning that older // compilers may issue here. #pragma warning(disable:4163) #pragma function(asinf) - +#endif
float FN_PROTOTYPE(asinf)(float x) { diff --git a/sdk/lib/crt/math/libm_sse2/atan.c b/sdk/lib/crt/math/libm_sse2/atan.c index c28e0672779..f6c4e38dfc6 100644 --- a/sdk/lib/crt/math/libm_sse2/atan.c +++ b/sdk/lib/crt/math/libm_sse2/atan.c @@ -37,7 +37,9 @@ THE SOFTWARE.
#include "libm_errno.h"
+#ifdef _MSC_VER #pragma function(atan) +#endif
double FN_PROTOTYPE(atan)(double x) { @@ -49,7 +51,7 @@ double FN_PROTOTYPE(atan)(double x)
/* Find properties of argument x. */
- unsigned long ux, aux, xneg; + unsigned long long ux, aux, xneg; GET_BITS_DP64(x, ux); aux = ux & ~SIGNBIT_DP64; xneg = (ux != aux); diff --git a/sdk/lib/crt/math/libm_sse2/atan2.c b/sdk/lib/crt/math/libm_sse2/atan2.c index fb9d1e8482f..71db395cf31 100644 --- a/sdk/lib/crt/math/libm_sse2/atan2.c +++ b/sdk/lib/crt/math/libm_sse2/atan2.c @@ -45,7 +45,9 @@ THE SOFTWARE.
#include "libm_errno.h"
+#ifdef _MSC_VER #pragma function(atan2) +#endif
double FN_PROTOTYPE(atan2)(double y, double x) { @@ -558,7 +560,7 @@ double FN_PROTOTYPE(atan2)(double y, double x)
/* Find properties of arguments x and y. */
- unsigned long ux, ui, aux, xneg, uy, auy, yneg; + unsigned long long ux, ui, aux, xneg, uy, auy, yneg;
GET_BITS_DP64(x, ux); GET_BITS_DP64(y, uy); diff --git a/sdk/lib/crt/math/libm_sse2/atan2f.c b/sdk/lib/crt/math/libm_sse2/atan2f.c index 42d54cda2d5..1426c19e8a1 100644 --- a/sdk/lib/crt/math/libm_sse2/atan2f.c +++ b/sdk/lib/crt/math/libm_sse2/atan2f.c @@ -41,10 +41,12 @@ THE SOFTWARE.
#include "libm_errno.h"
+#ifdef _MSC_VER // Disable "C4163: not available as intrinsic function" warning that older // compilers may issue here. #pragma warning(disable:4163) #pragma function(atan2f) +#endif
float FN_PROTOTYPE(atan2f)(float fy, float fx) { @@ -310,7 +312,7 @@ float FN_PROTOTYPE(atan2f)(float fy, float fx)
/* Find properties of arguments x and y. */
- unsigned long ux, aux, xneg, uy, auy, yneg; + unsigned long long ux, aux, xneg, uy, auy, yneg;
GET_BITS_DP64(x, ux); GET_BITS_DP64(y, uy); diff --git a/sdk/lib/crt/math/libm_sse2/atanf.c b/sdk/lib/crt/math/libm_sse2/atanf.c index 08c4eb7ff43..1baff25d8b8 100644 --- a/sdk/lib/crt/math/libm_sse2/atanf.c +++ b/sdk/lib/crt/math/libm_sse2/atanf.c @@ -37,10 +37,12 @@ THE SOFTWARE.
#include "libm_errno.h"
+#ifdef _MSC_VER // Disable "C4163: not available as intrinsic function" warning that older // compilers may issue here. #pragma warning(disable:4163) #pragma function(atanf) +#endif
float FN_PROTOTYPE(atanf)(float fx) { @@ -56,7 +58,7 @@ float FN_PROTOTYPE(atanf)(float fx)
/* Find properties of argument fx. */
- unsigned long ux, aux, xneg; + unsigned long long ux, aux, xneg;
GET_BITS_DP64(x, ux); aux = ux & ~SIGNBIT_DP64; diff --git a/sdk/lib/crt/math/libm_sse2/ceil.c b/sdk/lib/crt/math/libm_sse2/ceil.c index cb0f155e1d8..7a549a8931a 100644 --- a/sdk/lib/crt/math/libm_sse2/ceil.c +++ b/sdk/lib/crt/math/libm_sse2/ceil.c @@ -40,8 +40,8 @@ THE SOFTWARE. double FN_PROTOTYPE(ceil)(double x) { double r; - long rexp, xneg; - unsigned long ux, ax, ur, mask; + long long rexp, xneg; + unsigned long long ux, ax, ur, mask;
GET_BITS_DP64(x, ux); ax = ux & (~SIGNBIT_DP64); diff --git a/sdk/lib/crt/math/libm_sse2/cosh.c b/sdk/lib/crt/math/libm_sse2/cosh.c index 9eb06d0c261..69c0051481a 100644 --- a/sdk/lib/crt/math/libm_sse2/cosh.c +++ b/sdk/lib/crt/math/libm_sse2/cosh.c @@ -41,8 +41,10 @@ THE SOFTWARE. #undef USE_VAL_WITH_FLAGS #undef USE_HANDLE_ERROR
- +#ifdef _MSC_VER #pragma function(cosh) +#endif + double cosh(double x) { /* @@ -230,10 +232,10 @@ double cosh(double x) 3.64177136406482197344e+06, /* 0x414bc8d5ae99ad14 */ 7.63580561355670914054e+06}; /* 0x415d20d76744835c */
- unsigned long ux, aux, xneg; + unsigned long long ux, aux, xneg; double y, z, z1, z2; int m; - + /* Special cases */
GET_BITS_DP64(x, ux); diff --git a/sdk/lib/crt/math/libm_sse2/coshf.c b/sdk/lib/crt/math/libm_sse2/coshf.c index 6e7ad089c37..ceafca9e6f3 100644 --- a/sdk/lib/crt/math/libm_sse2/coshf.c +++ b/sdk/lib/crt/math/libm_sse2/coshf.c @@ -41,10 +41,12 @@ THE SOFTWARE. #undef USE_VALF_WITH_FLAGS #undef USE_HANDLE_ERRORF
+#ifdef _MSC_VER // Disable "C4163: not available as intrinsic function" warning that older // compilers may issue here. #pragma warning(disable:4163) #pragma function(coshf) +#endif
float coshf(float fx) { @@ -154,7 +156,7 @@ float coshf(float fx) 7.93006726156715250000e+14, /* 0x430689e221bc8d5a */ 2.15561577355759750000e+15}; /* 0x431ea215a1d20d76 */
- unsigned long ux, aux, xneg; + unsigned long long ux, aux, xneg; unsigned int uhx; double x = fx, y, z, z1, z2; int m; @@ -169,6 +171,7 @@ float coshf(float fx) if (LAMBDA_DP64 + x > 1.0) return valf_with_flags((float)1.0, AMD_F_INEXACT); /* with inexact */ } else if (aux >= PINFBITPATT_DP64) /* |x| is NaN or Inf */ + { if (aux > PINFBITPATT_DP64) /* x is NaN */ { GET_BITS_SP32(fx, uhx); @@ -177,6 +180,7 @@ float coshf(float fx) } else /* x is infinity */ return infinityf_with_flags(0); + } xneg = (aux != ux);
y = x; diff --git a/sdk/lib/crt/math/libm_sse2/exp2.c b/sdk/lib/crt/math/libm_sse2/exp2.c index 1061b5bc85d..470be6f4bf8 100644 --- a/sdk/lib/crt/math/libm_sse2/exp2.c +++ b/sdk/lib/crt/math/libm_sse2/exp2.c @@ -58,7 +58,7 @@ double FN_PROTOTYPE(_exp2)(double x)
double y, z1, z2, z, hx, tx, y1, y2; int m; - unsigned long ux, ax; + unsigned long long ux, ax;
/* Computation of exp2(x). @@ -121,7 +121,7 @@ double FN_PROTOTYPE(_exp2)(double x) else { /* Split x into hx (head) and tx (tail). */ - unsigned long u; + unsigned long long u; hx = x; GET_BITS_DP64(hx, u); u &= 0xfffffffff8000000; diff --git a/sdk/lib/crt/math/libm_sse2/floor.c b/sdk/lib/crt/math/libm_sse2/floor.c index cf8e18f8576..e2237a9ede7 100644 --- a/sdk/lib/crt/math/libm_sse2/floor.c +++ b/sdk/lib/crt/math/libm_sse2/floor.c @@ -37,10 +37,10 @@ THE SOFTWARE. double FN_PROTOTYPE(floor)(double x) { double r; - long rexp, xneg; + long long rexp, xneg;
- unsigned long ux, ax, ur, mask; + unsigned long long ux, ax, ur, mask;
GET_BITS_DP64(x, ux); ax = ux & (~SIGNBIT_DP64); diff --git a/sdk/lib/crt/math/libm_sse2/fma3_available.c b/sdk/lib/crt/math/libm_sse2/fma3_available.c index 123cba72194..24e99837fba 100644 --- a/sdk/lib/crt/math/libm_sse2/fma3_available.c +++ b/sdk/lib/crt/math/libm_sse2/fma3_available.c @@ -26,16 +26,18 @@ THE SOFTWARE.
#ifdef TEST_STANDALONE #include <stdio.h> +#ifdef _MSC_VER #pragma section (".CRT$XIC",long,read) -typedef void (__cdecl *_PIFV)(void); +#define _CRTALLOC(x) __declspec(allocate(x)) +#endif /* _MSC_VER */ #else +#include <intrin.h> #include <sect_attribs.h> -#include <windows.h> -#include <cruntime.h> -#include <internal.h> +#undef _CRTALLOC +#define _CRTALLOC(x) #endif
-#define _CRTALLOC(x) __declspec(allocate(x)) +typedef int (__cdecl *_PIFV)(void); // FIXME: include process.h?
int __fma3_is_available = 0; int __use_fma3_lib = 0; diff --git a/sdk/lib/crt/math/libm_sse2/hypot.c b/sdk/lib/crt/math/libm_sse2/hypot.c index dabaae103a7..a74afefdb06 100644 --- a/sdk/lib/crt/math/libm_sse2/hypot.c +++ b/sdk/lib/crt/math/libm_sse2/hypot.c @@ -39,6 +39,9 @@ THE SOFTWARE.
#include "libm_errno.h"
+#if (_MSC_VER >= 1920) // VS 2019+ / Compiler version 14.20 +#pragma function(_hypot) +#endif
double FN_PROTOTYPE(_hypot)(double x, double y) { @@ -49,10 +52,10 @@ double FN_PROTOTYPE(_hypot)(double x, double y)
#ifdef FAST_BUT_GREATER_THAN_ONE_ULP double r, retval; - unsigned long xexp, yexp, ux, uy; + unsigned long long xexp, yexp, ux, uy; #else double u, r, retval, hx, tx, x2, hy, ty, y2, hs, ts; - unsigned long xexp, yexp, ux, uy, ut; + unsigned long long xexp, yexp, ux, uy, ut; #endif int dexp, expadjust;
diff --git a/sdk/lib/crt/math/libm_sse2/hypotf.c b/sdk/lib/crt/math/libm_sse2/hypotf.c index 72864564bf7..6f1ddc161e4 100644 --- a/sdk/lib/crt/math/libm_sse2/hypotf.c +++ b/sdk/lib/crt/math/libm_sse2/hypotf.c @@ -55,7 +55,7 @@ float FN_PROTOTYPE(_hypotf)(float x, float y) const double large = 3.40282346638528859812e+38; /* 0x47efffffe0000000 */
- unsigned long ux, uy, avx, avy; + unsigned long long ux, uy, avx, avy;
GET_BITS_DP64(x, avx); avx &= ~SIGNBIT_DP64; diff --git a/sdk/lib/crt/math/libm_sse2/libm_inlines.h b/sdk/lib/crt/math/libm_sse2/libm_inlines.h index 5937701be6f..f7b9cc5daeb 100644 --- a/sdk/lib/crt/math/libm_sse2/libm_inlines.h +++ b/sdk/lib/crt/math/libm_sse2/libm_inlines.h @@ -46,7 +46,7 @@ are not checked */ static inline void splitDouble(double x, int *e, double *m) { - unsigned long ux, uy; + unsigned long long ux, uy; GET_BITS_DP64(x, ux); uy = ux; ux &= EXPBITS_DP64; @@ -66,7 +66,7 @@ static inline void splitDouble(double x, int *e, double *m) assumption, e will be even on exit. */ static inline void splitDouble_2(double x, int *e, double *m) { - unsigned long ux, vx; + unsigned long long ux, vx; GET_BITS_DP64(x, ux); vx = ux; ux &= EXPBITS_DP64; @@ -117,7 +117,7 @@ static inline double scaleDouble_1(double x, int n) { double t; /* Construct the number t = 2.0**n */ - PUT_BITS_DP64(((long)n + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t); + PUT_BITS_DP64(((long long)n + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t); return x*t; } #endif /* USE_SCALEDOUBLE_1 */ @@ -133,8 +133,8 @@ static inline double scaleDouble_2(double x, int n) n1 = n / 2; n2 = n - n1; /* Construct the numbers t1 = 2.0**n1 and t2 = 2.0**n2 */ - PUT_BITS_DP64(((long)n1 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t1); - PUT_BITS_DP64(((long)n2 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t2); + PUT_BITS_DP64(((long long)n1 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t1); + PUT_BITS_DP64(((long long)n2 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t2); return (x*t1)*t2; } #endif /* USE_SCALEDOUBLE_2 */ @@ -151,9 +151,9 @@ static inline double scaleDouble_3(double x, int n) n2 = (n - n1) / 2; n3 = n - n1 - n2; /* Construct the numbers t1 = 2.0**n1, t2 = 2.0**n2 and t3 = 2.0**n3 */ - PUT_BITS_DP64(((long)n1 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t1); - PUT_BITS_DP64(((long)n2 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t2); - PUT_BITS_DP64(((long)n3 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t3); + PUT_BITS_DP64(((long long)n1 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t1); + PUT_BITS_DP64(((long long)n2 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t2); + PUT_BITS_DP64(((long long)n3 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t3); return ((x*t1)*t2)*t3; } #endif /* USE_SCALEDOUBLE_3 */ @@ -393,7 +393,7 @@ static inline double infinity_with_flags(int flags) { double z; raise_fpsw_flags(flags); - PUT_BITS_DP64((unsigned long)(BIASEDEMAX_DP64 + 1) << EXPSHIFTBITS_DP64, z); + PUT_BITS_DP64((unsigned long long)(BIASEDEMAX_DP64 + 1) << EXPSHIFTBITS_DP64, z); return z; } #endif /* USE_INFINITY_WITH_FLAGS */ @@ -419,7 +419,7 @@ static inline float infinityf_with_flags(int flags) double _handle_error( char *fname, int opcode, - unsigned long value, + unsigned long long value, int type, int flags, int error, @@ -430,7 +430,7 @@ double _handle_error( float _handle_errorf( char *fname, int opcode, - unsigned long value, + unsigned long long value, int type, int flags, int error, @@ -744,9 +744,9 @@ static inline void splitexpf(float x, float logbase, /* Scales up a double (normal or denormal) whose bit pattern is given as ux by 2**1024. There are no checks that the input number is scalable by that amount. */ -static inline void scaleUpDouble1024(unsigned long ux, unsigned long *ur) +static inline void scaleUpDouble1024(unsigned long long ux, unsigned long long *ur) { - unsigned long uy; + unsigned long long uy; double y;
if ((ux & EXPBITS_DP64) == 0) @@ -773,17 +773,17 @@ static inline void scaleUpDouble1024(unsigned long ux, unsigned long *ur) #if defined(USE_SCALEDOWNDOUBLE) /* Scales down a double whose bit pattern is given as ux by 2**k. There are no checks that the input number is scalable by that amount. */ -static inline void scaleDownDouble(unsigned long ux, int k, - unsigned long *ur) +static inline void scaleDownDouble(unsigned long long ux, int k, + unsigned long long *ur) { - unsigned long uy, uk, ax, xsign; + unsigned long long uy, uk, ax, xsign; int n, shift; xsign = ux & SIGNBIT_DP64; ax = ux & ~SIGNBIT_DP64; n = (int)((ax & EXPBITS_DP64) >> EXPSHIFTBITS_DP64) - k; if (n > 0) { - uk = (unsigned long)n << EXPSHIFTBITS_DP64; + uk = (unsigned long long)n << EXPSHIFTBITS_DP64; uy = (ax & ~EXPBITS_DP64) | uk; } else @@ -898,7 +898,7 @@ static inline double sqrt_amd_inline(double x) = 2^(e/2) * [ sqrt(c) + sqrt(c)*q ] */
- unsigned long ux, ax, u; + unsigned long long ux, ax, u; double r1, r2, c, y, p, q, r, twop, z, rtc, rtc_lead, rtc_trail; int e, denorm = 0, index;
@@ -1213,13 +1213,13 @@ static inline double sqrt_amd_inline(double x) if (denorm) { /* Scale by 2**(e-30) */ - PUT_BITS_DP64(((long)(e - 30) + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, r); + PUT_BITS_DP64(((long long)(e - 30) + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, r); z *= r; } else { /* Scale by 2**e */ - PUT_BITS_DP64(((long)e + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, r); + PUT_BITS_DP64(((long long)e + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, r); z *= r; }
@@ -1586,7 +1586,7 @@ static const float rt_jby32_trail_table_float[97] = { #endif /* SQRTF_AMD_INLINE */
#ifdef USE_LOG_KERNEL_AMD -static inline void log_kernel_amd64(double x, unsigned long ux, int *xexp, double *r1, double *r2) +static inline void log_kernel_amd64(double x, unsigned long long ux, int *xexp, double *r1, double *r2) {
int expadjust; @@ -1755,7 +1755,7 @@ static inline void log_kernel_amd64(double x, unsigned long ux, int *xexp, doubl cb_2 = 1.24999999978138668903e-02, /* 0x3f89999999865ede */ cb_3 = 2.23219810758559851206e-03; /* 0x3f6249423bd94741 */
- static const unsigned long + static const unsigned long long log_thresh1 = 0x3fee0faa00000000, log_thresh2 = 0x3ff1082c00000000;
@@ -1885,7 +1885,7 @@ static inline void log_kernel_amd64(double x, unsigned long ux, int *xexp, doubl
#ifdef DEBUGGING_PRINT #include <stdio.h> -char *d2b(long d, int bitsper, int point) +char *d2b(long long d, int bitsper, int point) { static char buff[200]; int i, j; @@ -1915,7 +1915,7 @@ char *d2b(long d, int bitsper, int point) extra precision, and return the result in r. Return value "region" tells how many lots of pi/2 were subtracted from x to put it in the range [-pi/4,pi/4], mod 4. */ -static inline void __remainder_piby2f_inline(unsigned long ux, double *r, int *region) +static inline void __remainder_piby2f_inline(unsigned long long ux, double *r, int *region) {
/* This method simulates multi-precision floating-point @@ -1925,13 +1925,13 @@ static inline void __remainder_piby2f_inline(unsigned long ux, double *r, int *r #else #define bitsper 36 #endif - unsigned long res[10]; - unsigned long u, carry, mask, mant, nextbits; + unsigned long long res[10]; + unsigned long long u, carry, mask, mant, nextbits; int first, last, i, rexp, xexp, resexp, ltb, determ, bc; double dx; static const double piby2 = 1.57079632679489655800e+00; /* 0x3ff921fb54442d18 */ - static unsigned long pibits[] = + static unsigned long long pibits[] = { 0LL, 5215LL, 13000023176LL, 11362338026LL, 67174558139LL, @@ -1943,7 +1943,7 @@ static inline void __remainder_piby2f_inline(unsigned long ux, double *r, int *r ux = ((ux & MANTBITS_DP64) | IMPBIT_DP64) >> 29;
- /* Now ux is the mantissa bit pattern of x as a long integer */ + /* Now ux is the mantissa bit pattern of x as a long long integer */ mask = 1; mask = (mask << bitsper) - 1;
@@ -2073,7 +2073,7 @@ static inline void __remainder_piby2f_inline(unsigned long ux, double *r, int *r #endif
/* Put the result exponent rexp onto the mantissa pattern */ - u = ((unsigned long)rexp + EXPBIAS_DP64) << EXPSHIFTBITS_DP64; + u = ((unsigned long long)rexp + EXPBIAS_DP64) << EXPSHIFTBITS_DP64; ux = (mant & MANTBITS_DP64) | u; if (determ) /* If we negated the mantissa we negate x too */ diff --git a/sdk/lib/crt/math/libm_sse2/libm_util.h b/sdk/lib/crt/math/libm_sse2/libm_util.h index e62d32d155f..0dde14a3637 100644 --- a/sdk/lib/crt/math/libm_sse2/libm_util.h +++ b/sdk/lib/crt/math/libm_sse2/libm_util.h @@ -27,17 +27,9 @@ #define LIBM_UTIL_AMD_H_INCLUDED 1
#define inline __inline -#undef long -#define long __int64
-#include "emmintrin.h" -#include "float.h" - - - -/* Compile-time verification that type long is the same size - as type double (i.e. we are really on a 64-bit machine) */ -void check_long_against_double_size(int machine_is_64_bit[(sizeof(long) == sizeof(double))?1:-1]); +#include <emmintrin.h> +#include <float.h>
/* Definitions for double functions on 64 bit machines */ @@ -98,7 +90,7 @@ void check_long_against_double_size(int machine_is_64_bit[(sizeof(long) == sizeo #define CLASS_POSITIVE_INFINITY 10
#define OLD_BITS_SP32(x) (*((unsigned int *)&x)) -#define OLD_BITS_DP64(x) (*((unsigned long *)&x)) +#define OLD_BITS_DP64(x) (*((unsigned long long *)&x))
/* Alternatives to the above functions which don't have problems when using high optimization levels on gcc */ @@ -117,13 +109,13 @@ void check_long_against_double_size(int machine_is_64_bit[(sizeof(long) == sizeo
#define GET_BITS_DP64(x, ux) \ { \ - volatile union {double d; unsigned long i;} _bitsy; \ + volatile union {double d; unsigned long long i;} _bitsy; \ _bitsy.d = (x); \ ux = _bitsy.i; \ } #define PUT_BITS_DP64(ux, x) \ { \ - volatile union {double d; unsigned long i;} _bitsy; \ + volatile union {double d; unsigned long long i;} _bitsy; \ _bitsy.i = (ux); \ x = _bitsy.d; \ } diff --git a/sdk/lib/crt/math/libm_sse2/logb.c b/sdk/lib/crt/math/libm_sse2/logb.c index f8680e43d08..3fc70e9be5b 100644 --- a/sdk/lib/crt/math/libm_sse2/logb.c +++ b/sdk/lib/crt/math/libm_sse2/logb.c @@ -38,8 +38,8 @@ THE SOFTWARE. double _logb(double x) {
- unsigned long ux; - long u; + unsigned long long ux; + long long u; GET_BITS_DP64(x, ux); u = ((ux & EXPBITS_DP64) >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64; if ((ux & ~SIGNBIT_DP64) == 0) diff --git a/sdk/lib/crt/math/libm_sse2/modf.c b/sdk/lib/crt/math/libm_sse2/modf.c index 0b0900cf66e..2583b9bc1ba 100644 --- a/sdk/lib/crt/math/libm_sse2/modf.c +++ b/sdk/lib/crt/math/libm_sse2/modf.c @@ -33,8 +33,8 @@ double modf(double x, double *iptr) each with the same sign as x. */
- long xexp; - unsigned long ux, ax, mask; + long long xexp; + unsigned long long ux, ax, mask;
GET_BITS_DP64(x, ux); ax = ux & (~SIGNBIT_DP64); diff --git a/sdk/lib/crt/math/libm_sse2/remainder.c b/sdk/lib/crt/math/libm_sse2/remainder.c index 67a4d0a24d4..8de74d7f476 100644 --- a/sdk/lib/crt/math/libm_sse2/remainder.c +++ b/sdk/lib/crt/math/libm_sse2/remainder.c @@ -52,7 +52,7 @@ static inline void dekker_mul12(double x, double y, { double hx, tx, hy, ty; /* Split x into hx (head) and tx (tail). Do the same for y. */ - unsigned long u; + unsigned long long u; GET_BITS_DP64(x, u); u &= 0xfffffffff8000000; PUT_BITS_DP64(u, hx); @@ -79,7 +79,7 @@ double remainder(double x, double y) { double dx, dy, scale, w, t, v, c, cc; int i, ntimes, xexp, yexp; - unsigned long u, ux, uy, ax, ay, todd; + unsigned long long u, ux, uy, ax, ay, todd; unsigned int sw;
dx = x; @@ -227,7 +227,7 @@ double remainder(double x, double y) w = scaleDouble_3(dy, ntimes * 52);
/* Set scale = 2^(-52) */ - PUT_BITS_DP64((unsigned long)(-52 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, + PUT_BITS_DP64((unsigned long long)(-52 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, scale); }
@@ -252,7 +252,7 @@ double remainder(double x, double y) it loses the last (106th) bit of its quad precision result. */
/* Set dx = dx - w * t, where t is equal to trunc(dx/w). */ - t = (double)(long)(dx / w); + t = (double)(long long)(dx / w); /* At this point, t may be one too large due to rounding of dx/w */
@@ -277,8 +277,8 @@ double remainder(double x, double y)
/* One more time */ /* Variable todd says whether the integer t is odd or not */ - t = (double)(long)(dx / w); - todd = ((long)(dx / w)) & 1; + t = (double)(long long)(dx / w); + todd = ((long long)(dx / w)) & 1; dekker_mul12(w, t, &c, &cc); v = dx - c; dx = v + (((dx - v) - c) - cc); diff --git a/sdk/lib/crt/math/libm_sse2/remainder_piby2.c b/sdk/lib/crt/math/libm_sse2/remainder_piby2.c index 412bcb26df6..13fdd3186d7 100644 --- a/sdk/lib/crt/math/libm_sse2/remainder_piby2.c +++ b/sdk/lib/crt/math/libm_sse2/remainder_piby2.c @@ -42,11 +42,11 @@ void __remainder_piby2(double x, double *r, double *rr, int *region) piby2_part2 = 1.58932547122958567343e-08, /* 0x3e5110b460000000 */ piby2_part3 = 6.12323399573676480327e-17; /* 0x3c91a62633145c06 */ const int bitsper = 10; - unsigned long res[500]; - unsigned long ux, u, carry, mask, mant, highbitsrr; + unsigned long long res[500]; + unsigned long long ux, u, carry, mask, mant, highbitsrr; int first, last, i, rexp, xexp, resexp, ltb, determ; double xx, t; - static unsigned long pibits[] = + static unsigned long long pibits[] = { 0, 0, 0, 0, 0, 0, 162, 998, 54, 915, 580, 84, 671, 777, 855, 839, @@ -204,7 +204,7 @@ void __remainder_piby2(double x, double *r, double *rr, int *region)
/* Put the result exponent rexp onto the mantissa pattern */ - u = ((unsigned long)rexp + EXPBIAS_DP64) << EXPSHIFTBITS_DP64; + u = ((unsigned long long)rexp + EXPBIAS_DP64) << EXPSHIFTBITS_DP64; ux = (mant & MANTBITS_DP64) | u; if (determ) /* If we negated the mantissa we negate x too */ @@ -213,7 +213,7 @@ void __remainder_piby2(double x, double *r, double *rr, int *region)
/* Create the bit pattern for rr */ highbitsrr >>= 12; /* Note this is shifted one place too far */ - u = ((unsigned long)rexp + EXPBIAS_DP64 - 53) << EXPSHIFTBITS_DP64; + u = ((unsigned long long)rexp + EXPBIAS_DP64 - 53) << EXPSHIFTBITS_DP64; PUT_BITS_DP64(u, t); u |= highbitsrr; PUT_BITS_DP64(u, xx); diff --git a/sdk/lib/crt/math/libm_sse2/remainder_piby2f.c b/sdk/lib/crt/math/libm_sse2/remainder_piby2f.c index 71e97e8b1f5..a7a721e2609 100644 --- a/sdk/lib/crt/math/libm_sse2/remainder_piby2f.c +++ b/sdk/lib/crt/math/libm_sse2/remainder_piby2f.c @@ -32,20 +32,20 @@ THE SOFTWARE. extra precision, and return the result in r. Return value "region" tells how many lots of pi/2 were subtracted from x to put it in the range [-pi/4,pi/4], mod 4. */ -void __remainder_piby2f(unsigned long ux, double *r, int *region) +void __remainder_piby2f(unsigned long long ux, double *r, int *region) {
/* This method simulates multi-precision floating-point arithmetic and is accurate for all 1 <= x < infinity */ #define bitsper 36 - unsigned long res[10]; - unsigned long u, carry, mask, mant, nextbits; + unsigned long long res[10]; + unsigned long long u, carry, mask, mant, nextbits; int first, last, i, rexp, xexp, resexp, ltb, determ, bc; double dx; static const double piby2 = 1.57079632679489655800e+00; /* 0x3ff921fb54442d18 */ - static unsigned long pibits[] = + static unsigned long long pibits[] = { 0LL, 5215LL, 13000023176LL, 11362338026LL, 67174558139LL, @@ -156,7 +156,7 @@ void __remainder_piby2f(unsigned long ux, double *r, int *region)
/* Put the result exponent rexp onto the mantissa pattern */ - u = ((unsigned long)rexp + EXPBIAS_DP64) << EXPSHIFTBITS_DP64; + u = ((unsigned long long)rexp + EXPBIAS_DP64) << EXPSHIFTBITS_DP64; ux = (mant & MANTBITS_DP64) | u; if (determ) /* If we negated the mantissa we negate x too */ diff --git a/sdk/lib/crt/math/libm_sse2/remainderf.c b/sdk/lib/crt/math/libm_sse2/remainderf.c index 1b389b0d8e4..549fc9439c4 100644 --- a/sdk/lib/crt/math/libm_sse2/remainderf.c +++ b/sdk/lib/crt/math/libm_sse2/remainderf.c @@ -64,7 +64,7 @@ float remainderf(float x, float y) { double dx, dy, scale, w, t; int i, ntimes, xexp, yexp; - unsigned long ux, uy, ax, ay; + unsigned long long ux, uy, ax, ay;
unsigned int sw;
@@ -190,11 +190,11 @@ float remainderf(float x, float y) ntimes = (xexp - yexp) / 24;
/* Set w = y * 2^(24*ntimes) */ - PUT_BITS_DP64((unsigned long)(ntimes * 24 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, + PUT_BITS_DP64((unsigned long long)(ntimes * 24 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, scale); w = scale * dy; /* Set scale = 2^(-24) */ - PUT_BITS_DP64((unsigned long)(-24 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, + PUT_BITS_DP64((unsigned long long)(-24 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, scale); }
diff --git a/sdk/lib/crt/math/libm_sse2/simd.h b/sdk/lib/crt/math/libm_sse2/simd.h index c5f93ff610f..0049bff9084 100644 --- a/sdk/lib/crt/math/libm_sse2/simd.h +++ b/sdk/lib/crt/math/libm_sse2/simd.h @@ -66,7 +66,7 @@ typedef UINT_PTR AWORD; // x86-64 safe typedef union { float f; - unsigned long l; + unsigned long long l; } LFLOAT;
//typedef struct @@ -78,7 +78,7 @@ typedef unsigned _int64 QWORD; typedef union { double f; - unsigned long l[2]; + unsigned long long l[2]; } LDOUBLE;
typedef __declspec(align(16)) struct @@ -313,7 +313,7 @@ typedef struct { unsigned char opcode; unsigned char rmbyte; union { - unsigned long offset; // this will need work for x86-64 + unsigned long long offset; // this will need work for x86-64 unsigned char imm8; } data;
diff --git a/sdk/lib/crt/math/libm_sse2/sinh.c b/sdk/lib/crt/math/libm_sse2/sinh.c index 5b628dfbc19..f01b10c4ab7 100644 --- a/sdk/lib/crt/math/libm_sse2/sinh.c +++ b/sdk/lib/crt/math/libm_sse2/sinh.c @@ -43,8 +43,10 @@ THE SOFTWARE.
#include "libm_errno.h"
- +#ifdef _MSC_VER #pragma function(sinh) +#endif + double sinh(double x) { /* @@ -229,7 +231,7 @@ double sinh(double x) 3.64177136406482197344e+06, /* 0x414bc8d5ae99ad14 */ 7.63580561355670914054e+06}; /* 0x415d20d76744835c */
- unsigned long ux, aux, xneg; + unsigned long long ux, aux, xneg; double y, z, z1, z2; int m;
diff --git a/sdk/lib/crt/math/libm_sse2/sinhf.c b/sdk/lib/crt/math/libm_sse2/sinhf.c index ea6f6761d8f..746aafe6339 100644 --- a/sdk/lib/crt/math/libm_sse2/sinhf.c +++ b/sdk/lib/crt/math/libm_sse2/sinhf.c @@ -41,11 +41,12 @@ THE SOFTWARE.
#include "libm_errno.h"
+#ifdef _MSC_VER // Disable "C4163: not available as intrinsic function" warning that older // compilers may issue here. #pragma warning(disable:4163) #pragma function(sinhf) - +#endif
float sinhf(float fx) { @@ -153,7 +154,7 @@ float sinhf(float fx) 7.93006726156715250000e+14, /* 0x430689e221bc8d5a */ 2.15561577355759750000e+15}; /* 0x431ea215a1d20d76 */
- unsigned long ux, aux, xneg; + unsigned long long ux, aux, xneg; double x = fx, y, z, z1, z2; int m;
diff --git a/sdk/lib/crt/math/libm_sse2/sqrt.c b/sdk/lib/crt/math/libm_sse2/sqrt.c index ddadadaedc8..d2bd8963e46 100644 --- a/sdk/lib/crt/math/libm_sse2/sqrt.c +++ b/sdk/lib/crt/math/libm_sse2/sqrt.c @@ -49,7 +49,7 @@ double sqrt(double x) return sqrt_amd_inline(x); #else double r; - unsigned long ux; + unsigned long long ux; GET_BITS_DP64(x, ux);
/* Check for special cases for Microsoft error handling */ diff --git a/sdk/lib/crt/math/libm_sse2/tan.c b/sdk/lib/crt/math/libm_sse2/tan.c index 0a86a2ef606..fdf1834d910 100644 --- a/sdk/lib/crt/math/libm_sse2/tan.c +++ b/sdk/lib/crt/math/libm_sse2/tan.c @@ -98,7 +98,7 @@ static inline double tan_piby4(double x, double xx, int recip) { /* Compute -1.0/(t1 + t2) accurately */ double trec, trec_top, z1, z2, t; - unsigned long u; + unsigned long long u; t = t1 + t2; GET_BITS_DP64(t, u); u &= 0xffffffff00000000; @@ -115,14 +115,16 @@ static inline double tan_piby4(double x, double xx, int recip) return t1 + t2; }
+#ifdef _MSC_VER #pragma function(tan) +#endif
double tan(double x) { double r, rr; int region, xneg;
- unsigned long ux, ax; + unsigned long long ux, ax; GET_BITS_DP64(x, ux); ax = (ux & ~SIGNBIT_DP64); if (ax <= 0x3fe921fb54442d18) /* abs(x) <= pi/4 */ @@ -183,7 +185,7 @@ double tan(double x) piby2_3tail = 8.47842766036889956997e-32; /* 0x397b839a252049c1 */ double t, rhead, rtail; int npi2; - unsigned long uy, xexp, expdiff; + unsigned long long uy, xexp, expdiff; xexp = ax >> EXPSHIFTBITS_DP64; /* How many pi/2 is x a multiple of? */ if (ax <= 0x400f6a7a2955385e) /* 5pi/4 */ diff --git a/sdk/lib/crt/math/libm_sse2/tanf.c b/sdk/lib/crt/math/libm_sse2/tanf.c index 8a86a2d2b73..49808d34aff 100644 --- a/sdk/lib/crt/math/libm_sse2/tanf.c +++ b/sdk/lib/crt/math/libm_sse2/tanf.c @@ -39,10 +39,12 @@ THE SOFTWARE.
#include "libm_errno.h"
+#ifdef _MSC_VER // Disable "C4163: not available as intrinsic function" warning that older // compilers may issue here. #pragma warning(disable:4163) #pragma function(tanf) +#endif
/* tan(x) approximation valid on the interval [-pi/4,pi/4]. If recip is true return -1/tan(x) instead. */ @@ -72,7 +74,7 @@ float tanf(float x) double r, dx; int region, xneg;
- unsigned long ux, ax; + unsigned long long ux, ax;
dx = x;
@@ -135,7 +137,7 @@ float tanf(float x) piby2_3tail = 8.47842766036889956997e-32; /* 0x397b839a252049c1 */ double t, rhead, rtail; int npi2; - unsigned long uy, xexp, expdiff; + unsigned long long uy, xexp, expdiff; xexp = ax >> EXPSHIFTBITS_DP64; /* How many pi/2 is dx a multiple of? */ if (ax <= 0x400f6a7a2955385e) /* 5pi/4 */ diff --git a/sdk/lib/crt/math/libm_sse2/tanh.c b/sdk/lib/crt/math/libm_sse2/tanh.c index 49385275c26..14ddc17869c 100644 --- a/sdk/lib/crt/math/libm_sse2/tanh.c +++ b/sdk/lib/crt/math/libm_sse2/tanh.c @@ -39,8 +39,10 @@ THE SOFTWARE.
#include "libm_errno.h"
- +#ifdef _MSC_VER #pragma function(tanh) +#endif + double tanh(double x) { /* @@ -57,7 +59,7 @@ double tanh(double x) log2_by_32_tail = 5.68948749532545630390e-11, /* 0x3dcf473de6af278e */ large_threshold = 20.0; /* 0x4034000000000000 */
- unsigned long ux, aux, xneg; + unsigned long long ux, aux, xneg; double y, z, p, z1, z2; int m;
diff --git a/sdk/lib/crt/math/libm_sse2/tanhf.c b/sdk/lib/crt/math/libm_sse2/tanhf.c index ab0ddc70a4a..d481019e916 100644 --- a/sdk/lib/crt/math/libm_sse2/tanhf.c +++ b/sdk/lib/crt/math/libm_sse2/tanhf.c @@ -39,10 +39,12 @@ THE SOFTWARE.
#include "libm_errno.h"
+#ifdef _MSC_VER // Disable "C4163: not available as intrinsic function" warning that older // compilers may issue here. #pragma warning(disable:4163) #pragma function(tanhf) +#endif
float tanhf(float x) {