SSBM Decomp
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1#ifndef MSL_MATH_H
2#define MSL_MATH_H
3
4#include <Runtime/platform.h>
5
6#ifdef MWERKS_GEKKO
7#include <math_ppc.h>
8
10#endif
11
12#define MSL_HI(x) *(int*) &x
13#define MSL_LO(x) *(1 + (int*) &x)
14
22
23static inline s32 __fpclassifyf(float x)
24{
25 const s32 exp_mask = 0x7F800000;
26 const s32 mantissa_mask = 0x007FFFFF;
27 switch ((*(s32*) &x) & exp_mask) {
28 case exp_mask:
29 return ((*(s32*) &x) & mantissa_mask) ? FP_NAN : FP_INFINITE;
30 case 0:
31 return ((*(s32*) &x) & mantissa_mask) ? FP_SUBNORMAL : FP_ZERO;
32 default:
33 return FP_NORMAL;
34 }
35}
36
37extern int __HI(double);
38extern int __LO(double);
39
40static inline s32 __fpclassifyd(double x)
41{
42 switch (__HI(x) & 0x7ff00000) {
43 case 0x7ff00000:
44 return ((__HI(x) & 0x000fffff) || (__LO(x) & 0xffffffff))
45 ? FP_NAN
47 case 0:
48 return ((__HI(x) & 0x000fffff) || (__LO(x) & 0xffffffff))
50 : FP_ZERO;
51 default:
52 return FP_NORMAL;
53 }
54}
55
56#define fpclassify(x) \
57 ((sizeof(x) == sizeof(float)) ? __fpclassifyf((float) (x)) \
58 : __fpclassifyd((double) (x)))
59
60#ifdef MWERKS_GEKKO
61#define fabsf __fabsf
62static inline double fabs(double f)
63{
64 return __fabs(f);
65}
66#endif
67
68double fabs(double);
69double frexp(double x, int* exponent);
70float acosf(float);
71float asinf(float);
72float atan2f(float y, float x);
73float atanf(float);
74float cos__Ff(float x);
75float cosf(float);
76float expf(float);
77float fabsf(float);
78float fabsf__Ff(float);
79float logf(float);
80float sin__Ff(float x);
81float sinf(float);
82float sqrt(double);
83float sqrtf(float);
84void __sinit_trigf_c(void);
85
86static inline float fmodf(float a, float b)
87{
88 s64 quotient;
89
90 if (fabsf(b) > fabsf(a)) {
91 return a;
92 }
93 quotient = a / b;
94 return a - b * quotient;
95}
96
97#endif
#define __LO(x)
Definition ansi_fp.c:6
#define __HI(x)
Definition ansi_fp.c:5
signed int s32
Definition types.h:12
signed long long int s64
Definition types.h:15
#define FP_NAN
Definition math.h:90
#define FP_ZERO
Definition math.h:92
float sqrtf(float x)
Definition math.h:30
#define FP_INFINITE
Definition math.h:91
float sqrt(float x)
@TODO: this isn't correct! It's just to generate sdata2 in GXDraw.o
Definition math.h:55
float cosf(float x)
Definition trigf.c:68
long __fpclassifyd(double x)
float sinf(float x)
Definition trigf.c:24
float fmodf(float x, float m)
Definition math.h:101
double fabs(double x)
float acosf(float x)
Definition lbtrigf.c:45
float fabsf(float x)
long __fpclassifyf(float x)
#define FP_NORMAL
Definition math.h:93
#define FP_SUBNORMAL
Definition math.h:94
#define __fabs(f)
Definition placeholder.h:17
float expf(float)
Definition lb_00CE.c:27
float sin__Ff(float x)
Definition trigf.c:109
double frexp(double x, int *exponent)
Definition math_1.c:13
float fabsf__Ff(float)
Definition math_1.c:8
float cos__Ff(float x)
Definition trigf.c:114
float asinf(float)
Definition lbtrigf.c:63
float logf(float)
Definition math.c:64
FloatType
Definition math.h:15
void __sinit_trigf_c(void)
Definition trigf.c:14
float atanf(float)
float atan2f(float y, float x)
Definition lbtrigf.c:22
int y
Definition types.h:1
int x
Definition types.h:0