mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::mapi: Change header symbol name, visibility; use macro for declaration.
This commit is contained in:
parent
069d3b6f74
commit
1a266a0651
2 changed files with 39 additions and 12 deletions
|
@ -11,20 +11,46 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#define HAVE_IRCD_MAPI_H
|
#define HAVE_IRCD_MAPI_H
|
||||||
|
|
||||||
#define IRCD_MODULE_EXPORT_CODE_SECTION "ircd.code"
|
#define IRCD_MODULE_HEADER_SYMBOL_NAME "ircd_module"
|
||||||
#define IRCD_MODULE_EXPORT_DATA_SECTION "ircd.data"
|
#define IRCD_MODULE_IMPL_VISIBILITY "protected"
|
||||||
|
#define IRCD_MODULE_EXPORT_CODE_SECTION "ircd.code"
|
||||||
|
#define IRCD_MODULE_EXPORT_CODE_VISIBILITY "default"
|
||||||
|
#define IRCD_MODULE_EXPORT_DATA_SECTION "ircd.data"
|
||||||
|
#define IRCD_MODULE_EXPORT_DATA_VISIBILITY "default"
|
||||||
|
|
||||||
|
/// Macro of decorations used on function definitions in modules which are
|
||||||
|
/// loaded with RTLD_GLOBAL. These function definitions implement some decl
|
||||||
|
/// in the include/ircd/* headers; the decl is a weak unresolved symbol.
|
||||||
|
#define IRCD_MODULE_IMPL \
|
||||||
|
__attribute__((visibility(IRCD_MODULE_IMPL_VISIBILITY)))
|
||||||
|
|
||||||
|
/// Macro of decorations used on function definitions in modules which are
|
||||||
|
/// published for demangling and use by libircd. This is used in modules
|
||||||
|
/// which are loaded with RTLD_LOCAL where the function is manually imported
|
||||||
|
/// with the ircd::mods system.
|
||||||
#define IRCD_MODULE_EXPORT_CODE \
|
#define IRCD_MODULE_EXPORT_CODE \
|
||||||
__attribute__((section(IRCD_MODULE_EXPORT_CODE_SECTION))) \
|
__attribute__((section(IRCD_MODULE_EXPORT_CODE_SECTION))) \
|
||||||
__attribute__((visibility("default")))
|
__attribute__((visibility(IRCD_MODULE_EXPORT_CODE_VISIBILITY)))
|
||||||
|
|
||||||
|
/// Macro of decorations used on object definitions in modules which are
|
||||||
|
/// published for demangling and use by libircd. This is the object equivalent
|
||||||
|
/// of IRCD_MODULE_EXPORT_CODE (see docs).
|
||||||
#define IRCD_MODULE_EXPORT_DATA \
|
#define IRCD_MODULE_EXPORT_DATA \
|
||||||
__attribute__((section(IRCD_MODULE_EXPORT_DATA_SECTION))) \
|
__attribute__((section(IRCD_MODULE_EXPORT_DATA_SECTION))) \
|
||||||
__attribute__((visibility("default")))
|
__attribute__((visibility(IRCD_MODULE_EXPORT_CODE_VISIBILITY))) \
|
||||||
|
__attribute__((externally_visible))
|
||||||
|
|
||||||
// Common convenience
|
// Common convenience aliases
|
||||||
#define IRCD_MODULE_EXPORT \
|
#define IRCD_MODULE_EXPORT IRCD_MODULE_EXPORT_CODE
|
||||||
IRCD_MODULE_EXPORT_CODE
|
#define IRCD_EXPORT IRCD_MODULE_EXPORT
|
||||||
|
#define IRCD_IMPL IRCD_MODULE_IMPL
|
||||||
|
|
||||||
|
/// Module declaration
|
||||||
|
#define IRCD_MODULE \
|
||||||
|
__attribute__((visibility("default"))) \
|
||||||
|
__attribute__((externally_visible)) \
|
||||||
|
__attribute__((weak)) \
|
||||||
|
ircd_module
|
||||||
|
|
||||||
/// Module API: Interface for module developers.
|
/// Module API: Interface for module developers.
|
||||||
namespace ircd::mapi
|
namespace ircd::mapi
|
||||||
|
@ -45,7 +71,7 @@ namespace ircd::mapi
|
||||||
/// The name of the header variable in the module must match this string
|
/// The name of the header variable in the module must match this string
|
||||||
const char *const header_symbol_name
|
const char *const header_symbol_name
|
||||||
{
|
{
|
||||||
"IRCD_MODULE"
|
IRCD_MODULE_HEADER_SYMBOL_NAME
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Symbols in these sections are automatically demangle-mapped on load.
|
/// Symbols in these sections are automatically demangle-mapped on load.
|
||||||
|
@ -84,8 +110,7 @@ IRCD_MAPI_SERIAL
|
||||||
/// be externally visible. If this is not present or not visible, ircd::mods
|
/// be externally visible. If this is not present or not visible, ircd::mods
|
||||||
/// will not consider the file to be an IRCd module and it will be ignored.
|
/// will not consider the file to be an IRCd module and it will be ignored.
|
||||||
///
|
///
|
||||||
struct __attribute__((visibility("default")))
|
struct ircd::mapi::header
|
||||||
ircd::mapi::header
|
|
||||||
{
|
{
|
||||||
const magic_t magic {IRCD_MAPI_MAGIC}; // The magic must match
|
const magic_t magic {IRCD_MAPI_MAGIC}; // The magic must match
|
||||||
const version_t version {IRCD_MAPI_VERSION}; // Version indicator
|
const version_t version {IRCD_MAPI_VERSION}; // Version indicator
|
||||||
|
|
|
@ -94,7 +94,7 @@ struct cmd
|
||||||
cmd(std::string name, std::string symbol)
|
cmd(std::string name, std::string symbol)
|
||||||
:name{std::move(name)}
|
:name{std::move(name)}
|
||||||
,symbol{std::move(symbol)}
|
,symbol{std::move(symbol)}
|
||||||
,ptr{IRCD_MODULE, this->symbol}
|
,ptr{ircd_module, this->symbol}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
cmd() = default;
|
cmd() = default;
|
||||||
|
@ -110,7 +110,7 @@ init_cmds()
|
||||||
{
|
{
|
||||||
auto symbols
|
auto symbols
|
||||||
{
|
{
|
||||||
mods::symbols(mods::path(IRCD_MODULE))
|
mods::symbols(mods::path(ircd_module))
|
||||||
};
|
};
|
||||||
|
|
||||||
for(std::string &symbol : symbols)
|
for(std::string &symbol : symbols)
|
||||||
|
@ -196,6 +196,8 @@ _console_command(opt &out,
|
||||||
return ptr.operator()<prototype>(out, args);
|
return ptr.operator()<prototype>(out, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC visibility push(default)
|
||||||
|
|
||||||
/// This function may be linked and called by those wishing to execute a
|
/// This function may be linked and called by those wishing to execute a
|
||||||
/// command. Output from the command will be appended to the provided ostream.
|
/// command. Output from the command will be appended to the provided ostream.
|
||||||
/// The input to the command is passed in `line`. Since `struct opt` is not
|
/// The input to the command is passed in `line`. Since `struct opt` is not
|
||||||
|
|
Loading…
Reference in a new issue