e_sqrt and s_sin 100%

This commit is contained in:
shibbo 2023-03-02 01:23:40 -05:00
parent 6888144886
commit 00ee311d81
7 changed files with 178 additions and 8 deletions

View File

@ -120,7 +120,7 @@ cos,s_cos.o,MSL_C.PPCEABI.bare.H.a,false
floor,s_floor.o,MSL_C.PPCEABI.bare.H.a,true
frexp,s_frexp.o,MSL_C.PPCEABI.bare.H.a,false
ldexp,s_ldexp.o,MSL_C.PPCEABI.bare.H.a,true
sin,s_sin.o,MSL_C.PPCEABI.bare.H.a,false
sin,s_sin.o,MSL_C.PPCEABI.bare.H.a,true
tan,s_tan.o,MSL_C.PPCEABI.bare.H.a,true
acos,w_acos.o,MSL_C.PPCEABI.bare.H.a,true
asin,w_asin.o,MSL_C.PPCEABI.bare.H.a,true
@ -128,6 +128,6 @@ atan2,w_atan2.o,MSL_C.PPCEABI.bare.H.a,true
fmod,w_fmod.o,MSL_C.PPCEABI.bare.H.a,true
log10,w_log10.o,MSL_C.PPCEABI.bare.H.a,true
pow,w_pow.o,MSL_C.PPCEABI.bare.H.a,true
__ieee754_sqrt,e_sqrt.o,MSL_C.PPCEABI.bare.H.a,false
__ieee754_sqrt,e_sqrt.o,MSL_C.PPCEABI.bare.H.a,true
nan,math_ppc.o,MSL_C.PPCEABI.bare.H.a,true
sqrt,w_sqrt.o,MSL_C.PPCEABI.bare.H.a,true

1 Symbol Name Object File Library Archive Matching
120 floor s_floor.o MSL_C.PPCEABI.bare.H.a true
121 frexp s_frexp.o MSL_C.PPCEABI.bare.H.a false
122 ldexp s_ldexp.o MSL_C.PPCEABI.bare.H.a true
123 sin s_sin.o MSL_C.PPCEABI.bare.H.a false true
124 tan s_tan.o MSL_C.PPCEABI.bare.H.a true
125 acos w_acos.o MSL_C.PPCEABI.bare.H.a true
126 asin w_asin.o MSL_C.PPCEABI.bare.H.a true
128 fmod w_fmod.o MSL_C.PPCEABI.bare.H.a true
129 log10 w_log10.o MSL_C.PPCEABI.bare.H.a true
130 pow w_pow.o MSL_C.PPCEABI.bare.H.a true
131 __ieee754_sqrt e_sqrt.o MSL_C.PPCEABI.bare.H.a false true
132 nan math_ppc.o MSL_C.PPCEABI.bare.H.a true
133 sqrt w_sqrt.o MSL_C.PPCEABI.bare.H.a true

View File

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "MSL",
"message": "43.32%",
"message": "44.605%",
"color": "blue"
}

View File

@ -1,3 +1,3 @@
| Library | Percentage |
| ------------- | ------------- |
| [MSL_C.PPCEABI.bare.H](https://github.com/shibbo/Petari/blob/master/libs/MSL_C/docs/lib/MSL_C.PPCEABI.bare.H.md) | 43.32004629034332% |
| [MSL_C.PPCEABI.bare.H](https://github.com/shibbo/Petari/blob/master/libs/MSL_C/docs/lib/MSL_C.PPCEABI.bare.H.md) | 44.60588916034461% |

View File

@ -55,7 +55,7 @@
| s_floor.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| s_frexp.o | 0.0% | 0 / 1 | 0.0% | :x:
| s_ldexp.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| s_sin.o | 0.0% | 0 / 1 | 0.0% | :x:
| s_sin.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| s_tan.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| w_acos.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| w_asin.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
@ -63,7 +63,7 @@
| w_fmod.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| w_log10.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| w_pow.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| e_sqrt.o | 0.0% | 0 / 1 | 0.0% | :x:
| e_sqrt.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| math_ppc.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| w_sqrt.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
@ -427,7 +427,7 @@
# s_sin.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| sin | :x: |
| sin | :white_check_mark: |
# s_tan.o
@ -475,7 +475,7 @@
# e_sqrt.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| __ieee754_sqrt | :x: |
| __ieee754_sqrt | :white_check_mark: |
# math_ppc.o

View File

@ -31,6 +31,8 @@ double __ieee754_asin(double);
double scalbn(double, int);
double __kernel_sin(double, double, int);
double __kernel_cos(double, double);
double __kernel_tan(double, double, int);
int __ieee754_rem_pio2(double, double *);

138
libs/MSL_C/source/e_sqrt.c Normal file
View File

@ -0,0 +1,138 @@
#include <cerrno>
#include <cmath>
static const double one = 1.0;
static const double tiny = 1.0e-300;
double __ieee754_sqrt(double x) {
double z;
int sign = 0x80000000;
unsigned int r, t1, s1, ix1, q1;
int ix0, s0, q, m, t, i;
ix0 = *(int*)&x;
ix1 = *(1 + (int*)&x);
if ((ix0 & 0x7FF00000) == 0x7FF00000) {
errno = 0x21;
return x * x + x;
}
if (ix0 <= 0) {
if (((ix0 & (~sign)) | ix1) == 0) {
return x;
}
else if (ix0 < 0) {
errno = 0x21;
return NAN;
}
}
m = (ix0 >> 20);
if (m == 0) {
while (ix0 == 0) {
m -= 21;
ix0 |= (ix1 >> 11);
ix1 <<= 21;
}
for (i = 0; (ix0 & 0x100000) == 0; i++) {
ix0 <<= 1;
}
m -= i - 1;
ix0 |= (ix1 >> (32 - i));
ix1 <<= i;
}
m -= 1023;
ix0 = (ix0 & 0xFFFFF) | 0x100000;
if (m & 1) {
ix0 += ix0 + ((ix1 & sign) >> 31);
ix1 += ix1;
}
m >>= 1;
ix0 += ix0 + ((ix1 & sign) >> 31);
ix1 += ix1;
q = q1 = s0 = s1 = 0;
r = 0x200000;
while(r != 0) {
t = s0 + r;
if(t <= ix0) {
s0 = t + r;
ix0 -= t;
q += r;
}
ix0 += ix0 + ((ix1 & sign) >> 31);
ix1 += ix1;
r >>= 1;
}
r = sign;
while (r != 0) {
t1 = s1 + r;
t = s0;
if ((t < ix0) || ((t == ix0) && (t1 <= ix1))) {
s1 = t1 + r;
if(((t1 & sign) == sign) && (s1 & sign) == 0) {
s0 += 1;
}
ix0 -= t;
if (ix1 < t1) {
ix0 -= 1;
}
ix1 -= t1;
q1 += r;
}
ix0 += ix0 + ((ix1 & sign) >> 31);
ix1 += ix1;
r >>= 1;
}
if((ix0 | ix1) != 0) {
z = one - tiny;
if (z >= one) {
z = one + tiny;
if (q1 == 0xFFFFFFFF) {
q1 = 0;
q += 1;
}
else if (z > one) {
if (q1 == 0xFFFFFFFE) {
q += 1;
}
q1 += 2;
}
else {
q1 += (q1 & 1);
}
}
}
ix0 = (q >> 1) + 0x3FE00000;
ix1 = q1 >> 1;
if ((q & 1) == 1) {
ix1 |= sign;
}
ix0 += (m << 20);
*(int*)&z = ix0;
*(1 + (int*)&z) = ix1;
return z;
}

30
libs/MSL_C/source/s_sin.c Normal file
View File

@ -0,0 +1,30 @@
#include <cmath>
double sin(double x) {
double y[2], z = 0.0;
int n, ix;
ix = *(int*)&x;
ix &= 0x7FFFFFFF;
if (ix <= 0x3FE921FB) {
return __kernel_sin(x, z, 0);
}
else if (ix >= 0x7FF00000) {
return x - x;
}
else {
n = __ieee754_rem_pio2(x, y);
switch (n & 3) {
case 0:
return __kernel_sin(y[0], y[1], 1);
case 1:
return __kernel_cos(y[0], y[1]);
case 2:
return -__kernel_sin(y[0], y[1], 1);
default:
return -__kernel_cos(y[0], y[1]);
}
}
}