Alchemy
Loading...
Searching...
No Matches

call.h

Go to the documentation of this file.
1#ifndef ALCHEMY_CALL_H
2#define ALCHEMY_CALL_H
3
4/// @file
5/// Calls through a function pointer, by argument count.
6
7#include "types.h"
8
9static __inline__ void Call1(void (*f)(), s32 a0) {
10 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
11 * direct-call constants. */
12 f(a0);
13}
14
15static __inline__ void Call2(void (*f)(), s32 a0, s32 a1) {
16 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
17 * direct-call constants. */
18 f(a0, a1);
19}
20
21static __inline__ void Call3(void (*f)(), s32 a0, s32 a1, s32 a2) {
22 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
23 * direct-call constants. */
24 f(a0, a1, a2);
25}
26
27static __inline__ void Call4(void (*f)(), s32 a0, s32 a1, s32 a2, s32 a3) {
28 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
29 * direct-call constants. */
30 f(a0, a1, a2, a3);
31}
32
33static __inline__ void Call6(void (*f)(), s32 a0, s32 a1, s32 a2, s32 a3,
34 s32 a4, s32 a5) {
35 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
36 * direct-call constants. */
37 f(a0, a1, a2, a3, a4, a5);
38}
39
40static __inline__ void Call7(void (*f)(), s32 a0, s32 a1, s32 a2, s32 a3,
41 s32 a4, s32 a5, s32 a6) {
42 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
43 * direct-call constants. */
44 f(a0, a1, a2, a3, a4, a5, a6);
45}
46
47static __inline__ void Call11(void (*f)(), s32 a0, s32 a1, s32 a2, s32 a3,
48 s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9,
49 s32 a10) {
50 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
51 * direct-call constants. */
52 f(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
53}
54
55static __inline__ s32 Value0(s32 (*f)()) {
56 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
57 * direct-call constants and keeps the result argument in r0. */
58 return f();
59}
60
61static __inline__ s32 Value1(s32 (*f)(), s32 a0) {
62 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
63 * direct-call constants and keeps the result argument in r0. */
64 return f(a0);
65}
66
67static __inline__ s32 Value2(s32 (*f)(), s32 a0, s32 a1) {
68 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
69 * direct-call constants and keeps the result argument in r0. */
70 return f(a0, a1);
71}
72
73static __inline__ s32 Value3(s32 (*f)(), s32 a0, s32 a1, s32 a2) {
74 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
75 * direct-call constants and keeps the result argument in r0. */
76 return f(a0, a1, a2);
77}
78
79static __inline__ s32 Value4(s32 (*f)(), s32 a0, s32 a1, s32 a2, s32 a3) {
80 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
81 * direct-call constants and keeps the result argument in r0. */
82 return f(a0, a1, a2, a3);
83}
84
85static __inline__ s32 Value6(s32 (*f)(), s32 a0, s32 a1, s32 a2, s32 a3, s32 a4,
86 s32 a5) {
87 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
88 * direct-call constants and keeps the result argument in r0. */
89 return f(a0, a1, a2, a3, a4, a5);
90}
91
92static __inline__ s32 Value7(s32 (*f)(), s32 a0, s32 a1, s32 a2, s32 a3, s32 a4,
93 s32 a5, s32 a6) {
94 /* FAKEMATCH: forwarding through the pointer prevents GCC 2.96 from sharing
95 * direct-call constants and keeps the result argument in r0. */
96 return f(a0, a1, a2, a3, a4, a5, a6);
97}
98
99#endif
static __inline__ void Call6(void(*f)(), s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5)
Definition call.h:33
static __inline__ void Call3(void(*f)(), s32 a0, s32 a1, s32 a2)
Definition call.h:21
static __inline__ void Call11(void(*f)(), s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, s32 a10)
Definition call.h:47
static __inline__ s32 Value1(s32(*f)(), s32 a0)
Definition call.h:61
static __inline__ void Call7(void(*f)(), s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6)
Definition call.h:40
static __inline__ s32 Value7(s32(*f)(), s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6)
Definition call.h:92
static __inline__ s32 Value4(s32(*f)(), s32 a0, s32 a1, s32 a2, s32 a3)
Definition call.h:79
static __inline__ s32 Value2(s32(*f)(), s32 a0, s32 a1)
Definition call.h:67
static __inline__ void Call4(void(*f)(), s32 a0, s32 a1, s32 a2, s32 a3)
Definition call.h:27
static __inline__ void Call1(void(*f)(), s32 a0)
Definition call.h:9
static __inline__ void Call2(void(*f)(), s32 a0, s32 a1)
Definition call.h:15
static __inline__ s32 Value3(s32(*f)(), s32 a0, s32 a1, s32 a2)
Definition call.h:73
static __inline__ s32 Value0(s32(*f)())
Definition call.h:55
static __inline__ s32 Value6(s32(*f)(), s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5)
Definition call.h:85
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14