| 1 |
#include "pmath.h" |
| 2 |
#include <stdlib.h> |
| 3 |
#include <math.h> |
| 4 |
|
| 5 |
/* Currently the games only uses sign of an integer */ |
| 6 |
int fpcrtl_signi(int x) |
| 7 |
{ |
| 8 |
if(x > 0){ |
| 9 |
return 1; |
| 10 |
} |
| 11 |
else if(x < 0){ |
| 12 |
return -1; |
| 13 |
} |
| 14 |
else{ |
| 15 |
return 0; |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
float fpcrtl_csc(float x) |
| 20 |
{ |
| 21 |
return 1 / sin(x); |
| 22 |
} |
| 23 |
|
| 24 |
float __attribute__((overloadable)) fpcrtl_abs(float x) |
| 25 |
{ |
| 26 |
return fabsf(x); |
| 27 |
} |
| 28 |
double __attribute__((overloadable)) fpcrtl_abs(double x) |
| 29 |
{ |
| 30 |
return fabs(x); |
| 31 |
} |
| 32 |
long double __attribute__((overloadable)) fpcrtl_abs(long double x) |
| 33 |
{ |
| 34 |
return fabsl(x); |
| 35 |
} |
| 36 |
int __attribute__((overloadable)) fpcrtl_abs(int x) |
| 37 |
{ |
| 38 |
return abs(x); |
| 39 |
} |
| 40 |
|
| 41 |
int64_t __attribute__((overloadable)) fpcrtl_abs(int64_t x) |
| 42 |
{ |
| 43 |
return x < 0 ? -x : x; |
| 44 |
} |