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>
7
9typedef int enum_t;
10
12typedef void (*Event)(void);
13
14#if defined(__MWERKS__) && defined(__PPCGEKKO__)
15#define MWERKS_GEKKO
16#endif
17
18#ifndef ATTRIBUTE_ALIGN
19#if defined(__MWERKS__) || defined(__GNUC__)
20#define ATTRIBUTE_ALIGN(num) __attribute__((aligned(num)))
21#elif defined(_MSC_VER)
22#define ATTRIBUTE_ALIGN(num)
23#else
24#error unknown compiler
25#endif
26#endif
27
28#ifndef SECTION_INIT
29#if defined(__MWERKS__) && !defined(M2CTX)
30#define SECTION_INIT __declspec(section ".init")
31#else
32#define SECTION_INIT
33#endif
34#endif
35
36#ifndef SECTION_CTORS
37#if defined(__MWERKS__) && !defined(M2CTX)
38#define SECTION_CTORS __declspec(section ".ctors")
39#else
40#define SECTION_CTORS
41#endif
42#endif
43
44#ifndef SECTION_DTORS
45#if defined(__MWERKS__) && !defined(M2CTX)
46#define SECTION_DTORS __declspec(section ".dtors")
47#else
48#define SECTION_DTORS
49#endif
50#endif
51
52#ifndef ATTRIBUTE_NORETURN
53#if defined(__clang__) || defined(__GNUC__)
54#define ATTRIBUTE_NORETURN __attribute__((noreturn))
55#else
56#define ATTRIBUTE_NORETURN
57#endif
58#endif
59
60#ifndef ATTRIBUTE_RESTRICT
61#if defined(__MWERKS__) && !defined(M2CTX)
62#define ATTRIBUTE_RESTRICT __restrict
63#else
64#define ATTRIBUTE_RESTRICT
65#endif
66#endif
67
68#ifdef PERMUTER
69#define AT_ADDRESS(x) = FIXEDADDR(x)
70#elif defined(__MWERKS__) && !defined(M2CTX)
71#define AT_ADDRESS(x) : (x)
72#else
73#define AT_ADDRESS(x)
74#endif
75
76#ifdef __PPCGEKKO__
77#define qr0 0
78#define qr1 1
79#define qr2 2
80#define qr3 3
81#define qr4 4
82#define qr5 5
83#define qr6 6
84#define qr7 7
85#endif
86
87#define U8_MAX 0xFF
88#define U16_MAX 0xFFFF
89#define U32_MAX 0xFFFFFFFF
90#define S8_MAX 0x7F
91#define S16_MAX 0x7FFF
92#define S32_MAX 0x7FFFFFFF
93#define F32_MAX 3.4028235e38f
94
95#define SQ(x) ((x) * (x))
96#define MIN(a, b) (((a) > (b)) ? (b) : (a))
97#define MAX(a, b) (((a) > (b)) ? (a) : (b))
98
99#ifdef __cplusplus
100#ifndef _Static_assert
101#define _Static_assert static_assert
102#endif
103#endif
104#ifdef __MWERKS__
105#define STATIC_ASSERT(cond) \
106 struct { \
107 int x[1 - 2 * !(cond)]; \
108 };
109#else
110#define STATIC_ASSERT(cond) _Static_assert((cond), "(" #cond ") failed")
111#endif
112
113#define RETURN_IF(cond) \
114 do { \
115 if ((cond)) { \
116 return; \
117 } \
118 } while (0)
119
120#if defined(__MWERKS__) && !defined(M2CTX)
121#define SDATA __declspec(section ".sdata")
122#define WEAK __declspec(weak)
123#else
124#define SDATA
125#define WEAK
126#endif
127
128#endif
int enum_t
The underlying type of an enum, used as a placeholder.
Definition platform.h:9
void(* Event)(void)
A void callback with no arguments.
Definition platform.h:12