SSBM Decomp
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#include <dolphin/types.h> // IWYU pragma: export
7
12#undef BOOL
13
18#undef FALSE
19
24#undef TRUE
25
27typedef int enum_t;
28
30typedef void (*Event)(void);
31
32typedef bool (*Predicate)(void);
33
34#if defined(__MWERKS__) && defined(__PPCGEKKO__)
35#define MWERKS_GEKKO
36#endif
37
38#ifndef ATTRIBUTE_ALIGN
39#if defined(__MWERKS__) || defined(__GNUC__)
40#define ATTRIBUTE_ALIGN(num) __attribute__((aligned(num)))
41#elif defined(_MSC_VER)
42#define ATTRIBUTE_ALIGN(num)
43#else
44#error unknown compiler
45#endif
46#endif
47
48#ifndef SECTION_INIT
49#if defined(__MWERKS__) && !defined(M2CTX)
50#define SECTION_INIT __declspec(section ".init")
51#else
52#define SECTION_INIT
53#endif
54#endif
55
56#ifndef SECTION_CTORS
57#if defined(__MWERKS__) && !defined(M2CTX)
58#define SECTION_CTORS __declspec(section ".ctors")
59#else
60#define SECTION_CTORS
61#endif
62#endif
63
64#ifndef SECTION_DTORS
65#if defined(__MWERKS__) && !defined(M2CTX)
66#define SECTION_DTORS __declspec(section ".dtors")
67#else
68#define SECTION_DTORS
69#endif
70#endif
71
72#ifndef ATTRIBUTE_NORETURN
73#if defined(__clang__) || defined(__GNUC__)
74#define ATTRIBUTE_NORETURN __attribute__((noreturn))
75#else
76#define ATTRIBUTE_NORETURN
77#endif
78#endif
79
80#ifndef ATTRIBUTE_RESTRICT
81#if defined(__MWERKS__) && !defined(M2CTX)
82#define ATTRIBUTE_RESTRICT __restrict
83#else
84#define ATTRIBUTE_RESTRICT
85#endif
86#endif
87
88#ifdef PERMUTER
89#define AT_ADDRESS(x) = FIXEDADDR(x)
90#elif defined(__MWERKS__) && !defined(M2CTX)
91#define AT_ADDRESS(x) : (x)
92#else
93#define AT_ADDRESS(x)
94#endif
95
96#ifdef __PPCGEKKO__
97#define qr0 0
98#define qr1 1
99#define qr2 2
100#define qr3 3
101#define qr4 4
102#define qr5 5
103#define qr6 6
104#define qr7 7
105#endif
106
107#define U8_MAX 0xFF
108#define U16_MAX 0xFFFF
109#define U32_MAX 0xFFFFFFFF
110#define S8_MAX 0x7F
111#define S16_MAX 0x7FFF
112#define S32_MAX 0x7FFFFFFF
113#define F32_MAX 3.4028235e38f
114
115#define SQ(x) ((x) * (x))
116#define MIN(a, b) (((a) < (b)) ? (a) : (b))
117#define MAX(a, b) (((a) > (b)) ? (a) : (b))
118
119#ifdef __cplusplus
120#ifndef _Static_assert
121#define _Static_assert static_assert
122#endif
123#endif
124#ifdef M2CTX
125#define STATIC_ASSERT(cond)
126#elif defined(__MWERKS__)
127#define STATIC_ASSERT(cond) \
128 struct { \
129 int x[1 - 2 * !(cond)]; \
130 };
131#else
132#define STATIC_ASSERT(cond) _Static_assert((cond), "(" #cond ") failed")
133#endif
134
135#define RETURN_IF(cond) \
136 do { \
137 if ((cond)) { \
138 return; \
139 } \
140 } while (0)
141
142#if defined(__MWERKS__) && !defined(M2CTX)
143#define SDATA __declspec(section ".sdata")
144#define DATA __declspec(section ".data")
145#define WEAK __declspec(weak)
146#else
147#define SDATA
148#define DATA
149#define WEAK
150#endif
151
152#endif
bool(* Predicate)(void)
Definition platform.h:32
int enum_t
The underlying type of an enum, used as a placeholder.
Definition platform.h:27
void(* Event)(void)
A void callback with no arguments.
Definition platform.h:30
int bool
A signed integer used to contain boolean values.
Definition stdbool.h:8