mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:35:41 +00:00
[LIBM] Fix build
This commit is contained in:
parent
4afb647c78
commit
9e8ed3f817
35 changed files with 139 additions and 112 deletions
|
@ -32,7 +32,7 @@ double FN_PROTOTYPE(_chgsign)(double x)
|
||||||
/* Returns x with its sign reversed.
|
/* Returns x with its sign reversed.
|
||||||
NaNs are not considered special; their sign bits are handled
|
NaNs are not considered special; their sign bits are handled
|
||||||
the same as for any other number */
|
the same as for any other number */
|
||||||
unsigned long u;
|
unsigned long long u;
|
||||||
GET_BITS_DP64(x, u);
|
GET_BITS_DP64(x, u);
|
||||||
u ^= SIGNBIT_DP64;
|
u ^= SIGNBIT_DP64;
|
||||||
PUT_BITS_DP64(u, x);
|
PUT_BITS_DP64(u, x);
|
||||||
|
|
|
@ -34,7 +34,7 @@ THE SOFTWARE.
|
||||||
double FN_PROTOTYPE(_copysign)(double x, double y)
|
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(x, ux);
|
||||||
GET_BITS_DP64(y, uy);
|
GET_BITS_DP64(y, uy);
|
||||||
if ((ux ^ uy) & SIGNBIT_DP64)
|
if ((ux ^ uy) & SIGNBIT_DP64)
|
||||||
|
|
|
@ -33,7 +33,7 @@ int FN_PROTOTYPE(_finite)(double x)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
unsigned long ux;
|
unsigned long long ux;
|
||||||
GET_BITS_DP64(x, ux);
|
GET_BITS_DP64(x, ux);
|
||||||
return (int)(((ux & ~SIGNBIT_DP64) - PINFBITPATT_DP64) >> 63);
|
return (int)(((ux & ~SIGNBIT_DP64) - PINFBITPATT_DP64) >> 63);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma function(acos)
|
#pragma function(acos)
|
||||||
|
#endif
|
||||||
|
|
||||||
double FN_PROTOTYPE(acos)(double x)
|
double FN_PROTOTYPE(acos)(double x)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +70,7 @@ double FN_PROTOTYPE(acos)(double x)
|
||||||
double u, y, s=0.0, r;
|
double u, y, s=0.0, r;
|
||||||
int xexp, xnan, transform=0;
|
int xexp, xnan, transform=0;
|
||||||
|
|
||||||
unsigned long ux, aux, xneg;
|
unsigned long long ux, aux, xneg;
|
||||||
GET_BITS_DP64(x, ux);
|
GET_BITS_DP64(x, ux);
|
||||||
aux = ux & ~SIGNBIT_DP64;
|
aux = ux & ~SIGNBIT_DP64;
|
||||||
xneg = (ux & SIGNBIT_DP64);
|
xneg = (ux & SIGNBIT_DP64);
|
||||||
|
@ -133,7 +134,7 @@ double FN_PROTOTYPE(acos)(double x)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double c, s1;
|
double c, s1;
|
||||||
unsigned long us;
|
unsigned long long us;
|
||||||
GET_BITS_DP64(s, us);
|
GET_BITS_DP64(s, us);
|
||||||
PUT_BITS_DP64(0xffffffff00000000 & us, s1);
|
PUT_BITS_DP64(0xffffffff00000000 & us, s1);
|
||||||
c = (r-s1*s1)/(s+s1);
|
c = (r-s1*s1)/(s+s1);
|
||||||
|
|
|
@ -37,11 +37,12 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
// Disable "C4163: not available as intrinsic function" warning that older
|
// Disable "C4163: not available as intrinsic function" warning that older
|
||||||
// compilers may issue here.
|
// compilers may issue here.
|
||||||
#pragma warning(disable:4163)
|
#pragma warning(disable:4163)
|
||||||
#pragma function(acosf)
|
#pragma function(acosf)
|
||||||
|
#endif
|
||||||
|
|
||||||
float FN_PROTOTYPE(acosf)(float x)
|
float FN_PROTOTYPE(acosf)(float x)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,7 +37,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma function(asin)
|
#pragma function(asin)
|
||||||
|
#endif
|
||||||
|
|
||||||
double FN_PROTOTYPE(asin)(double x)
|
double FN_PROTOTYPE(asin)(double x)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +67,7 @@ double FN_PROTOTYPE(asin)(double x)
|
||||||
double u, v, y, s=0.0, r;
|
double u, v, y, s=0.0, r;
|
||||||
int xexp, xnan, transform=0;
|
int xexp, xnan, transform=0;
|
||||||
|
|
||||||
unsigned long ux, aux, xneg;
|
unsigned long long ux, aux, xneg;
|
||||||
GET_BITS_DP64(x, ux);
|
GET_BITS_DP64(x, ux);
|
||||||
aux = ux & ~SIGNBIT_DP64;
|
aux = ux & ~SIGNBIT_DP64;
|
||||||
xneg = (ux & SIGNBIT_DP64);
|
xneg = (ux & SIGNBIT_DP64);
|
||||||
|
@ -127,7 +129,7 @@ double FN_PROTOTYPE(asin)(double x)
|
||||||
{ /* Reconstruct asin carefully in transformed region */
|
{ /* Reconstruct asin carefully in transformed region */
|
||||||
{
|
{
|
||||||
double c, s1, p, q;
|
double c, s1, p, q;
|
||||||
unsigned long us;
|
unsigned long long us;
|
||||||
GET_BITS_DP64(s, us);
|
GET_BITS_DP64(s, us);
|
||||||
PUT_BITS_DP64(0xffffffff00000000 & us, s1);
|
PUT_BITS_DP64(0xffffffff00000000 & us, s1);
|
||||||
c = (r-s1*s1)/(s+s1);
|
c = (r-s1*s1)/(s+s1);
|
||||||
|
|
|
@ -37,11 +37,12 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
// Disable "C4163: not available as intrinsic function" warning that older
|
// Disable "C4163: not available as intrinsic function" warning that older
|
||||||
// compilers may issue here.
|
// compilers may issue here.
|
||||||
#pragma warning(disable:4163)
|
#pragma warning(disable:4163)
|
||||||
#pragma function(asinf)
|
#pragma function(asinf)
|
||||||
|
#endif
|
||||||
|
|
||||||
float FN_PROTOTYPE(asinf)(float x)
|
float FN_PROTOTYPE(asinf)(float x)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,7 +37,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma function(atan)
|
#pragma function(atan)
|
||||||
|
#endif
|
||||||
|
|
||||||
double FN_PROTOTYPE(atan)(double x)
|
double FN_PROTOTYPE(atan)(double x)
|
||||||
{
|
{
|
||||||
|
@ -49,7 +51,7 @@ double FN_PROTOTYPE(atan)(double x)
|
||||||
|
|
||||||
/* Find properties of argument x. */
|
/* Find properties of argument x. */
|
||||||
|
|
||||||
unsigned long ux, aux, xneg;
|
unsigned long long ux, aux, xneg;
|
||||||
GET_BITS_DP64(x, ux);
|
GET_BITS_DP64(x, ux);
|
||||||
aux = ux & ~SIGNBIT_DP64;
|
aux = ux & ~SIGNBIT_DP64;
|
||||||
xneg = (ux != aux);
|
xneg = (ux != aux);
|
||||||
|
|
|
@ -45,7 +45,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma function(atan2)
|
#pragma function(atan2)
|
||||||
|
#endif
|
||||||
|
|
||||||
double FN_PROTOTYPE(atan2)(double y, double x)
|
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. */
|
/* 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(x, ux);
|
||||||
GET_BITS_DP64(y, uy);
|
GET_BITS_DP64(y, uy);
|
||||||
|
|
|
@ -41,10 +41,12 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
// Disable "C4163: not available as intrinsic function" warning that older
|
// Disable "C4163: not available as intrinsic function" warning that older
|
||||||
// compilers may issue here.
|
// compilers may issue here.
|
||||||
#pragma warning(disable:4163)
|
#pragma warning(disable:4163)
|
||||||
#pragma function(atan2f)
|
#pragma function(atan2f)
|
||||||
|
#endif
|
||||||
|
|
||||||
float FN_PROTOTYPE(atan2f)(float fy, float fx)
|
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. */
|
/* 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(x, ux);
|
||||||
GET_BITS_DP64(y, uy);
|
GET_BITS_DP64(y, uy);
|
||||||
|
|
|
@ -37,10 +37,12 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
// Disable "C4163: not available as intrinsic function" warning that older
|
// Disable "C4163: not available as intrinsic function" warning that older
|
||||||
// compilers may issue here.
|
// compilers may issue here.
|
||||||
#pragma warning(disable:4163)
|
#pragma warning(disable:4163)
|
||||||
#pragma function(atanf)
|
#pragma function(atanf)
|
||||||
|
#endif
|
||||||
|
|
||||||
float FN_PROTOTYPE(atanf)(float fx)
|
float FN_PROTOTYPE(atanf)(float fx)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +58,7 @@ float FN_PROTOTYPE(atanf)(float fx)
|
||||||
|
|
||||||
/* Find properties of argument fx. */
|
/* Find properties of argument fx. */
|
||||||
|
|
||||||
unsigned long ux, aux, xneg;
|
unsigned long long ux, aux, xneg;
|
||||||
|
|
||||||
GET_BITS_DP64(x, ux);
|
GET_BITS_DP64(x, ux);
|
||||||
aux = ux & ~SIGNBIT_DP64;
|
aux = ux & ~SIGNBIT_DP64;
|
||||||
|
|
|
@ -40,8 +40,8 @@ THE SOFTWARE.
|
||||||
double FN_PROTOTYPE(ceil)(double x)
|
double FN_PROTOTYPE(ceil)(double x)
|
||||||
{
|
{
|
||||||
double r;
|
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);
|
GET_BITS_DP64(x, ux);
|
||||||
ax = ux & (~SIGNBIT_DP64);
|
ax = ux & (~SIGNBIT_DP64);
|
||||||
|
|
|
@ -41,8 +41,10 @@ THE SOFTWARE.
|
||||||
#undef USE_VAL_WITH_FLAGS
|
#undef USE_VAL_WITH_FLAGS
|
||||||
#undef USE_HANDLE_ERROR
|
#undef USE_HANDLE_ERROR
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma function(cosh)
|
#pragma function(cosh)
|
||||||
|
#endif
|
||||||
|
|
||||||
double cosh(double x)
|
double cosh(double x)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -230,10 +232,10 @@ double cosh(double x)
|
||||||
3.64177136406482197344e+06, /* 0x414bc8d5ae99ad14 */
|
3.64177136406482197344e+06, /* 0x414bc8d5ae99ad14 */
|
||||||
7.63580561355670914054e+06}; /* 0x415d20d76744835c */
|
7.63580561355670914054e+06}; /* 0x415d20d76744835c */
|
||||||
|
|
||||||
unsigned long ux, aux, xneg;
|
unsigned long long ux, aux, xneg;
|
||||||
double y, z, z1, z2;
|
double y, z, z1, z2;
|
||||||
int m;
|
int m;
|
||||||
|
|
||||||
/* Special cases */
|
/* Special cases */
|
||||||
|
|
||||||
GET_BITS_DP64(x, ux);
|
GET_BITS_DP64(x, ux);
|
||||||
|
|
|
@ -41,10 +41,12 @@ THE SOFTWARE.
|
||||||
#undef USE_VALF_WITH_FLAGS
|
#undef USE_VALF_WITH_FLAGS
|
||||||
#undef USE_HANDLE_ERRORF
|
#undef USE_HANDLE_ERRORF
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
// Disable "C4163: not available as intrinsic function" warning that older
|
// Disable "C4163: not available as intrinsic function" warning that older
|
||||||
// compilers may issue here.
|
// compilers may issue here.
|
||||||
#pragma warning(disable:4163)
|
#pragma warning(disable:4163)
|
||||||
#pragma function(coshf)
|
#pragma function(coshf)
|
||||||
|
#endif
|
||||||
|
|
||||||
float coshf(float fx)
|
float coshf(float fx)
|
||||||
{
|
{
|
||||||
|
@ -154,7 +156,7 @@ float coshf(float fx)
|
||||||
7.93006726156715250000e+14, /* 0x430689e221bc8d5a */
|
7.93006726156715250000e+14, /* 0x430689e221bc8d5a */
|
||||||
2.15561577355759750000e+15}; /* 0x431ea215a1d20d76 */
|
2.15561577355759750000e+15}; /* 0x431ea215a1d20d76 */
|
||||||
|
|
||||||
unsigned long ux, aux, xneg;
|
unsigned long long ux, aux, xneg;
|
||||||
unsigned int uhx;
|
unsigned int uhx;
|
||||||
double x = fx, y, z, z1, z2;
|
double x = fx, y, z, z1, z2;
|
||||||
int m;
|
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 */
|
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 */
|
else if (aux >= PINFBITPATT_DP64) /* |x| is NaN or Inf */
|
||||||
|
{
|
||||||
if (aux > PINFBITPATT_DP64) /* x is NaN */
|
if (aux > PINFBITPATT_DP64) /* x is NaN */
|
||||||
{
|
{
|
||||||
GET_BITS_SP32(fx, uhx);
|
GET_BITS_SP32(fx, uhx);
|
||||||
|
@ -177,6 +180,7 @@ float coshf(float fx)
|
||||||
}
|
}
|
||||||
else /* x is infinity */
|
else /* x is infinity */
|
||||||
return infinityf_with_flags(0);
|
return infinityf_with_flags(0);
|
||||||
|
}
|
||||||
xneg = (aux != ux);
|
xneg = (aux != ux);
|
||||||
|
|
||||||
y = x;
|
y = x;
|
||||||
|
|
|
@ -58,7 +58,7 @@ double FN_PROTOTYPE(_exp2)(double x)
|
||||||
|
|
||||||
double y, z1, z2, z, hx, tx, y1, y2;
|
double y, z1, z2, z, hx, tx, y1, y2;
|
||||||
int m;
|
int m;
|
||||||
unsigned long ux, ax;
|
unsigned long long ux, ax;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Computation of exp2(x).
|
Computation of exp2(x).
|
||||||
|
@ -121,7 +121,7 @@ double FN_PROTOTYPE(_exp2)(double x)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Split x into hx (head) and tx (tail). */
|
/* Split x into hx (head) and tx (tail). */
|
||||||
unsigned long u;
|
unsigned long long u;
|
||||||
hx = x;
|
hx = x;
|
||||||
GET_BITS_DP64(hx, u);
|
GET_BITS_DP64(hx, u);
|
||||||
u &= 0xfffffffff8000000;
|
u &= 0xfffffffff8000000;
|
||||||
|
|
|
@ -37,10 +37,10 @@ THE SOFTWARE.
|
||||||
double FN_PROTOTYPE(floor)(double x)
|
double FN_PROTOTYPE(floor)(double x)
|
||||||
{
|
{
|
||||||
double r;
|
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);
|
GET_BITS_DP64(x, ux);
|
||||||
ax = ux & (~SIGNBIT_DP64);
|
ax = ux & (~SIGNBIT_DP64);
|
||||||
|
|
|
@ -26,16 +26,18 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#ifdef TEST_STANDALONE
|
#ifdef TEST_STANDALONE
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma section (".CRT$XIC",long,read)
|
#pragma section (".CRT$XIC",long,read)
|
||||||
typedef void (__cdecl *_PIFV)(void);
|
#define _CRTALLOC(x) __declspec(allocate(x))
|
||||||
|
#endif /* _MSC_VER */
|
||||||
#else
|
#else
|
||||||
|
#include <intrin.h>
|
||||||
#include <sect_attribs.h>
|
#include <sect_attribs.h>
|
||||||
#include <windows.h>
|
#undef _CRTALLOC
|
||||||
#include <cruntime.h>
|
#define _CRTALLOC(x)
|
||||||
#include <internal.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _CRTALLOC(x) __declspec(allocate(x))
|
typedef int (__cdecl *_PIFV)(void); // FIXME: include process.h?
|
||||||
|
|
||||||
int __fma3_is_available = 0;
|
int __fma3_is_available = 0;
|
||||||
int __use_fma3_lib = 0;
|
int __use_fma3_lib = 0;
|
||||||
|
|
|
@ -39,6 +39,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#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)
|
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
|
#ifdef FAST_BUT_GREATER_THAN_ONE_ULP
|
||||||
double r, retval;
|
double r, retval;
|
||||||
unsigned long xexp, yexp, ux, uy;
|
unsigned long long xexp, yexp, ux, uy;
|
||||||
#else
|
#else
|
||||||
double u, r, retval, hx, tx, x2, hy, ty, y2, hs, ts;
|
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
|
#endif
|
||||||
int dexp, expadjust;
|
int dexp, expadjust;
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ float FN_PROTOTYPE(_hypotf)(float x, float y)
|
||||||
const double large = 3.40282346638528859812e+38; /* 0x47efffffe0000000 */
|
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);
|
GET_BITS_DP64(x, avx);
|
||||||
avx &= ~SIGNBIT_DP64;
|
avx &= ~SIGNBIT_DP64;
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
are not checked */
|
are not checked */
|
||||||
static inline void splitDouble(double x, int *e, double *m)
|
static inline void splitDouble(double x, int *e, double *m)
|
||||||
{
|
{
|
||||||
unsigned long ux, uy;
|
unsigned long long ux, uy;
|
||||||
GET_BITS_DP64(x, ux);
|
GET_BITS_DP64(x, ux);
|
||||||
uy = ux;
|
uy = ux;
|
||||||
ux &= EXPBITS_DP64;
|
ux &= EXPBITS_DP64;
|
||||||
|
@ -66,7 +66,7 @@ static inline void splitDouble(double x, int *e, double *m)
|
||||||
assumption, e will be even on exit. */
|
assumption, e will be even on exit. */
|
||||||
static inline void splitDouble_2(double x, int *e, double *m)
|
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);
|
GET_BITS_DP64(x, ux);
|
||||||
vx = ux;
|
vx = ux;
|
||||||
ux &= EXPBITS_DP64;
|
ux &= EXPBITS_DP64;
|
||||||
|
@ -117,7 +117,7 @@ static inline double scaleDouble_1(double x, int n)
|
||||||
{
|
{
|
||||||
double t;
|
double t;
|
||||||
/* Construct the number t = 2.0**n */
|
/* 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;
|
return x*t;
|
||||||
}
|
}
|
||||||
#endif /* USE_SCALEDOUBLE_1 */
|
#endif /* USE_SCALEDOUBLE_1 */
|
||||||
|
@ -133,8 +133,8 @@ static inline double scaleDouble_2(double x, int n)
|
||||||
n1 = n / 2;
|
n1 = n / 2;
|
||||||
n2 = n - n1;
|
n2 = n - n1;
|
||||||
/* Construct the numbers t1 = 2.0**n1 and t2 = 2.0**n2 */
|
/* 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 long)n1 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t1);
|
||||||
PUT_BITS_DP64(((long)n2 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t2);
|
PUT_BITS_DP64(((long long)n2 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t2);
|
||||||
return (x*t1)*t2;
|
return (x*t1)*t2;
|
||||||
}
|
}
|
||||||
#endif /* USE_SCALEDOUBLE_2 */
|
#endif /* USE_SCALEDOUBLE_2 */
|
||||||
|
@ -151,9 +151,9 @@ static inline double scaleDouble_3(double x, int n)
|
||||||
n2 = (n - n1) / 2;
|
n2 = (n - n1) / 2;
|
||||||
n3 = n - n1 - n2;
|
n3 = n - n1 - n2;
|
||||||
/* Construct the numbers t1 = 2.0**n1, t2 = 2.0**n2 and t3 = 2.0**n3 */
|
/* 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 long)n1 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t1);
|
||||||
PUT_BITS_DP64(((long)n2 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t2);
|
PUT_BITS_DP64(((long long)n2 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t2);
|
||||||
PUT_BITS_DP64(((long)n3 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t3);
|
PUT_BITS_DP64(((long long)n3 + EXPBIAS_DP64) << EXPSHIFTBITS_DP64, t3);
|
||||||
return ((x*t1)*t2)*t3;
|
return ((x*t1)*t2)*t3;
|
||||||
}
|
}
|
||||||
#endif /* USE_SCALEDOUBLE_3 */
|
#endif /* USE_SCALEDOUBLE_3 */
|
||||||
|
@ -393,7 +393,7 @@ static inline double infinity_with_flags(int flags)
|
||||||
{
|
{
|
||||||
double z;
|
double z;
|
||||||
raise_fpsw_flags(flags);
|
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;
|
return z;
|
||||||
}
|
}
|
||||||
#endif /* USE_INFINITY_WITH_FLAGS */
|
#endif /* USE_INFINITY_WITH_FLAGS */
|
||||||
|
@ -419,7 +419,7 @@ static inline float infinityf_with_flags(int flags)
|
||||||
double _handle_error(
|
double _handle_error(
|
||||||
char *fname,
|
char *fname,
|
||||||
int opcode,
|
int opcode,
|
||||||
unsigned long value,
|
unsigned long long value,
|
||||||
int type,
|
int type,
|
||||||
int flags,
|
int flags,
|
||||||
int error,
|
int error,
|
||||||
|
@ -430,7 +430,7 @@ double _handle_error(
|
||||||
float _handle_errorf(
|
float _handle_errorf(
|
||||||
char *fname,
|
char *fname,
|
||||||
int opcode,
|
int opcode,
|
||||||
unsigned long value,
|
unsigned long long value,
|
||||||
int type,
|
int type,
|
||||||
int flags,
|
int flags,
|
||||||
int error,
|
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
|
/* 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
|
as ux by 2**1024. There are no checks that the input number is
|
||||||
scalable by that amount. */
|
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;
|
double y;
|
||||||
|
|
||||||
if ((ux & EXPBITS_DP64) == 0)
|
if ((ux & EXPBITS_DP64) == 0)
|
||||||
|
@ -773,17 +773,17 @@ static inline void scaleUpDouble1024(unsigned long ux, unsigned long *ur)
|
||||||
#if defined(USE_SCALEDOWNDOUBLE)
|
#if defined(USE_SCALEDOWNDOUBLE)
|
||||||
/* Scales down a double whose bit pattern is given as ux by 2**k.
|
/* 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. */
|
There are no checks that the input number is scalable by that amount. */
|
||||||
static inline void scaleDownDouble(unsigned long ux, int k,
|
static inline void scaleDownDouble(unsigned long long ux, int k,
|
||||||
unsigned long *ur)
|
unsigned long long *ur)
|
||||||
{
|
{
|
||||||
unsigned long uy, uk, ax, xsign;
|
unsigned long long uy, uk, ax, xsign;
|
||||||
int n, shift;
|
int n, shift;
|
||||||
xsign = ux & SIGNBIT_DP64;
|
xsign = ux & SIGNBIT_DP64;
|
||||||
ax = ux & ~SIGNBIT_DP64;
|
ax = ux & ~SIGNBIT_DP64;
|
||||||
n = (int)((ax & EXPBITS_DP64) >> EXPSHIFTBITS_DP64) - k;
|
n = (int)((ax & EXPBITS_DP64) >> EXPSHIFTBITS_DP64) - k;
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
{
|
||||||
uk = (unsigned long)n << EXPSHIFTBITS_DP64;
|
uk = (unsigned long long)n << EXPSHIFTBITS_DP64;
|
||||||
uy = (ax & ~EXPBITS_DP64) | uk;
|
uy = (ax & ~EXPBITS_DP64) | uk;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -898,7 +898,7 @@ static inline double sqrt_amd_inline(double x)
|
||||||
= 2^(e/2) * [ sqrt(c) + sqrt(c)*q ]
|
= 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;
|
double r1, r2, c, y, p, q, r, twop, z, rtc, rtc_lead, rtc_trail;
|
||||||
int e, denorm = 0, index;
|
int e, denorm = 0, index;
|
||||||
|
|
||||||
|
@ -1213,13 +1213,13 @@ static inline double sqrt_amd_inline(double x)
|
||||||
if (denorm)
|
if (denorm)
|
||||||
{
|
{
|
||||||
/* Scale by 2**(e-30) */
|
/* 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;
|
z *= r;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Scale by 2**e */
|
/* 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;
|
z *= r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1586,7 +1586,7 @@ static const float rt_jby32_trail_table_float[97] = {
|
||||||
#endif /* SQRTF_AMD_INLINE */
|
#endif /* SQRTF_AMD_INLINE */
|
||||||
|
|
||||||
#ifdef USE_LOG_KERNEL_AMD
|
#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;
|
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_2 = 1.24999999978138668903e-02, /* 0x3f89999999865ede */
|
||||||
cb_3 = 2.23219810758559851206e-03; /* 0x3f6249423bd94741 */
|
cb_3 = 2.23219810758559851206e-03; /* 0x3f6249423bd94741 */
|
||||||
|
|
||||||
static const unsigned long
|
static const unsigned long long
|
||||||
log_thresh1 = 0x3fee0faa00000000,
|
log_thresh1 = 0x3fee0faa00000000,
|
||||||
log_thresh2 = 0x3ff1082c00000000;
|
log_thresh2 = 0x3ff1082c00000000;
|
||||||
|
|
||||||
|
@ -1885,7 +1885,7 @@ static inline void log_kernel_amd64(double x, unsigned long ux, int *xexp, doubl
|
||||||
|
|
||||||
#ifdef DEBUGGING_PRINT
|
#ifdef DEBUGGING_PRINT
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
char *d2b(long d, int bitsper, int point)
|
char *d2b(long long d, int bitsper, int point)
|
||||||
{
|
{
|
||||||
static char buff[200];
|
static char buff[200];
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -1915,7 +1915,7 @@ char *d2b(long d, int bitsper, int point)
|
||||||
extra precision, and return the result in r.
|
extra precision, and return the result in r.
|
||||||
Return value "region" tells how many lots of pi/2 were subtracted
|
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. */
|
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
|
/* 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
|
#else
|
||||||
#define bitsper 36
|
#define bitsper 36
|
||||||
#endif
|
#endif
|
||||||
unsigned long res[10];
|
unsigned long long res[10];
|
||||||
unsigned long u, carry, mask, mant, nextbits;
|
unsigned long long u, carry, mask, mant, nextbits;
|
||||||
int first, last, i, rexp, xexp, resexp, ltb, determ, bc;
|
int first, last, i, rexp, xexp, resexp, ltb, determ, bc;
|
||||||
double dx;
|
double dx;
|
||||||
static const double
|
static const double
|
||||||
piby2 = 1.57079632679489655800e+00; /* 0x3ff921fb54442d18 */
|
piby2 = 1.57079632679489655800e+00; /* 0x3ff921fb54442d18 */
|
||||||
static unsigned long pibits[] =
|
static unsigned long long pibits[] =
|
||||||
{
|
{
|
||||||
0LL,
|
0LL,
|
||||||
5215LL, 13000023176LL, 11362338026LL, 67174558139LL,
|
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;
|
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 = 1;
|
||||||
mask = (mask << bitsper) - 1;
|
mask = (mask << bitsper) - 1;
|
||||||
|
|
||||||
|
@ -2073,7 +2073,7 @@ static inline void __remainder_piby2f_inline(unsigned long ux, double *r, int *r
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Put the result exponent rexp onto the mantissa pattern */
|
/* 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;
|
ux = (mant & MANTBITS_DP64) | u;
|
||||||
if (determ)
|
if (determ)
|
||||||
/* If we negated the mantissa we negate x too */
|
/* If we negated the mantissa we negate x too */
|
||||||
|
|
|
@ -27,17 +27,9 @@
|
||||||
#define LIBM_UTIL_AMD_H_INCLUDED 1
|
#define LIBM_UTIL_AMD_H_INCLUDED 1
|
||||||
|
|
||||||
#define inline __inline
|
#define inline __inline
|
||||||
#undef long
|
|
||||||
#define long __int64
|
|
||||||
|
|
||||||
#include "emmintrin.h"
|
#include <emmintrin.h>
|
||||||
#include "float.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]);
|
|
||||||
|
|
||||||
|
|
||||||
/* Definitions for double functions on 64 bit machines */
|
/* 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 CLASS_POSITIVE_INFINITY 10
|
||||||
|
|
||||||
#define OLD_BITS_SP32(x) (*((unsigned int *)&x))
|
#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
|
/* Alternatives to the above functions which don't have
|
||||||
problems when using high optimization levels on gcc */
|
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) \
|
#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); \
|
_bitsy.d = (x); \
|
||||||
ux = _bitsy.i; \
|
ux = _bitsy.i; \
|
||||||
}
|
}
|
||||||
#define PUT_BITS_DP64(ux, x) \
|
#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); \
|
_bitsy.i = (ux); \
|
||||||
x = _bitsy.d; \
|
x = _bitsy.d; \
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ THE SOFTWARE.
|
||||||
double _logb(double x)
|
double _logb(double x)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned long ux;
|
unsigned long long ux;
|
||||||
long u;
|
long long u;
|
||||||
GET_BITS_DP64(x, ux);
|
GET_BITS_DP64(x, ux);
|
||||||
u = ((ux & EXPBITS_DP64) >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64;
|
u = ((ux & EXPBITS_DP64) >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64;
|
||||||
if ((ux & ~SIGNBIT_DP64) == 0)
|
if ((ux & ~SIGNBIT_DP64) == 0)
|
||||||
|
|
|
@ -33,8 +33,8 @@ double modf(double x, double *iptr)
|
||||||
each with the same sign as x. */
|
each with the same sign as x. */
|
||||||
|
|
||||||
|
|
||||||
long xexp;
|
long long xexp;
|
||||||
unsigned long ux, ax, mask;
|
unsigned long long ux, ax, mask;
|
||||||
|
|
||||||
GET_BITS_DP64(x, ux);
|
GET_BITS_DP64(x, ux);
|
||||||
ax = ux & (~SIGNBIT_DP64);
|
ax = ux & (~SIGNBIT_DP64);
|
||||||
|
|
|
@ -52,7 +52,7 @@ static inline void dekker_mul12(double x, double y,
|
||||||
{
|
{
|
||||||
double hx, tx, hy, ty;
|
double hx, tx, hy, ty;
|
||||||
/* Split x into hx (head) and tx (tail). Do the same for y. */
|
/* 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);
|
GET_BITS_DP64(x, u);
|
||||||
u &= 0xfffffffff8000000;
|
u &= 0xfffffffff8000000;
|
||||||
PUT_BITS_DP64(u, hx);
|
PUT_BITS_DP64(u, hx);
|
||||||
|
@ -79,7 +79,7 @@ double remainder(double x, double y)
|
||||||
{
|
{
|
||||||
double dx, dy, scale, w, t, v, c, cc;
|
double dx, dy, scale, w, t, v, c, cc;
|
||||||
int i, ntimes, xexp, yexp;
|
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;
|
unsigned int sw;
|
||||||
|
|
||||||
dx = x;
|
dx = x;
|
||||||
|
@ -227,7 +227,7 @@ double remainder(double x, double y)
|
||||||
w = scaleDouble_3(dy, ntimes * 52);
|
w = scaleDouble_3(dy, ntimes * 52);
|
||||||
|
|
||||||
/* Set scale = 2^(-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);
|
scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ double remainder(double x, double y)
|
||||||
it loses the last (106th) bit of its quad precision result. */
|
it loses the last (106th) bit of its quad precision result. */
|
||||||
|
|
||||||
/* Set dx = dx - w * t, where t is equal to trunc(dx/w). */
|
/* 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
|
/* At this point, t may be one too large due to
|
||||||
rounding of dx/w */
|
rounding of dx/w */
|
||||||
|
|
||||||
|
@ -277,8 +277,8 @@ double remainder(double x, double y)
|
||||||
|
|
||||||
/* One more time */
|
/* One more time */
|
||||||
/* Variable todd says whether the integer t is odd or not */
|
/* Variable todd says whether the integer t is odd or not */
|
||||||
t = (double)(long)(dx / w);
|
t = (double)(long long)(dx / w);
|
||||||
todd = ((long)(dx / w)) & 1;
|
todd = ((long long)(dx / w)) & 1;
|
||||||
dekker_mul12(w, t, &c, &cc);
|
dekker_mul12(w, t, &c, &cc);
|
||||||
v = dx - c;
|
v = dx - c;
|
||||||
dx = v + (((dx - v) - c) - cc);
|
dx = v + (((dx - v) - c) - cc);
|
||||||
|
|
|
@ -42,11 +42,11 @@ void __remainder_piby2(double x, double *r, double *rr, int *region)
|
||||||
piby2_part2 = 1.58932547122958567343e-08, /* 0x3e5110b460000000 */
|
piby2_part2 = 1.58932547122958567343e-08, /* 0x3e5110b460000000 */
|
||||||
piby2_part3 = 6.12323399573676480327e-17; /* 0x3c91a62633145c06 */
|
piby2_part3 = 6.12323399573676480327e-17; /* 0x3c91a62633145c06 */
|
||||||
const int bitsper = 10;
|
const int bitsper = 10;
|
||||||
unsigned long res[500];
|
unsigned long long res[500];
|
||||||
unsigned long ux, u, carry, mask, mant, highbitsrr;
|
unsigned long long ux, u, carry, mask, mant, highbitsrr;
|
||||||
int first, last, i, rexp, xexp, resexp, ltb, determ;
|
int first, last, i, rexp, xexp, resexp, ltb, determ;
|
||||||
double xx, t;
|
double xx, t;
|
||||||
static unsigned long pibits[] =
|
static unsigned long long pibits[] =
|
||||||
{
|
{
|
||||||
0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0,
|
||||||
162, 998, 54, 915, 580, 84, 671, 777, 855, 839,
|
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 */
|
/* 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;
|
ux = (mant & MANTBITS_DP64) | u;
|
||||||
if (determ)
|
if (determ)
|
||||||
/* If we negated the mantissa we negate x too */
|
/* 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 */
|
/* Create the bit pattern for rr */
|
||||||
highbitsrr >>= 12; /* Note this is shifted one place too far */
|
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);
|
PUT_BITS_DP64(u, t);
|
||||||
u |= highbitsrr;
|
u |= highbitsrr;
|
||||||
PUT_BITS_DP64(u, xx);
|
PUT_BITS_DP64(u, xx);
|
||||||
|
|
|
@ -32,20 +32,20 @@ THE SOFTWARE.
|
||||||
extra precision, and return the result in r.
|
extra precision, and return the result in r.
|
||||||
Return value "region" tells how many lots of pi/2 were subtracted
|
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. */
|
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
|
/* This method simulates multi-precision floating-point
|
||||||
arithmetic and is accurate for all 1 <= x < infinity */
|
arithmetic and is accurate for all 1 <= x < infinity */
|
||||||
#define bitsper 36
|
#define bitsper 36
|
||||||
unsigned long res[10];
|
unsigned long long res[10];
|
||||||
unsigned long u, carry, mask, mant, nextbits;
|
unsigned long long u, carry, mask, mant, nextbits;
|
||||||
int first, last, i, rexp, xexp, resexp, ltb, determ, bc;
|
int first, last, i, rexp, xexp, resexp, ltb, determ, bc;
|
||||||
double dx;
|
double dx;
|
||||||
static const double
|
static const double
|
||||||
piby2 = 1.57079632679489655800e+00; /* 0x3ff921fb54442d18 */
|
piby2 = 1.57079632679489655800e+00; /* 0x3ff921fb54442d18 */
|
||||||
static unsigned long pibits[] =
|
static unsigned long long pibits[] =
|
||||||
{
|
{
|
||||||
0LL,
|
0LL,
|
||||||
5215LL, 13000023176LL, 11362338026LL, 67174558139LL,
|
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 */
|
/* 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;
|
ux = (mant & MANTBITS_DP64) | u;
|
||||||
if (determ)
|
if (determ)
|
||||||
/* If we negated the mantissa we negate x too */
|
/* If we negated the mantissa we negate x too */
|
||||||
|
|
|
@ -64,7 +64,7 @@ float remainderf(float x, float y)
|
||||||
{
|
{
|
||||||
double dx, dy, scale, w, t;
|
double dx, dy, scale, w, t;
|
||||||
int i, ntimes, xexp, yexp;
|
int i, ntimes, xexp, yexp;
|
||||||
unsigned long ux, uy, ax, ay;
|
unsigned long long ux, uy, ax, ay;
|
||||||
|
|
||||||
unsigned int sw;
|
unsigned int sw;
|
||||||
|
|
||||||
|
@ -190,11 +190,11 @@ float remainderf(float x, float y)
|
||||||
ntimes = (xexp - yexp) / 24;
|
ntimes = (xexp - yexp) / 24;
|
||||||
|
|
||||||
/* Set w = y * 2^(24*ntimes) */
|
/* 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);
|
scale);
|
||||||
w = scale * dy;
|
w = scale * dy;
|
||||||
/* Set scale = 2^(-24) */
|
/* 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);
|
scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ typedef UINT_PTR AWORD; // x86-64 safe
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
float f;
|
float f;
|
||||||
unsigned long l;
|
unsigned long long l;
|
||||||
} LFLOAT;
|
} LFLOAT;
|
||||||
|
|
||||||
//typedef struct
|
//typedef struct
|
||||||
|
@ -78,7 +78,7 @@ typedef unsigned _int64 QWORD;
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
double f;
|
double f;
|
||||||
unsigned long l[2];
|
unsigned long long l[2];
|
||||||
} LDOUBLE;
|
} LDOUBLE;
|
||||||
|
|
||||||
typedef __declspec(align(16)) struct
|
typedef __declspec(align(16)) struct
|
||||||
|
@ -313,7 +313,7 @@ typedef struct {
|
||||||
unsigned char opcode;
|
unsigned char opcode;
|
||||||
unsigned char rmbyte;
|
unsigned char rmbyte;
|
||||||
union {
|
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;
|
unsigned char imm8;
|
||||||
} data;
|
} data;
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,10 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma function(sinh)
|
#pragma function(sinh)
|
||||||
|
#endif
|
||||||
|
|
||||||
double sinh(double x)
|
double sinh(double x)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -229,7 +231,7 @@ double sinh(double x)
|
||||||
3.64177136406482197344e+06, /* 0x414bc8d5ae99ad14 */
|
3.64177136406482197344e+06, /* 0x414bc8d5ae99ad14 */
|
||||||
7.63580561355670914054e+06}; /* 0x415d20d76744835c */
|
7.63580561355670914054e+06}; /* 0x415d20d76744835c */
|
||||||
|
|
||||||
unsigned long ux, aux, xneg;
|
unsigned long long ux, aux, xneg;
|
||||||
double y, z, z1, z2;
|
double y, z, z1, z2;
|
||||||
int m;
|
int m;
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,12 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
// Disable "C4163: not available as intrinsic function" warning that older
|
// Disable "C4163: not available as intrinsic function" warning that older
|
||||||
// compilers may issue here.
|
// compilers may issue here.
|
||||||
#pragma warning(disable:4163)
|
#pragma warning(disable:4163)
|
||||||
#pragma function(sinhf)
|
#pragma function(sinhf)
|
||||||
|
#endif
|
||||||
|
|
||||||
float sinhf(float fx)
|
float sinhf(float fx)
|
||||||
{
|
{
|
||||||
|
@ -153,7 +154,7 @@ float sinhf(float fx)
|
||||||
7.93006726156715250000e+14, /* 0x430689e221bc8d5a */
|
7.93006726156715250000e+14, /* 0x430689e221bc8d5a */
|
||||||
2.15561577355759750000e+15}; /* 0x431ea215a1d20d76 */
|
2.15561577355759750000e+15}; /* 0x431ea215a1d20d76 */
|
||||||
|
|
||||||
unsigned long ux, aux, xneg;
|
unsigned long long ux, aux, xneg;
|
||||||
double x = fx, y, z, z1, z2;
|
double x = fx, y, z, z1, z2;
|
||||||
int m;
|
int m;
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ double sqrt(double x)
|
||||||
return sqrt_amd_inline(x);
|
return sqrt_amd_inline(x);
|
||||||
#else
|
#else
|
||||||
double r;
|
double r;
|
||||||
unsigned long ux;
|
unsigned long long ux;
|
||||||
GET_BITS_DP64(x, ux);
|
GET_BITS_DP64(x, ux);
|
||||||
|
|
||||||
/* Check for special cases for Microsoft error handling */
|
/* Check for special cases for Microsoft error handling */
|
||||||
|
|
|
@ -98,7 +98,7 @@ static inline double tan_piby4(double x, double xx, int recip)
|
||||||
{
|
{
|
||||||
/* Compute -1.0/(t1 + t2) accurately */
|
/* Compute -1.0/(t1 + t2) accurately */
|
||||||
double trec, trec_top, z1, z2, t;
|
double trec, trec_top, z1, z2, t;
|
||||||
unsigned long u;
|
unsigned long long u;
|
||||||
t = t1 + t2;
|
t = t1 + t2;
|
||||||
GET_BITS_DP64(t, u);
|
GET_BITS_DP64(t, u);
|
||||||
u &= 0xffffffff00000000;
|
u &= 0xffffffff00000000;
|
||||||
|
@ -115,14 +115,16 @@ static inline double tan_piby4(double x, double xx, int recip)
|
||||||
return t1 + t2;
|
return t1 + t2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma function(tan)
|
#pragma function(tan)
|
||||||
|
#endif
|
||||||
|
|
||||||
double tan(double x)
|
double tan(double x)
|
||||||
{
|
{
|
||||||
double r, rr;
|
double r, rr;
|
||||||
int region, xneg;
|
int region, xneg;
|
||||||
|
|
||||||
unsigned long ux, ax;
|
unsigned long long ux, ax;
|
||||||
GET_BITS_DP64(x, ux);
|
GET_BITS_DP64(x, ux);
|
||||||
ax = (ux & ~SIGNBIT_DP64);
|
ax = (ux & ~SIGNBIT_DP64);
|
||||||
if (ax <= 0x3fe921fb54442d18) /* abs(x) <= pi/4 */
|
if (ax <= 0x3fe921fb54442d18) /* abs(x) <= pi/4 */
|
||||||
|
@ -183,7 +185,7 @@ double tan(double x)
|
||||||
piby2_3tail = 8.47842766036889956997e-32; /* 0x397b839a252049c1 */
|
piby2_3tail = 8.47842766036889956997e-32; /* 0x397b839a252049c1 */
|
||||||
double t, rhead, rtail;
|
double t, rhead, rtail;
|
||||||
int npi2;
|
int npi2;
|
||||||
unsigned long uy, xexp, expdiff;
|
unsigned long long uy, xexp, expdiff;
|
||||||
xexp = ax >> EXPSHIFTBITS_DP64;
|
xexp = ax >> EXPSHIFTBITS_DP64;
|
||||||
/* How many pi/2 is x a multiple of? */
|
/* How many pi/2 is x a multiple of? */
|
||||||
if (ax <= 0x400f6a7a2955385e) /* 5pi/4 */
|
if (ax <= 0x400f6a7a2955385e) /* 5pi/4 */
|
||||||
|
|
|
@ -39,10 +39,12 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
// Disable "C4163: not available as intrinsic function" warning that older
|
// Disable "C4163: not available as intrinsic function" warning that older
|
||||||
// compilers may issue here.
|
// compilers may issue here.
|
||||||
#pragma warning(disable:4163)
|
#pragma warning(disable:4163)
|
||||||
#pragma function(tanf)
|
#pragma function(tanf)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* tan(x) approximation valid on the interval [-pi/4,pi/4].
|
/* tan(x) approximation valid on the interval [-pi/4,pi/4].
|
||||||
If recip is true return -1/tan(x) instead. */
|
If recip is true return -1/tan(x) instead. */
|
||||||
|
@ -72,7 +74,7 @@ float tanf(float x)
|
||||||
double r, dx;
|
double r, dx;
|
||||||
int region, xneg;
|
int region, xneg;
|
||||||
|
|
||||||
unsigned long ux, ax;
|
unsigned long long ux, ax;
|
||||||
|
|
||||||
dx = x;
|
dx = x;
|
||||||
|
|
||||||
|
@ -135,7 +137,7 @@ float tanf(float x)
|
||||||
piby2_3tail = 8.47842766036889956997e-32; /* 0x397b839a252049c1 */
|
piby2_3tail = 8.47842766036889956997e-32; /* 0x397b839a252049c1 */
|
||||||
double t, rhead, rtail;
|
double t, rhead, rtail;
|
||||||
int npi2;
|
int npi2;
|
||||||
unsigned long uy, xexp, expdiff;
|
unsigned long long uy, xexp, expdiff;
|
||||||
xexp = ax >> EXPSHIFTBITS_DP64;
|
xexp = ax >> EXPSHIFTBITS_DP64;
|
||||||
/* How many pi/2 is dx a multiple of? */
|
/* How many pi/2 is dx a multiple of? */
|
||||||
if (ax <= 0x400f6a7a2955385e) /* 5pi/4 */
|
if (ax <= 0x400f6a7a2955385e) /* 5pi/4 */
|
||||||
|
|
|
@ -39,8 +39,10 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma function(tanh)
|
#pragma function(tanh)
|
||||||
|
#endif
|
||||||
|
|
||||||
double tanh(double x)
|
double tanh(double x)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -57,7 +59,7 @@ double tanh(double x)
|
||||||
log2_by_32_tail = 5.68948749532545630390e-11, /* 0x3dcf473de6af278e */
|
log2_by_32_tail = 5.68948749532545630390e-11, /* 0x3dcf473de6af278e */
|
||||||
large_threshold = 20.0; /* 0x4034000000000000 */
|
large_threshold = 20.0; /* 0x4034000000000000 */
|
||||||
|
|
||||||
unsigned long ux, aux, xneg;
|
unsigned long long ux, aux, xneg;
|
||||||
double y, z, p, z1, z2;
|
double y, z, p, z1, z2;
|
||||||
int m;
|
int m;
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,12 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "libm_errno.h"
|
#include "libm_errno.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
// Disable "C4163: not available as intrinsic function" warning that older
|
// Disable "C4163: not available as intrinsic function" warning that older
|
||||||
// compilers may issue here.
|
// compilers may issue here.
|
||||||
#pragma warning(disable:4163)
|
#pragma warning(disable:4163)
|
||||||
#pragma function(tanhf)
|
#pragma function(tanhf)
|
||||||
|
#endif
|
||||||
|
|
||||||
float tanhf(float x)
|
float tanhf(float x)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue