0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd::info: Get kernel name and version out of utsname if available.

This commit is contained in:
Jason Volk 2019-03-13 15:57:49 -07:00
parent 4c6e943d49
commit 0158e88949
2 changed files with 43 additions and 0 deletions

View file

@ -51,6 +51,9 @@ namespace ircd::info
#ifdef HAVE_SYS_UTSNAME_H
extern const ::utsname utsname;
#endif
extern const string_view kname;
extern const string_view kversion_str;
extern const int kversion[3];
// Third-party information
extern const int glibc_version[3];

View file

@ -200,6 +200,46 @@ ircd::info::utsname{[]
}()};
#endif
decltype(ircd::info::kname)
ircd::info::kname
{
#ifdef HAVE_SYS_UTSNAME_H
utsname.sysname
#endif
};
decltype(ircd::info::kversion_str)
ircd::info::kversion_str
{
#ifdef HAVE_SYS_UTSNAME_H
utsname.release
#endif
};
decltype(ircd::info::kversion)
ircd::info::kversion
{
[] // major
{
const auto str(split(kversion_str, '.').first);
return try_lex_cast<int>(str)?
lex_cast<int>(str):
0;
}(),
[] // minor
{
auto str(split(kversion_str, '.').second);
str = split(str, '.').first;
return try_lex_cast<int>(str)?
lex_cast<int>(str):
0;
}(),
// patch
0
};
//
// System information
//