KallistiOS
git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
init_base.h
Go to the documentation of this file.
1
/* KallistiOS ##version##
2
3
include/kos/init_base.h
4
Copyright (C) 2023 Falco Girgis
5
6
*/
7
8
/** \file kos/init_base.h
9
\brief Shared initialization macros and utilities
10
\ingroup init_flags
11
12
This file contains common utilities which can be included within
13
architecture-specific `init_flags.h` files, providing a base
14
layer of infrastructure for managing initialization flags.
15
16
\sa kos/init.h
17
\sa arch/init_flags.h
18
19
\author Falco Girgis
20
*/
21
22
#ifndef __KOS_INIT_BASE_H
23
#define __KOS_INIT_BASE_H
24
25
#include <
kos/cdefs.h
>
26
__BEGIN_DECLS
27
28
/** \cond */
29
30
/* Declares a weak function pointer which can be optionally
31
overridden and given a value later. */
32
#define KOS_INIT_FLAG_WEAK(func, dft_on) \
33
void (*func##_weak)(void) __weak = (dft_on) ? func : NULL
34
35
/* Invokes the given function if its weak function pointer
36
has been overridden to point to a valid function. */
37
#define KOS_INIT_FLAG_CALL(func) ({ \
38
int ret = 0; \
39
if(func##_weak) { \
40
(*func##_weak)(); \
41
ret = 1; \
42
} \
43
ret; \
44
})
45
46
/* Export the given function pointer by assigning it to the weak function
47
* pointer if the given flags value contains all the flags set in the mask. */
48
#define KOS_INIT_FLAG_ALL(flags, mask, func) \
49
extern void func(void); \
50
void (*func##_weak)(void) = ((flags) & (mask)) == (mask) ? func : NULL
51
52
/* Export the given function by assigning it to the weak function pointer if the
53
given flags value contains none of the flags set in the mask. */
54
#define KOS_INIT_FLAG_NONE(flags, mask, func) \
55
extern void func(void); \
56
void (*func##_weak)(void) = ((flags) & (mask)) ? NULL : func
57
58
/* Export the given function by assigning it to the weak function pointer if the
59
given flags value contains the selected flag */
60
#define KOS_INIT_FLAG(flags, mask, func) \
61
extern void func(void); \
62
void (*func##_weak)(void) = ((flags) & (mask)) ? func : NULL
63
64
/** \endcond */
65
66
__END_DECLS
67
68
#endif
/* !__ARCH_INIT_BASE_H */
cdefs.h
Definitions for builtin attributes and compiler directives.
include
kos
init_base.h
Generated by
1.11.0