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
15#define M_PI 3.14159265358979323846
16#define M_PI_2 (M_PI / 2)
17
25
26static inline s32 __fpclassifyf(float x)
27{
28 const s32 exp_mask = 0x7F800000;
29 const s32 mantissa_mask = 0x007FFFFF;
30 switch ((*(s32*) &x) & exp_mask) {
31 case exp_mask:
32 return ((*(s32*) &x) & mantissa_mask) ? FP_NAN : FP_INFINITE;
33 case 0:
34 return ((*(s32*) &x) & mantissa_mask) ? FP_SUBNORMAL : FP_ZERO;
35 default:
36 return FP_NORMAL;
37 }
38}
39
40extern int __HI(double);
41extern int __LO(double);
42
43static inline s32 __fpclassifyd(double x)
44{
45 switch (__HI(x) & 0x7ff00000) {
46 case 0x7ff00000:
47 return ((__HI(x) & 0x000fffff) || (__LO(x) & 0xffffffff))
48 ? FP_NAN
50 case 0:
51 return ((__HI(x) & 0x000fffff) || (__LO(x) & 0xffffffff))
53 : FP_ZERO;
54 default:
55 return FP_NORMAL;
56 }
57}
58
59#define fpclassify(x) \
60 ((sizeof(x) == sizeof(float)) ? __fpclassifyf((float) (x)) \
61 : __fpclassifyd((double) (x)))
62
63#ifdef MWERKS_GEKKO
64#define fabsf __fabsf
65static inline double fabs(double f)
66{
67 return __fabs(f);
68}
69#endif
70
71double fabs(double);
72double frexp(double x, int* exponent);
73float acosf(float);
74float asinf(float);
75float atan2f(float y, float x);
76float atanf(float);
77float cos__Ff(float x);
78float cosf(float);
79float expf(float);
80float fabsf(float);
81float fabsf__Ff(float);
82float logf(float);
83float sin__Ff(float x);
84float sinf(float);
85float sqrt(double);
86float sqrtf(float);
87void __sinit_trigf_c(void);
88
89static inline float fmodf(float a, float b)
90{
91 long long quotient;
92
93 if (fabsf(b) > fabsf(a)) {
94 return a;
95 }
96 quotient = a / b;
97 return a - b * quotient;
98}
99
100#endif
#define __LO(x)
Definition ansi_fp.c:6
#define __HI(x)
Definition ansi_fp.c:5
signed long s32
Definition types.h:8
#define FP_NAN
Definition math.h:86
#define FP_ZERO
Definition math.h:88
float sqrtf(float x)
Definition math.h:30
#define FP_INFINITE
Definition math.h:87
float sqrt(float x)
Definition math.h:53
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:95
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:89
#define FP_SUBNORMAL
Definition math.h:90
#define __fabs(f)
Definition placeholder.h:16
float expf(float)
Definition lb_00CE.c:27
float sin__Ff(float x)
Definition trigf.c:113
double frexp(double x, int *exponent)
Definition math_1.c:8
float fabsf__Ff(float)
Definition math_1.c:3
float cos__Ff(float x)
Definition trigf.c:118
float asinf(float)
Definition lbtrigf.c:63
float logf(float)
Definition math.c:64
FloatType
Definition math.h:18
void __sinit_trigf_c(void)
Definition trigf.c:14
float atanf(float)
float atan2f(float y, float x)
Definition lbtrigf.c:22
GXColorS10 a
Definition tev.c:9