0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00

ircd: Various symbol internalizing and PLT reductions.

This commit is contained in:
Jason Volk 2022-06-14 14:15:53 -07:00
parent 2288e0d6fa
commit 4ae50c97d1
19 changed files with 120 additions and 46 deletions

View file

@ -136,7 +136,7 @@ struct ircd::exception
/// Remember: the order of the catch blocks is important.
///
#define IRCD_EXCEPTION(parent, name) \
struct name \
struct [[gnu::visibility("protected")]] name \
:parent \
{ \
template<class... args> \
@ -180,7 +180,7 @@ struct name \
/// Hides the name of the exception when generating a string
#define IRCD_EXCEPTION_HIDENAME(parent, name) \
struct name \
struct [[gnu::visibility("protected")]] name \
:parent \
{ \
template<class... args> \

View file

@ -56,15 +56,15 @@ class ircd::fmt::snprintf
const_buffer fmt; // Current running position in the fmtstr.
short idx; // Keeps count of the args for better err msgs
protected:
bool finished() const;
size_t remaining() const;
bool finished() const noexcept;
size_t remaining() const noexcept;
size_t consumed() const { return out.consumed(); }
string_view completed() const { return out.completed(); }
void append(const string_view &);
void argument(const arg &);
protected:
IRCD_OVERLOAD(internal)
snprintf(internal_t, const mutable_buffer &, const string_view &, const va_rtti &);

View file

@ -17,7 +17,8 @@
// definition file if you need low level access to this acceptor API.
/// Implementation to net::listener. See listener.h for additional interface.
struct ircd::net::acceptor
struct [[gnu::visibility("protected")]]
ircd::net::acceptor
:std::enable_shared_from_this<struct ircd::net::acceptor>
{
using error_code = boost::system::error_code;

View file

@ -16,7 +16,8 @@
// is part of the <ircd/asio.h> stack which can be included in your
// definition file if you need low level access to this acceptor API.
struct ircd::net::acceptor_udp
struct [[gnu::visibility("protected")]]
ircd::net::acceptor_udp
{
using error_code = boost::system::error_code;
using datagram = listener_udp::datagram;

View file

@ -101,9 +101,14 @@ struct ircd::net::dns::opts
};
/// (internal)
struct ircd::net::dns::init
class [[gnu::visibility("hidden")]]
ircd::net::dns::init
{
static void service_init(), service_fini() noexcept;
static void
service_init(),
service_fini() noexcept;
init(), ~init() noexcept;
public:
init();
~init() noexcept;
};

View file

@ -27,7 +27,8 @@ namespace ircd::net::dns
uint16_t resolver_call(const hostport &, const opts &);
}
struct ircd::net::dns::resolver
struct [[gnu::visibility("protected")]]
ircd::net::dns::resolver
{
using header = rfc1035::header;
@ -100,7 +101,8 @@ struct ircd::net::dns::resolver
~resolver() noexcept;
};
struct ircd::net::dns::tag
struct [[gnu::visibility("protected")]]
ircd::net::dns::tag
{
uint16_t id {0};
hostport hp;

View file

@ -26,7 +26,8 @@ namespace ircd::net
/// Internal socket interface
///
struct ircd::net::socket
struct [[gnu::visibility("protected")]]
ircd::net::socket
:std::enable_shared_from_this<ircd::net::socket>
{
struct io;

View file

@ -26,7 +26,7 @@ namespace ircd
/// the triggering callsite should be eliminated. Nevertheless it throws
/// normally in release mode for recovering at an exception handler.
#define IRCD_PANICKING(parent, name) \
struct name \
struct [[gnu::visibility("protected")]] name \
:parent \
{ \
template<class... args> \

View file

@ -71,7 +71,6 @@ struct ircd::rfc3986::uri
uri() = default;
};
#pragma GCC visibility push(default)
// Exposition of individual grammatical elements. Due to the diverse and
// foundational applications of this unit, we offer a public list of references
// to individual rules in the grammar; many of these are directly specified in
@ -81,6 +80,7 @@ struct ircd::rfc3986::uri
// which take a reference to any apropos rule. To avoid exposure of
// boost::spirit in project headers these types are carefully crafted thin forward
// declarations, so spirit itself is not included here.
#pragma GCC visibility push(default)
namespace ircd::rfc3986::parser
{
using it = const char *;

View file

@ -136,7 +136,8 @@ struct ircd::run::changed
/// otherwise an exception is thrown.
///
template<class E>
struct ircd::run::barrier
struct [[gnu::visibility("internal")]]
ircd::run::barrier
{
template<class... args>
barrier(args&&... a)

View file

@ -2224,11 +2224,13 @@ ircd::cl::offload_opts
"cl"
};
[[gnu::visibility("hidden")]]
void
ircd::cl::work::init()
{
}
[[using gnu: cold, visibility("hidden")]]
void
ircd::cl::work::fini()
noexcept

View file

@ -246,11 +246,13 @@ noexcept
//
// Out-of-line placement
[[gnu::visibility("protected")]]
ircd::exception::~exception()
noexcept
{
}
[[gnu::visibility("protected")]]
ssize_t
ircd::exception::generate(const string_view &fmt,
const va_rtti &ap)
@ -259,6 +261,7 @@ noexcept
return fmt::vsnprintf(buf, sizeof(buf), fmt, ap);
}
[[gnu::visibility("protected")]]
ssize_t
ircd::exception::generate(const char *const &name,
const string_view &fmt,
@ -275,6 +278,7 @@ noexcept
return size;
}
[[gnu::visibility("protected")]]
const char *
ircd::exception::what()
const noexcept

View file

@ -8,8 +8,7 @@
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
namespace ircd { namespace fmt
__attribute__((visibility("internal")))
namespace ircd::fmt
{
using namespace ircd::spirit;
@ -29,22 +28,23 @@ __attribute__((visibility("internal")))
constexpr char SPECIFIER_TERMINATOR {'$'};
template<class generator>
bool generate_string(char *&out, const size_t &max, generator&&, const arg &val);
static bool generate_string(char *&out, const size_t &max, generator&&, const arg &val);
template<class gen,
class... attr>
bool generate(mutable_buffer &, gen&&, attr&&...);
static bool generate(mutable_buffer &, gen&&, attr&&...);
template<class T,
class lambda>
bool visit_type(const arg &val, lambda&& closure);
static bool visit_type(const arg &val, lambda&& closure);
void handle_specifier(mutable_buffer &out, const uint &idx, const spec &, const arg &);
}}
static void handle_specifier(mutable_buffer &out, const uint &idx, const spec &, const arg &);
}
/// Structural representation of a format specifier. The parse of each
/// specifier in the format string creates one of these.
struct ircd::fmt::spec
struct [[gnu::visibility("internal")]]
ircd::fmt::spec
{
char sign {'+'};
char pad {' '};
@ -67,12 +67,15 @@ BOOST_FUSION_ADAPT_STRUCT
)
#pragma GCC visibility pop
#pragma GCC visibility push(internal)
/// The format string parser grammar.
namespace ircd::fmt::parser
{
template<class R = unused_type>
using rule = qi::rule<const char *, R>;
struct [[gnu::visibility("internal")]] rule
:qi::rule<const char *, R>
{
using qi::rule<const char *, R>::rule;
};
const expr specsym
{
@ -104,13 +107,13 @@ namespace ircd::fmt::parser
"specifier"
};
}
#pragma GCC visibility pop
/// A format specifier handler module. This allows a new "%foo" to be defined
/// with custom handling by overriding. This abstraction is inserted into a
/// mapping key'ed by the supplied names leading to an instance of this.
///
class ircd::fmt::specifier
class [[gnu::visibility("hidden")]]
ircd::fmt::specifier
{
static std::map<string_view, const specifier *, std::less<>> registry;
@ -130,7 +133,8 @@ class ircd::fmt::specifier
decltype(ircd::fmt::specifier::registry)
ircd::fmt::specifier::registry;
struct ircd::fmt::string_specifier
struct [[gnu::visibility("hidden")]]
ircd::fmt::string_specifier
:specifier
{
static const std::tuple
@ -156,7 +160,8 @@ const ircd::fmt::string_specifier
decltype(ircd::fmt::string_specifier::types)
ircd::fmt::string_specifier::types;
struct ircd::fmt::bool_specifier
struct [[gnu::visibility("hidden")]]
ircd::fmt::bool_specifier
:specifier
{
static const std::tuple
@ -181,7 +186,8 @@ const ircd::fmt::bool_specifier
decltype(ircd::fmt::bool_specifier::types)
ircd::fmt::bool_specifier::types;
struct ircd::fmt::signed_specifier
struct [[gnu::visibility("hidden")]]
ircd::fmt::signed_specifier
:specifier
{
static const std::tuple
@ -206,7 +212,8 @@ const ircd::fmt::signed_specifier
decltype(ircd::fmt::signed_specifier::types)
ircd::fmt::signed_specifier::types;
struct ircd::fmt::unsigned_specifier
struct [[gnu::visibility("hidden")]]
ircd::fmt::unsigned_specifier
:specifier
{
static const std::tuple
@ -228,7 +235,8 @@ const ircd::fmt::unsigned_specifier
{ "u"s, "lu"s, "zu"s }
};
struct ircd::fmt::hex_lowercase_specifier
struct [[gnu::visibility("hidden")]]
ircd::fmt::hex_lowercase_specifier
:specifier
{
static const std::tuple
@ -253,7 +261,8 @@ const ircd::fmt::hex_lowercase_specifier
decltype(ircd::fmt::hex_lowercase_specifier::types)
ircd::fmt::hex_lowercase_specifier::types;
struct ircd::fmt::hex_uppercase_specifier
struct [[gnu::visibility("hidden")]]
ircd::fmt::hex_uppercase_specifier
:specifier
{
static const std::tuple
@ -281,7 +290,8 @@ ircd::fmt::hex_uppercase_specifier::types;
decltype(ircd::fmt::unsigned_specifier::types)
ircd::fmt::unsigned_specifier::types;
struct ircd::fmt::float_specifier
struct [[gnu::visibility("hidden")]]
ircd::fmt::float_specifier
:specifier
{
static const std::tuple
@ -306,7 +316,8 @@ const ircd::fmt::float_specifier
decltype(ircd::fmt::float_specifier::types)
ircd::fmt::float_specifier::types;
struct ircd::fmt::char_specifier
struct [[gnu::visibility("hidden")]]
ircd::fmt::char_specifier
:specifier
{
bool operator()(char *&out, const size_t &max, const spec &, const arg &val) const override;
@ -317,7 +328,8 @@ const ircd::fmt::char_specifier
"c"s
};
struct ircd::fmt::pointer_specifier
struct [[gnu::visibility("hidden")]]
ircd::fmt::pointer_specifier
:specifier
{
bool operator()(char *&out, const size_t &max, const spec &, const arg &val) const override;
@ -332,6 +344,7 @@ const ircd::fmt::pointer_specifier
// snprintf::snprintf
//
[[gnu::visibility("protected")]]
ircd::fmt::snprintf::snprintf(internal_t,
const mutable_buffer &out,
const string_view &fmt,
@ -386,6 +399,7 @@ catch(const std::out_of_range &e)
};
}
[[gnu::visibility("hidden")]]
void
ircd::fmt::snprintf::argument(const arg &val)
{
@ -426,6 +440,7 @@ ircd::fmt::snprintf::argument(const arg &val)
consume(this->fmt, size(leg));
}
[[gnu::visibility("hidden")]]
void
ircd::fmt::snprintf::append(const string_view &src)
{
@ -435,18 +450,20 @@ ircd::fmt::snprintf::append(const string_view &src)
});
}
[[gnu::visibility("hidden")]]
size_t
ircd::fmt::snprintf::remaining()
const
const noexcept
{
return out.remaining()?
out.remaining() - 1:
0;
}
[[gnu::visibility("hidden")]]
bool
ircd::fmt::snprintf::finished()
const
const noexcept
{
return empty(fmt) || !remaining();
}

View file

@ -12,6 +12,7 @@
#pragma STDC FENV_ACCESS on
#endif
[[gnu::visibility("protected")]]
void
ircd::fpe::debug_info()
{

View file

@ -56,6 +56,7 @@ ircd::boost_version_abi
"boost", info::versions::ABI //TODO: get this
};
[[gnu::visibility("hidden")]]
void
ircd::ios::init(asio::executor &&user)
{
@ -78,7 +79,7 @@ ircd::ios::init(asio::executor &&user)
ios::main = *ios::primary;
}
[[gnu::cold]]
[[using gnu: cold, visibility("hidden")]]
void
ircd::ios::forking()
{
@ -89,7 +90,7 @@ ircd::ios::forking()
#endif
}
[[gnu::cold]]
[[using gnu: cold, visibility("hidden")]]
void
ircd::ios::forked_child()
{
@ -100,7 +101,7 @@ ircd::ios::forked_child()
#endif
}
[[gnu::cold]]
[[using gnu: cold, visibility("hidden")]]
void
ircd::ios::forked_parent()
{

View file

@ -121,6 +121,7 @@ ircd::log::hook;
// init
//
[[gnu::visibility("hidden")]]
void
ircd::log::init()
{
@ -145,6 +146,7 @@ ircd::log::init()
ircd::log::ready = true;
}
[[using gnu: cold, visibility("hidden")]]
void
ircd::log::fini()
{

View file

@ -1215,6 +1215,7 @@ ircd::net::ssl_cipher_blacklist
{ "default", string_view{} },
};
[[gnu::visibility("hidden")]]
boost::asio::ssl::context
ircd::net::sslv23_client
{
@ -1222,12 +1223,10 @@ ircd::net::sslv23_client
};
decltype(ircd::net::socket::count)
ircd::net::socket::count
{};
ircd::net::socket::count;
decltype(ircd::net::socket::instances)
ircd::net::socket::instances
{};
ircd::net::socket::instances;
decltype(ircd::net::socket::desc_connect)
ircd::net::socket::desc_connect
@ -2698,6 +2697,7 @@ ircd::net::string(const mutable_buffer &buf,
};
}
[[gnu::visibility("protected")]]
ircd::net::ipport
ircd::net::make_ipport(const boost::asio::ip::udp::endpoint &ep)
{
@ -2707,6 +2707,7 @@ ircd::net::make_ipport(const boost::asio::ip::udp::endpoint &ep)
};
}
[[gnu::visibility("protected")]]
ircd::net::ipport
ircd::net::make_ipport(const boost::asio::ip::tcp::endpoint &ep)
{
@ -2716,6 +2717,7 @@ ircd::net::make_ipport(const boost::asio::ip::tcp::endpoint &ep)
};
}
[[gnu::visibility("protected")]]
boost::asio::ip::udp::endpoint
ircd::net::make_endpoint_udp(const ipport &ipport)
{
@ -2725,6 +2727,7 @@ ircd::net::make_endpoint_udp(const ipport &ipport)
};
}
[[gnu::visibility("protected")]]
boost::asio::ip::tcp::endpoint
ircd::net::make_endpoint(const ipport &ipport)
{
@ -2757,6 +2760,7 @@ const
// net/ipaddr.h
//
[[gnu::visibility("protected")]]
boost::asio::ip::address
ircd::net::make_address(const ipaddr &ipaddr)
{
@ -2765,6 +2769,7 @@ ircd::net::make_address(const ipaddr &ipaddr)
ip::address(make_address(ipaddr.v6));
}
[[gnu::visibility("protected")]]
boost::asio::ip::address
ircd::net::make_address(const string_view &ip)
try
@ -2781,12 +2786,14 @@ catch(const boost::system::system_error &e)
throw_system_error(e);
}
[[gnu::visibility("protected")]]
boost::asio::ip::address_v4
ircd::net::make_address(const uint32_t &ip)
{
return ip::address_v4{ip};
}
[[gnu::visibility("protected")]]
boost::asio::ip::address_v6
ircd::net::make_address(const uint128_t &ip)
{
@ -2906,6 +2913,7 @@ ircd::net::ipaddr::ipaddr(const uint128_t &ip)
{
}
[[gnu::visibility("protected")]]
ircd::net::ipaddr::ipaddr(const asio::ip::address &address)
{
const auto address_
@ -3080,12 +3088,14 @@ ircd::net::string(const mutable_buffer &buf,
// net/asio.h
//
[[gnu::visibility("protected")]]
std::string
ircd::net::string(const ip::tcp::endpoint &ep)
{
return string(make_ipport(ep));
}
[[gnu::visibility("protected")]]
ircd::string_view
ircd::net::string(const mutable_buffer &buf,
const ip::tcp::endpoint &ep)
@ -3093,24 +3103,28 @@ ircd::net::string(const mutable_buffer &buf,
return string(buf, make_ipport(ep));
}
[[gnu::visibility("protected")]]
std::string
ircd::net::host(const ip::tcp::endpoint &ep)
{
return string(addr(ep));
}
[[gnu::visibility("protected")]]
boost::asio::ip::address
ircd::net::addr(const ip::tcp::endpoint &ep)
{
return ep.address();
}
[[gnu::visibility("protected")]]
uint16_t
ircd::net::port(const ip::tcp::endpoint &ep)
{
return ep.port();
}
[[gnu::visibility("protected")]]
std::string
ircd::net::string(const ip::address &addr)
{
@ -3120,6 +3134,7 @@ ircd::net::string(const ip::address &addr)
string(addr.to_v6());
}
[[gnu::visibility("protected")]]
std::string
ircd::net::string(const ip::address_v4 &addr)
{
@ -3130,12 +3145,14 @@ ircd::net::string(const ip::address_v4 &addr)
});
}
[[gnu::visibility("protected")]]
std::string
ircd::net::string(const ip::address_v6 &addr)
{
return addr.to_string();
}
[[gnu::visibility("protected")]]
ircd::string_view
ircd::net::string(const mutable_buffer &out,
const ip::address &addr)
@ -3146,6 +3163,7 @@ ircd::net::string(const mutable_buffer &out,
string(out, addr.to_v6());
}
[[gnu::visibility("protected")]]
ircd::string_view
ircd::net::string(const mutable_buffer &out,
const ip::address_v4 &addr)
@ -3161,6 +3179,7 @@ ircd::net::string(const mutable_buffer &out,
};
}
[[gnu::visibility("protected")]]
ircd::string_view
ircd::net::string(const mutable_buffer &out,
const ip::address_v6 &addr)
@ -3188,6 +3207,7 @@ ircd::buffer::null_buffers
null_buffer
}};
[[gnu::visibility("protected")]]
ircd::buffer::mutable_buffer::operator
boost::asio::mutable_buffer()
const noexcept
@ -3198,6 +3218,7 @@ const noexcept
};
}
[[gnu::visibility("protected")]]
ircd::buffer::const_buffer::operator
boost::asio::const_buffer()
const noexcept

View file

@ -22,6 +22,7 @@ namespace ircd::net::dns
/// Custom internal database. This translates a service name and protocol
/// into a port number. Note that a query to this table will only be made
/// after the system query does not return results (or cannot be made).
[[gnu::visibility("internal")]]
decltype(ircd::net::dns::service_ports)
ircd::net::dns::service_ports
{
@ -31,6 +32,7 @@ ircd::net::dns::service_ports
/// Custom internal database. This translates a service port and protocol
/// into a service name. Note that a query to this table will only be made
/// after the system query does not return results (or cannot be made).
[[gnu::visibility("internal")]]
decltype(ircd::net::dns::service_names)
ircd::net::dns::service_names
{

View file

@ -12,6 +12,7 @@
#include <RB_INC_VALGRIND_MEMCHECK_H
#include <RB_INC_VALGRIND_CALLGRIND_H
[[gnu::visibility("protected")]]
void
ircd::vg::set_noaccess(const const_buffer &buf)
noexcept
@ -21,6 +22,7 @@ noexcept
#endif
}
[[gnu::visibility("protected")]]
void
ircd::vg::set_undefined(const const_buffer &buf)
noexcept
@ -30,6 +32,7 @@ noexcept
#endif
}
[[gnu::visibility("protected")]]
void
ircd::vg::set_defined(const const_buffer &buf)
noexcept
@ -39,6 +42,7 @@ noexcept
#endif
}
[[gnu::visibility("protected")]]
bool
ircd::vg::defined(const const_buffer &buf)
noexcept
@ -50,6 +54,7 @@ noexcept
#endif
}
[[gnu::visibility("protected")]]
size_t
ircd::vg::errors()
noexcept
@ -75,6 +80,7 @@ ircd::vg::active{[]() -> bool
// vg::stack
//
[[gnu::visibility("protected")]]
void
ircd::vg::stack::del(const uint &id)
noexcept
@ -84,6 +90,7 @@ noexcept
#endif
}
[[gnu::visibility("protected")]]
uint
ircd::vg::stack::add(const mutable_buffer &buf)
noexcept
@ -105,6 +112,7 @@ namespace ircd::prof::vg
static bool _enabled;
}
[[gnu::visibility("protected")]]
void
ircd::prof::vg::stop()
noexcept
@ -116,6 +124,7 @@ noexcept
#endif
}
[[gnu::visibility("protected")]]
void
ircd::prof::vg::start()
noexcept
@ -127,6 +136,7 @@ noexcept
#endif
}
[[gnu::visibility("protected")]]
void
ircd::prof::vg::reset()
{
@ -135,6 +145,7 @@ ircd::prof::vg::reset()
#endif
}
[[gnu::visibility("protected")]]
void
ircd::prof::vg::toggle()
{
@ -143,6 +154,7 @@ ircd::prof::vg::toggle()
#endif
}
[[gnu::visibility("protected")]]
void
ircd::prof::vg::dump(const char *const reason)
{
@ -151,6 +163,7 @@ ircd::prof::vg::dump(const char *const reason)
#endif
}
[[gnu::visibility("protected")]]
bool
ircd::prof::vg::enabled()
{