0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-17 15:30:52 +01:00

ircd::info: Gather information from rlimit if available.

This commit is contained in:
Jason Volk 2018-04-02 17:03:05 -07:00
parent c54e7f5afe
commit 31c3dea483
2 changed files with 38 additions and 0 deletions

View file

@ -44,6 +44,9 @@ namespace ircd::info
extern const size_t hardware_concurrency; extern const size_t hardware_concurrency;
extern const size_t destructive_interference; extern const size_t destructive_interference;
extern const size_t constructive_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 #ifdef HAVE_SYS_UTSNAME_H
extern const ::utsname utsname; extern const ::utsname utsname;
#endif #endif

View file

@ -8,6 +8,7 @@
// copyright notice and this permission notice is present in all copies. The // copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file. // full license for this software is available in the LICENSE file.
#include <RB_INC_SYS_RESOURCE_H
#include <ircd/asio.h> #include <ircd/asio.h>
void void
@ -176,6 +177,40 @@ ircd::info::utsname{[]
}()}; }()};
#endif #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) decltype(ircd::info::max_align)
ircd::info::max_align ircd::info::max_align
{ {