diff --git a/include/ircd/info.h b/include/ircd/info.h index eefe99e8c..0c1388956 100644 --- a/include/ircd/info.h +++ b/include/ircd/info.h @@ -44,6 +44,9 @@ namespace ircd::info extern const size_t hardware_concurrency; extern const size_t destructive_interference; extern const size_t constructive_interference; + extern const uint64_t rlimit_as; + extern const uint64_t rlimit_data; + extern const uint64_t rlimit_rss; #ifdef HAVE_SYS_UTSNAME_H extern const ::utsname utsname; #endif diff --git a/ircd/info.cc b/ircd/info.cc index 745dd76dd..bc84ba31d 100644 --- a/ircd/info.cc +++ b/ircd/info.cc @@ -8,6 +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. +#include void @@ -176,6 +177,40 @@ ircd::info::utsname{[] }()}; #endif +#ifdef HAVE_SYS_RESOURCE_H +static uint64_t +_get_rlimit(const int &resource) +{ + rlimit rlim; + ircd::syscall(getrlimit, RLIMIT_AS, &rlim); + return rlim.rlim_cur; +} +#else +static uint64_t +_get_rlimit(const int &resource) +{ + return 0; +} +#endif + +decltype(ircd::info::rlimit_as) +ircd::info::rlimit_as +{ + _get_rlimit(RLIMIT_AS) +}; + +decltype(ircd::info::rlimit_data) +ircd::info::rlimit_data +{ + _get_rlimit(RLIMIT_DATA) +}; + +decltype(ircd::info::rlimit_rss) +ircd::info::rlimit_rss +{ + _get_rlimit(RLIMIT_RSS) +}; + decltype(ircd::info::max_align) ircd::info::max_align {