First 0.7 update, removing all deprecated features.

This commit is contained in:
Christoffer Lerno
2025-02-27 14:16:36 +01:00
committed by Christoffer Lerno
parent cff6697818
commit 2a895ec7be
1589 changed files with 2635 additions and 115363 deletions

View File

@@ -1,15 +1,15 @@
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double _fabs(double x) @weak @extern("fabs") @nostrip
{
ulong ix = bitcast(x, ulong);
ix &= ~(1ul << 63);
return bitcast(ix, double);
}
fn float _fabsf(float x) @weak @extern("fabsf") @nostrip
{
uint ix = bitcast(x, uint);
ix &= 0x7fffffff;
return bitcast(ix, float);
}
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double _fabs(double x) @weak @extern("fabs") @nostrip
{
ulong ix = bitcast(x, ulong);
ix &= ~(1ul << 63);
return bitcast(ix, double);
}
fn float _fabsf(float x) @weak @extern("fabsf") @nostrip
{
uint ix = bitcast(x, uint);
ix &= 0x7fffffff;
return bitcast(ix, float);
}

View File

@@ -1,59 +1,59 @@
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double frexp(double x, int* exp) @extern("frexp")
{
uint hx = x.high_word();
uint ix = hx & 0x7fffffff;
uint lx = x.low_word();
if (ix >= 0x7ff00000 || (ix | lx) == 0)
{
*exp = 0;
return x;
}
// exponent extraction and normalization
int e = (int)((ix >> 20) & 0x7ff);
if (e == 0)
{
// subnormal number
x *= 0x1p64;
hx = x.high_word();
e = (int)((hx >> 20) & 0x7ff) - 64;
}
*exp = e - 1022;
// set exponent to -1 (fraction in [0.5, 1))
hx = (hx & 0x800fffff) | 0x3fe00000;
{
ulong rep = ((ulong)hx << 32) | lx;
return bitcast(rep, double);
}
}
fn float frexpf(float x, int* exp) @extern("frexpf")
{
uint ix = x.word();
uint hx = ix & 0x7fffffff;
if (hx >= 0x7f800000 || hx == 0)
{
*exp = 0;
return x;
}
// exponent extraction and normalization
int e = (int)((hx >> 23) & 0xff);
if (e == 0)
{
// subnormal number
x *= 0x1p64f;
ix = x.word();
e = (int)((ix >> 23) & 0xff) - 64;
}
*exp = e - 126;
// set exponent to -1 (fraction in [0.5, 1))
ix = (ix & 0x807fffff) | 0x3f000000;
return bitcast(ix, float);
}
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double frexp(double x, int* exp) @extern("frexp")
{
uint hx = x.high_word();
uint ix = hx & 0x7fffffff;
uint lx = x.low_word();
if (ix >= 0x7ff00000 || (ix | lx) == 0)
{
*exp = 0;
return x;
}
// exponent extraction and normalization
int e = (int)((ix >> 20) & 0x7ff);
if (e == 0)
{
// subnormal number
x *= 0x1p64;
hx = x.high_word();
e = (int)((hx >> 20) & 0x7ff) - 64;
}
*exp = e - 1022;
// set exponent to -1 (fraction in [0.5, 1))
hx = (hx & 0x800fffff) | 0x3fe00000;
{
ulong rep = ((ulong)hx << 32) | lx;
return bitcast(rep, double);
}
}
fn float frexpf(float x, int* exp) @extern("frexpf")
{
uint ix = x.word();
uint hx = ix & 0x7fffffff;
if (hx >= 0x7f800000 || hx == 0)
{
*exp = 0;
return x;
}
// exponent extraction and normalization
int e = (int)((hx >> 23) & 0xff);
if (e == 0)
{
// subnormal number
x *= 0x1p64f;
ix = x.word();
e = (int)((ix >> 23) & 0xff) - 64;
}
*exp = e - 126;
// set exponent to -1 (fraction in [0.5, 1))
ix = (ix & 0x807fffff) | 0x3f000000;
return bitcast(ix, float);
}

View File

@@ -1,67 +1,67 @@
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double ldexp(double x, int exp) @extern("ldexp")
{
uint hx = x.high_word();
int hexp = (int)((hx & 0x7ff00000) >> 20);
if (hexp == 0x7ff) return x;
if (hexp == 0)
{
// subnormal number handling
x *= 0x1p64;
hx = x.high_word();
hexp = (int)((hx & 0x7ff00000) >> 20) - 64;
}
// new exponent calculation
hexp += exp;
if (hexp > 0x7fe) return x * double.inf;
if (hexp < 1)
{
x *= 0x1p-1022;
hexp += 1022;
if (hexp < 1) x *= 0x1p-1022;
return x;
}
// set new exponent
hx = ((ulong)hx & 0x800fffff) | ((ulong)hexp << 20);
{
ulong rep = ((ulong)hx << 32) | x.low_word();
return bitcast(rep, double);
}
}
fn float ldexpf(float x, int exp) @extern("ldexpf")
{
uint ix = x.word();
int hexp = (int)((ix & 0x7f800000) >> 23);
if (hexp == 0xff) return x;
if (hexp == 0)
{
// subnormal number handling
x *= 0x1p64f;
ix = x.word();
hexp = (int)((ix & 0x7f800000) >> 23) - 64;
}
// new exponent calculation
hexp += exp;
if (hexp > 0xfe) return x * float.inf;
if (hexp < 1)
{
x *= 0x1p-126f;
hexp += 126;
if (hexp < 1) x *= 0x1p-126f;
return x;
}
// set new exponent
ix = (ix & 0x807fffff) | (hexp << 23);
return bitcast(ix, float);
}
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double ldexp(double x, int exp) @extern("ldexp")
{
uint hx = x.high_word();
int hexp = (int)((hx & 0x7ff00000) >> 20);
if (hexp == 0x7ff) return x;
if (hexp == 0)
{
// subnormal number handling
x *= 0x1p64;
hx = x.high_word();
hexp = (int)((hx & 0x7ff00000) >> 20) - 64;
}
// new exponent calculation
hexp += exp;
if (hexp > 0x7fe) return x * double.inf;
if (hexp < 1)
{
x *= 0x1p-1022;
hexp += 1022;
if (hexp < 1) x *= 0x1p-1022;
return x;
}
// set new exponent
hx = ((ulong)hx & 0x800fffff) | ((ulong)hexp << 20);
{
ulong rep = ((ulong)hx << 32) | x.low_word();
return bitcast(rep, double);
}
}
fn float ldexpf(float x, int exp) @extern("ldexpf")
{
uint ix = x.word();
int hexp = (int)((ix & 0x7f800000) >> 23);
if (hexp == 0xff) return x;
if (hexp == 0)
{
// subnormal number handling
x *= 0x1p64f;
ix = x.word();
hexp = (int)((ix & 0x7f800000) >> 23) - 64;
}
// new exponent calculation
hexp += exp;
if (hexp > 0xfe) return x * float.inf;
if (hexp < 1)
{
x *= 0x1p-126f;
hexp += 126;
if (hexp < 1) x *= 0x1p-126f;
return x;
}
// set new exponent
ix = (ix & 0x807fffff) | (hexp << 23);
return bitcast(ix, float);
}