aarch64: couple of less bad math functions in libc

This commit is contained in:
K. Lange 2022-01-31 21:06:17 +09:00
parent c3311fe272
commit f0409ff120
1 changed files with 13 additions and 2 deletions

View File

@ -1,7 +1,9 @@
/* bad math */
#include <math.h>
double sqrt(double x) {
return 0.0;
asm volatile ("fsqrt %d0, %d1" : "=w"(x) : "w"(x));
return x;
}
double atan2(double y, double x) {
@ -13,5 +15,14 @@ double pow(double x, double y) {
}
double fmod(double x, double y) {
return 0.0;
int _x = fpclassify(x);
int _y = fpclassify(y);
if (_y == FP_NAN) return NAN;
if (_x == FP_INFINITE) return NAN;
if (_y == FP_ZERO) return NAN;
if (_x == FP_ZERO) return x;
long div = x / y;
return x - (double)div * y;
}