SSBM Decomp
Toggle main menu visibility
Loading...
Searching...
No Matches
platform.h
Go to the documentation of this file.
1
#ifndef RUNTIME_PLATFORM_H
2
#define RUNTIME_PLATFORM_H
3
4
#include <
stdbool.h
>
// IWYU pragma: export
5
#include <
stddef.h
>
// IWYU pragma: export
6
7
#include <
dolphin/types.h
>
// IWYU pragma: export
8
13
#undef BOOL
14
19
#undef FALSE
20
25
#undef TRUE
26
28
typedef
int
enum_t
;
29
31
typedef
signed
int
ssize_t
;
32
34
typedef
void (*
Event
)(void);
35
36
typedef
bool
(*
Predicate
)(void);
37
38
#if defined(__MWERKS__) && defined(__PPCGEKKO__)
39
#define MWERKS_GEKKO
40
#endif
41
42
#if defined(__MWERKS__) && !defined(M2CTX)
43
#define ASM asm
44
#else
45
#define ASM
46
#endif
47
48
#ifndef UNUSED
49
#if defined(__clang__) || defined(__GNUC__)
50
#define UNUSED __attribute__((unused))
51
#else
52
#define UNUSED
53
#endif
54
#endif
55
56
#ifndef ATTRIBUTE_ALIGN
57
#if defined(__MWERKS__) || defined(__GNUC__)
58
#define ATTRIBUTE_ALIGN(num) __attribute__((aligned(num)))
59
#elif defined(_MSC_VER)
60
#define ATTRIBUTE_ALIGN(num)
61
#else
62
#error unknown compiler
63
#endif
64
#endif
65
66
#ifndef SECTION_INIT
67
#if defined(__MWERKS__) && !defined(M2CTX)
68
#define SECTION_INIT __declspec(section ".init")
69
#else
70
#define SECTION_INIT
71
#endif
72
#endif
73
74
#ifndef SECTION_CTORS
75
#if defined(__MWERKS__) && !defined(M2CTX)
76
#define SECTION_CTORS __declspec(section ".ctors")
77
#else
78
#define SECTION_CTORS
79
#endif
80
#endif
81
82
#ifndef SECTION_DTORS
83
#if defined(__MWERKS__) && !defined(M2CTX)
84
#define SECTION_DTORS __declspec(section ".dtors")
85
#else
86
#define SECTION_DTORS
87
#endif
88
#endif
89
90
#ifndef ATTRIBUTE_NORETURN
91
#if defined(__clang__) || defined(__GNUC__)
92
#define ATTRIBUTE_NORETURN __attribute__((noreturn))
93
#else
94
#define ATTRIBUTE_NORETURN
95
#endif
96
#endif
97
98
#ifndef ATTRIBUTE_RESTRICT
99
#if defined(__MWERKS__) && !defined(M2CTX)
100
#define ATTRIBUTE_RESTRICT __restrict
101
#else
102
#define ATTRIBUTE_RESTRICT
103
#endif
104
#endif
105
106
#ifndef AT_ADDRESS
107
#ifdef PERMUTER
108
#define AT_ADDRESS(x) = FIXEDADDR(x)
109
#elif defined(__MWERKS__) && !defined(M2CTX)
110
#define AT_ADDRESS(x) : (x)
111
#else
112
#define AT_ADDRESS(x)
113
#endif
114
#endif
115
116
#ifdef MWERKS_GEKKO
117
#define qr0 0
118
#define qr1 1
119
#define qr2 2
120
#define qr3 3
121
#define qr4 4
122
#define qr5 5
123
#define qr6 6
124
#define qr7 7
125
#endif
126
127
#define U8_MAX 0xFF
128
#define U16_MAX 0xFFFF
129
#define U32_MAX 0xFFFFFFFF
130
#define U64_MAX 0xFFFFFFFFFFFFFFFF
131
#define S8_MAX 0x7F
132
#define S16_MAX 0x7FFF
133
#define S32_MAX 0x7FFFFFFF
134
#define F32_MAX 3.4028235e38f
135
136
#define SQ(x) ((x) * (x))
137
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
138
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
139
140
#ifdef __cplusplus
141
#ifndef _Static_assert
142
#define _Static_assert static_assert
143
#endif
144
#endif
145
#ifdef M2CTX
146
#define STATIC_ASSERT(cond)
147
#elif defined(__MWERKS__)
148
#define STATIC_ASSERT(cond) \
149
struct { \
150
int x[1 - 2 * !(cond)]; \
151
};
152
#else
153
#define STATIC_ASSERT(cond) _Static_assert((cond), "(" #cond ") failed")
154
#endif
155
156
#if defined(MUST_MATCH) || defined(LINT)
157
#define ASSERT_SIZE(expr, size) STATIC_ASSERT(sizeof(expr) == size)
158
#define ASSERT_OFFSET(type, member, offset) \
159
STATIC_ASSERT(offsetof(type, member) == offset)
160
#else
161
#define ASSERT_SIZE(expr, size)
162
#define ASSERT_OFFSET(expr, member, offset)
163
#endif
164
165
#define RETURN_IF(cond) \
166
do { \
167
if ((cond)) { \
168
return; \
169
} \
170
} while (0)
171
172
#if defined(__MWERKS__) && !defined(M2CTX)
173
#define SDATA __declspec(section ".sdata")
174
#define DATA __declspec(section ".data")
175
#define WEAK __declspec(weak)
176
#else
177
#define SDATA
178
#define DATA
179
#define WEAK
180
#endif
181
182
#define M_TAU 6.283185307179586
183
#define M_PI_3 (M_PI / 3)
184
185
#define M_PI_F 3.14159265358979323846F
186
#define M_TAU_F 6.283185307179586F
187
#define M_PI_2_F (M_PI_F / 2.0F)
188
#define M_PI_3_F (M_PI_F / 3.0F)
189
190
#define M_PI_L 3.14159265358979323846L
191
#define M_TAU_L 6.283185307179586L
192
#define M_PI_2_L (M_PI_L / 2.0L)
193
#define M_PI_3_L (M_PI_L / 3.0L)
194
195
#define SIGNF(x) ((x) > 0.0f ? 1.0f : -1.0f)
196
197
#define FLT_EPSILON 1.00000001335e-10F
198
199
#define ABS(x) ((x) < 0 ? -(x) : (x))
200
201
#ifndef ARRAY_SIZE
202
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
203
#endif
204
205
#endif
types.h
Predicate
bool(* Predicate)(void)
Definition
platform.h:36
enum_t
int enum_t
The underlying type of an enum, used as a placeholder.
Definition
platform.h:28
Event
void(* Event)(void)
A void callback with no arguments.
Definition
platform.h:34
ssize_t
signed int ssize_t
Signed variant of size_t.
Definition
platform.h:31
stdbool.h
bool
int bool
A signed integer used to contain boolean values.
Definition
stdbool.h:6
stddef.h
src
Runtime
platform.h
Generated by
1.17.0