From: ljsebald <ljs...@us...> - 2023-11-23 03:45:06
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via b6d26daa07a7e1b0342be19a5a8787d978e9b62b (commit) via 1d6c9fd74b0f199c9609ebe57e7920cdaa0b629d (commit) from 8aa26e9089de3928faca950a9ad73ad3a392e9d2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b6d26daa07a7e1b0342be19a5a8787d978e9b62b Merge: 8aa26e9 1d6c9fd Author: Lawrence Sebald <ljs...@us...> Date: Wed Nov 22 22:15:35 2023 -0500 Merge pull request #381 from pcercuei/kos_init_flags_cpp init.h: Support KOS_INIT_FLAGS() in C++ code commit 1d6c9fd74b0f199c9609ebe57e7920cdaa0b629d Author: Paul Cercueil <pa...@cr...> Date: Wed Nov 22 22:56:49 2023 +0100 init.h: Support KOS_INIT_FLAGS() in C++ code Automatically add extern "C" brackets around the exported variables when the KOS_INIT_FLAGS() macro is used inside C++ code. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: include/kos/init.h | 54 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/include/kos/init.h b/include/kos/init.h index 341e04d..4becbeb 100644 --- a/include/kos/init.h +++ b/include/kos/init.h @@ -28,6 +28,10 @@ #ifndef __KOS_INIT_H #define __KOS_INIT_H +#ifdef __cplusplus +extern "C" { +#endif + #include <kos/cdefs.h> __BEGIN_DECLS @@ -35,19 +39,14 @@ __BEGIN_DECLS #include <kos/init_base.h> #include <stdint.h> -/** \brief Exports and initializes the given KOS subsystems. - - KOS_INIT_FLAGS() provides a mechanism through which various components - of KOS can be enabled and initialized depending on whether their flag - has been included within the list. - - \note - When no KOS_INIT_FLAGS() have been explicitly provided, the default - flags used by KOS are equivalent to KOS_INIT_FLAGS(INIT_DEFAULT). +/** \cond */ +#ifdef __cplusplus +#define __kos_cplusplus 1 +#else +#define __kos_cplusplus 0 +#endif - \param flags Parts of KOS to init. - */ - #define KOS_INIT_FLAGS(flags) \ + #define __KOS_INIT_FLAGS_0(flags) \ const uint32_t __kos_init_flags = (flags); \ KOS_INIT_FLAG(flags, INIT_NET, arch_init_net); \ KOS_INIT_FLAG(flags, INIT_NET, net_shutdown); \ @@ -58,10 +57,35 @@ __BEGIN_DECLS KOS_INIT_FLAG(flags, INIT_EXPORT, export_init); \ KOS_INIT_FLAGS_ARCH(flags) -/** \cond */ +#define __KOS_INIT_FLAGS_1(flags) \ + extern "C" { \ + __KOS_INIT_FLAGS_0(flags); \ + } + +#define __KOS_INIT_FLAGS(flags, cp) \ + __KOS_INIT_FLAGS_##cp(flags) + +#define _KOS_INIT_FLAGS(flags, cp) \ + __KOS_INIT_FLAGS(flags, cp) + extern const uint32_t __kos_init_flags; /** \endcond */ +/** \brief Exports and initializes the given KOS subsystems. + + KOS_INIT_FLAGS() provides a mechanism through which various components + of KOS can be enabled and initialized depending on whether their flag + has been included within the list. + + \note + When no KOS_INIT_FLAGS() have been explicitly provided, the default + flags used by KOS are equivalent to KOS_INIT_FLAGS(INIT_DEFAULT). + + \param flags Parts of KOS to init. + */ +#define KOS_INIT_FLAGS(flags) \ + _KOS_INIT_FLAGS(flags, __kos_cplusplus) + /** \brief Deprecated and not useful anymore. */ #define KOS_INIT_ROMDISK(rd) \ void *__kos_romdisk = (rd); \ @@ -108,4 +132,8 @@ extern void * __kos_romdisk; __END_DECLS +#ifdef __cplusplus +}; +#endif + #endif /* !__KOS_INIT_H */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |