0
0
Fork 0
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:
Jason Volk 2019-05-01 17:06:40 -07:00
parent 069d3b6f74
commit 1a266a0651
2 changed files with 39 additions and 12 deletions

View file

@ -11,20 +11,46 @@
#pragma once
#define HAVE_IRCD_MAPI_H
#define IRCD_MODULE_EXPORT_CODE_SECTION "ircd.code"
#define IRCD_MODULE_EXPORT_DATA_SECTION "ircd.data"
#define IRCD_MODULE_HEADER_SYMBOL_NAME "ircd_module"
#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 \
__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 \
__attribute__((section(IRCD_MODULE_EXPORT_DATA_SECTION))) \
__attribute__((visibility("default")))
__attribute__((visibility(IRCD_MODULE_EXPORT_CODE_VISIBILITY))) \
__attribute__((externally_visible))
// Common convenience
#define IRCD_MODULE_EXPORT \
IRCD_MODULE_EXPORT_CODE
// Common convenience aliases
#define IRCD_MODULE_EXPORT 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.
namespace ircd::mapi
@ -45,7 +71,7 @@ namespace ircd::mapi
/// The name of the header variable in the module must match this string
const char *const header_symbol_name
{
"IRCD_MODULE"
IRCD_MODULE_HEADER_SYMBOL_NAME
};
/// 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
/// will not consider the file to be an IRCd module and it will be ignored.
///
struct __attribute__((visibility("default")))
ircd::mapi::header
struct ircd::mapi::header
{
const magic_t magic {IRCD_MAPI_MAGIC}; // The magic must match
const version_t version {IRCD_MAPI_VERSION}; // Version indicator

View file

@ -94,7 +94,7 @@ struct cmd
cmd(std::string name, std::string symbol)
:name{std::move(name)}
,symbol{std::move(symbol)}
,ptr{IRCD_MODULE, this->symbol}
,ptr{ircd_module, this->symbol}
{}
cmd() = default;
@ -110,7 +110,7 @@ init_cmds()
{
auto symbols
{
mods::symbols(mods::path(IRCD_MODULE))
mods::symbols(mods::path(ircd_module))
};
for(std::string &symbol : symbols)
@ -196,6 +196,8 @@ _console_command(opt &out,
return ptr.operator()<prototype>(out, args);
}
#pragma GCC visibility push(default)
/// 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.
/// The input to the command is passed in `line`. Since `struct opt` is not