2018-01-17 12:55:36 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
2018-02-04 03:22:01 +01:00
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
2018-01-17 12:55:36 +01:00
|
|
|
|
2018-08-23 10:09:11 +02:00
|
|
|
#include <RB_INC_UNISTD_H
|
2019-04-01 01:06:17 +02:00
|
|
|
#include <RB_INC_CPUID_H
|
2020-03-16 19:59:08 +01:00
|
|
|
#include <RB_INC_SYS_SYSINFO_H
|
2019-06-02 07:22:44 +02:00
|
|
|
#include <RB_INC_GNU_LIBC_VERSION_H
|
2018-01-17 12:55:36 +01:00
|
|
|
|
2019-06-05 23:22:18 +02:00
|
|
|
namespace ircd::info
|
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
static void dump_exe_info();
|
|
|
|
static void dump_lib_info();
|
|
|
|
static void dump_sys_info();
|
2019-06-05 23:22:18 +02:00
|
|
|
static void dump_cpu_info();
|
|
|
|
}
|
|
|
|
|
2019-04-23 10:30:36 +02:00
|
|
|
decltype(ircd::info::credits)
|
|
|
|
ircd::info::credits
|
2018-04-20 21:41:03 +02:00
|
|
|
{
|
2019-04-23 10:30:36 +02:00
|
|
|
"Inspired by the original Internet Relay Chat daemon from Jarkko Oikarinen",
|
|
|
|
" ",
|
|
|
|
"This - is The Construct",
|
|
|
|
" ",
|
|
|
|
"Internet Relay Chat daemon: Matrix Construct",
|
|
|
|
" ",
|
|
|
|
"Copyright (C) 2016-2018 Matrix Construct Developers, Authors & Contributors",
|
|
|
|
"Permission to use, copy, modify, and/or distribute this software for any",
|
|
|
|
"purpose with or without fee is hereby granted, provided that the above",
|
|
|
|
"copyright notice and this permission notice is present in all copies.",
|
|
|
|
" ",
|
|
|
|
nullptr
|
|
|
|
};
|
2018-04-20 21:41:03 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
ircd::info::dump()
|
2018-01-17 12:55:36 +01:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
dump_exe_info();
|
|
|
|
dump_lib_info();
|
|
|
|
dump_sys_info();
|
2019-06-05 23:22:18 +02:00
|
|
|
dump_cpu_info();
|
2018-01-17 12:55:36 +01:00
|
|
|
}
|
|
|
|
|
2019-05-31 05:12:32 +02:00
|
|
|
//
|
|
|
|
// Version registry
|
|
|
|
//
|
|
|
|
|
|
|
|
template<>
|
|
|
|
decltype(ircd::util::instance_list<ircd::info::versions>::allocator)
|
|
|
|
ircd::util::instance_list<ircd::info::versions>::allocator
|
|
|
|
{};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
decltype(ircd::util::instance_list<ircd::info::versions>::list)
|
|
|
|
ircd::util::instance_list<ircd::info::versions>::list
|
|
|
|
{
|
|
|
|
allocator
|
|
|
|
};
|
|
|
|
|
2019-05-31 23:50:25 +02:00
|
|
|
/// Straightforward construction of versions members; string is copied
|
|
|
|
/// into member buffer with null termination.
|
2019-05-31 05:12:32 +02:00
|
|
|
ircd::info::versions::versions(const string_view &name,
|
|
|
|
const enum type &type,
|
2019-05-31 23:50:25 +02:00
|
|
|
const long &monotonic,
|
|
|
|
const std::array<long, 3> &semantic,
|
2019-05-31 05:12:32 +02:00
|
|
|
const string_view &string)
|
2019-06-02 23:21:40 +02:00
|
|
|
:versions
|
|
|
|
{
|
|
|
|
name, type, monotonic, semantic, [&string]
|
|
|
|
(auto &that, const mutable_buffer &buf)
|
|
|
|
{
|
|
|
|
strlcpy(buf, string);
|
|
|
|
}
|
|
|
|
}
|
2019-05-31 05:12:32 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-05-31 23:50:25 +02:00
|
|
|
/// Construction of versions members with closure for custom string generation.
|
|
|
|
/// The version string must be stored into buffer with null termination.
|
|
|
|
ircd::info::versions::versions(const string_view &name,
|
|
|
|
const enum type &type,
|
|
|
|
const long &monotonic,
|
|
|
|
const std::array<long, 3> &semantic,
|
|
|
|
const std::function<void (versions &, const mutable_buffer &)> &closure)
|
|
|
|
:name{name}
|
|
|
|
,type{type}
|
|
|
|
,monotonic{monotonic}
|
|
|
|
,semantic{semantic}
|
2019-06-02 23:25:36 +02:00
|
|
|
,string{'\0'}
|
2019-05-31 23:50:25 +02:00
|
|
|
{
|
|
|
|
closure(*this, this->string);
|
2019-06-02 23:21:40 +02:00
|
|
|
|
|
|
|
// User provided a string already; nothing else to do
|
|
|
|
if(strnlen(this->string, sizeof(this->string)) != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Generate a string from the semantic version number or if all zeroes
|
|
|
|
// from the monotonic version number instead.
|
2019-06-02 23:25:36 +02:00
|
|
|
if(!this->semantic[0] && !this->semantic[1] && !this->semantic[2])
|
2019-06-02 23:21:40 +02:00
|
|
|
::snprintf(this->string, sizeof(this->string), "%ld",
|
2019-06-02 23:25:36 +02:00
|
|
|
this->monotonic);
|
2019-06-02 23:21:40 +02:00
|
|
|
else
|
2019-06-02 23:25:36 +02:00
|
|
|
::snprintf(this->string, sizeof(this->string), "%ld.%ld.%ld",
|
|
|
|
this->semantic[0],
|
|
|
|
this->semantic[1],
|
|
|
|
this->semantic[2]);
|
2019-05-31 23:50:25 +02:00
|
|
|
}
|
|
|
|
|
2019-06-24 06:28:50 +02:00
|
|
|
// Required for instance_list template instantiation.
|
|
|
|
ircd::info::versions::~versions()
|
|
|
|
noexcept
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2018-12-19 21:23:38 +01:00
|
|
|
//
|
2020-03-16 19:36:49 +01:00
|
|
|
// Hardware / Platform
|
2018-12-19 21:23:38 +01:00
|
|
|
//
|
2018-02-19 23:03:05 +01:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
void
|
|
|
|
ircd::info::dump_cpu_info()
|
2018-02-19 23:03:05 +01:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
// This message flashes hardware standard information about this platform
|
|
|
|
#if defined(__i386__) or defined(__x86_64__)
|
|
|
|
log::info
|
|
|
|
{
|
|
|
|
log::star, "%s mmx:%b sse:%b sse2:%b sse3:%b ssse3:%b sse4.1:%b sse4.2:%b avx:%b avx2:%b",
|
|
|
|
hardware::x86::vendor,
|
|
|
|
hardware::x86::mmx,
|
|
|
|
hardware::x86::sse,
|
|
|
|
hardware::x86::sse2,
|
|
|
|
hardware::x86::sse3,
|
|
|
|
hardware::x86::ssse3,
|
|
|
|
hardware::x86::sse4_1,
|
|
|
|
hardware::x86::sse4_2,
|
|
|
|
hardware::x86::avx,
|
|
|
|
hardware::x86::avx2,
|
|
|
|
};
|
|
|
|
#endif
|
2018-02-19 23:03:05 +01:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
// This message flashes language standard information about this platform
|
|
|
|
#ifdef RB_DEBUG
|
|
|
|
log::logf
|
|
|
|
{
|
|
|
|
log::star, log::DEBUG,
|
|
|
|
"max_align=%zu hw_conc=%zu d_inter=%zu c_inter=%zu",
|
|
|
|
hardware::max_align,
|
|
|
|
hardware::hardware_concurrency,
|
|
|
|
hardware::destructive_interference,
|
|
|
|
hardware::constructive_interference,
|
|
|
|
};
|
|
|
|
#endif
|
2018-04-03 01:50:51 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
if(!ircd::debugmode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
log::debug
|
|
|
|
{
|
|
|
|
log::star,
|
|
|
|
"0..00 STD MANUFAC [%08x|%08x|%08x|%08x] "
|
|
|
|
"0..01 STD FEATURE [%08x|%08x|%08x|%08x]",
|
|
|
|
uint32_t(hardware::x86::manufact >> 0),
|
|
|
|
uint32_t(hardware::x86::manufact >> 32),
|
|
|
|
uint32_t(hardware::x86::manufact >> 64),
|
|
|
|
uint32_t(hardware::x86::manufact >> 96),
|
|
|
|
uint32_t(hardware::x86::features >> 0),
|
|
|
|
uint32_t(hardware::x86::features >> 32),
|
|
|
|
uint32_t(hardware::x86::features >> 64),
|
|
|
|
uint32_t(hardware::x86::features >> 96),
|
|
|
|
};
|
|
|
|
|
|
|
|
log::debug
|
|
|
|
{
|
|
|
|
log::star,
|
|
|
|
"8..00 EXT MANUFAC [%08x|%08x|%08x|%08x] "
|
|
|
|
"8..01 EXT FEATURE [%08x|%08x|%08x|%08x]",
|
|
|
|
uint32_t(hardware::x86::_manufact >> 0),
|
|
|
|
uint32_t(hardware::x86::_manufact >> 32),
|
|
|
|
uint32_t(hardware::x86::_manufact >> 64),
|
|
|
|
uint32_t(hardware::x86::_manufact >> 96),
|
|
|
|
uint32_t(hardware::x86::_features >> 0),
|
|
|
|
uint32_t(hardware::x86::_features >> 32),
|
|
|
|
uint32_t(hardware::x86::_features >> 64),
|
|
|
|
uint32_t(hardware::x86::_features >> 96),
|
|
|
|
};
|
|
|
|
|
|
|
|
log::debug
|
|
|
|
{
|
|
|
|
log::star,
|
|
|
|
"8..07 EXT APMI [%08x|%08x|%08x|%08x] "
|
|
|
|
"8..1C EXT LWPROF [%08x|%08x|%08x|%08x]",
|
|
|
|
uint32_t(hardware::x86::_apmi >> 0),
|
|
|
|
uint32_t(hardware::x86::_apmi >> 32),
|
|
|
|
uint32_t(hardware::x86::_apmi >> 64),
|
|
|
|
uint32_t(hardware::x86::_apmi >> 96),
|
|
|
|
uint32_t(hardware::x86::_lwp >> 0),
|
|
|
|
uint32_t(hardware::x86::_lwp >> 32),
|
|
|
|
uint32_t(hardware::x86::_lwp >> 64),
|
|
|
|
uint32_t(hardware::x86::_lwp >> 96),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
decltype(ircd::info::hardware::max_align)
|
|
|
|
ircd::info::hardware::max_align
|
2018-04-03 01:50:51 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
alignof(std::max_align_t)
|
2018-04-03 01:50:51 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::hardware_concurrency)
|
|
|
|
ircd::info::hardware::hardware_concurrency
|
2016-08-16 01:21:01 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
std::thread::hardware_concurrency()
|
2016-08-16 01:21:01 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::destructive_interference)
|
|
|
|
ircd::info::hardware::destructive_interference
|
2016-08-16 01:21:01 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
#ifdef __cpp_lib_hardware_interference_size
|
|
|
|
std::hardware_destructive_interference_size
|
|
|
|
#else
|
|
|
|
0
|
|
|
|
#endif
|
2016-08-16 01:21:01 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::constructive_interference)
|
|
|
|
ircd::info::hardware::constructive_interference
|
2016-08-16 01:21:01 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
#ifdef __cpp_lib_hardware_interference_size
|
|
|
|
std::hardware_constructive_interference_size
|
|
|
|
#else
|
|
|
|
0
|
|
|
|
#endif
|
2016-08-16 01:21:01 +02:00
|
|
|
};
|
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
//
|
2020-03-16 19:36:49 +01:00
|
|
|
// x86::x86
|
2018-12-19 21:23:38 +01:00
|
|
|
//
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::manufact)
|
|
|
|
ircd::info::hardware::x86::manufact
|
|
|
|
{
|
|
|
|
cpuid(0x00000000U, 0),
|
|
|
|
};
|
2018-11-29 01:53:59 +01:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::features)
|
|
|
|
ircd::info::hardware::x86::features
|
2018-01-21 11:09:13 +01:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
cpuid(0x00000001U, 0)
|
|
|
|
};
|
2018-01-21 11:09:13 +01:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::extended_features)
|
|
|
|
ircd::info::hardware::x86::extended_features
|
|
|
|
{
|
|
|
|
cpuid(0x00000007U, 0)
|
|
|
|
};
|
2019-06-01 01:06:55 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::_manufact)
|
|
|
|
ircd::info::hardware::x86::_manufact
|
2019-03-13 23:57:49 +01:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
cpuid(0x80000000U, 0),
|
2019-03-13 23:57:49 +01:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::_features)
|
|
|
|
ircd::info::hardware::x86::_features
|
2019-03-13 23:57:49 +01:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
cpuid(0x80000001U, 0)
|
2019-03-13 23:57:49 +01:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::_apmi)
|
|
|
|
ircd::info::hardware::x86::_apmi
|
2019-03-13 23:57:49 +01:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
cpuid(0x80000007U, 0)
|
2019-06-01 01:06:55 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::_lwp)
|
|
|
|
ircd::info::hardware::x86::_lwp
|
2019-06-02 07:03:53 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
cpuid(0x8000001CU, 0)
|
2019-06-02 07:03:53 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
static char
|
|
|
|
ircd_info_hardware_x86_vendor[16];
|
2019-06-02 23:25:36 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::vendor)
|
|
|
|
ircd::info::hardware::x86::vendor{[]
|
2019-06-02 23:25:36 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
char *const out{ircd_info_hardware_x86_vendor};
|
|
|
|
const auto in{reinterpret_cast<const uint8_t *>(&manufact)};
|
2019-06-02 07:03:53 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
out[0] = in[4]; out[1] = in[5]; out[2] = in[6]; out[3] = in[7];
|
|
|
|
out[4] = in[12]; out[5] = in[13]; out[6] = in[14]; out[7] = in[15];
|
|
|
|
out[8] = in[8]; out[9] = in[9]; out[10] = in[10]; out[11] = in[11];
|
2019-06-01 01:06:55 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
return string_view
|
2019-03-13 23:57:49 +01:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
ircd_info_hardware_x86_vendor
|
|
|
|
};
|
|
|
|
}()};
|
2019-06-01 01:06:55 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::mmx)
|
|
|
|
ircd::info::hardware::x86::mmx
|
2019-06-01 01:06:55 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
bool(features & (uint128_t(1) << (96 + 23)))
|
2019-06-02 23:25:36 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::sse)
|
|
|
|
ircd::info::hardware::x86::sse
|
2019-06-02 23:25:36 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
bool(features & (uint128_t(1) << (96 + 26)))
|
2019-03-13 23:57:49 +01:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::sse2)
|
|
|
|
ircd::info::hardware::x86::sse2
|
2019-06-02 23:25:36 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
bool(features & (uint128_t(1) << (96 + 0)))
|
2019-06-02 23:25:36 +02:00
|
|
|
};
|
2019-06-02 06:59:31 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::sse3)
|
|
|
|
ircd::info::hardware::x86::sse3
|
2019-08-13 12:11:42 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
bool(features & (uint128_t(1) << (64 + 0)))
|
2019-08-13 12:11:42 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::ssse3)
|
|
|
|
ircd::info::hardware::x86::ssse3
|
2018-04-03 02:03:05 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
bool(features & (uint128_t(1) << (64 + 9)))
|
2018-04-03 02:03:05 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::sse4_1)
|
|
|
|
ircd::info::hardware::x86::sse4_1
|
2018-04-03 02:03:05 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
bool(features & (uint128_t(1) << (64 + 19)))
|
2018-04-03 02:03:05 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::sse4_2)
|
|
|
|
ircd::info::hardware::x86::sse4_2
|
2018-04-03 02:03:05 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
bool(features & (uint128_t(1) << (64 + 20)))
|
2018-04-03 02:03:05 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::avx)
|
|
|
|
ircd::info::hardware::x86::avx
|
2018-04-20 21:37:17 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
bool(features & (uint128_t(1) << (64 + 28)))
|
2018-04-20 21:37:17 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::hardware::x86::avx2)
|
|
|
|
ircd::info::hardware::x86::avx2
|
2018-11-15 02:36:15 +01:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
bool(features & (uint128_t(1) << (32 + 5)))
|
2018-11-15 02:36:15 +01:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
#ifdef __x86_64__
|
|
|
|
ircd::uint128_t
|
|
|
|
ircd::info::hardware::x86::cpuid(const uint &leaf,
|
|
|
|
const uint &subleaf)
|
2019-04-06 01:50:08 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
uint32_t reg[4];
|
|
|
|
asm volatile
|
|
|
|
(
|
|
|
|
"cpuid" "\n\t"
|
|
|
|
: "=a" (reg[0]),
|
|
|
|
"=b" (reg[1]),
|
|
|
|
"=c" (reg[2]),
|
|
|
|
"=d" (reg[3])
|
|
|
|
: "0" (leaf),
|
|
|
|
"2" (subleaf)
|
|
|
|
);
|
|
|
|
|
|
|
|
return uint128_t
|
|
|
|
{
|
|
|
|
(uint128_t(reg[3]) << 96) | // edx
|
|
|
|
(uint128_t(reg[2]) << 64) | // ecx
|
|
|
|
(uint128_t(reg[1]) << 32) | // ebx
|
|
|
|
(uint128_t(reg[0]) << 0) // eax
|
|
|
|
};
|
|
|
|
}
|
2019-04-06 01:50:08 +02:00
|
|
|
#else
|
2020-03-16 19:36:49 +01:00
|
|
|
ircd::uint128_t
|
|
|
|
ircd::info::hardware::x86::cpuid(const uint &leaf,
|
|
|
|
const uint &subleaf)
|
2019-04-06 01:50:08 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2019-04-06 01:50:08 +02:00
|
|
|
#endif
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// System information
|
|
|
|
//
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::info::dump_sys_info()
|
2018-01-21 11:09:13 +01:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
// This message flashes posix information about the system and platform IRCd
|
|
|
|
// is running on when ::uname() is available
|
|
|
|
#ifdef HAVE_SYS_UTSNAME_H
|
|
|
|
log::info
|
|
|
|
{
|
|
|
|
log::star, "%s %s %s %s %s",
|
|
|
|
utsname.sysname,
|
|
|
|
utsname.nodename,
|
|
|
|
utsname.release,
|
|
|
|
utsname.version,
|
|
|
|
utsname.machine
|
|
|
|
};
|
2018-12-19 21:23:38 +01:00
|
|
|
#endif
|
2018-01-21 11:09:13 +01:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
// Dump detected filesystem related to log.
|
|
|
|
fs::support::dump_info();
|
|
|
|
|
|
|
|
// Additional detected system parameters
|
|
|
|
#ifdef RB_DEBUG
|
2020-03-16 19:59:08 +01:00
|
|
|
char buf[2][48];
|
2020-03-16 19:36:49 +01:00
|
|
|
log::logf
|
|
|
|
{
|
|
|
|
log::star, log::DEBUG,
|
2020-03-16 19:59:08 +01:00
|
|
|
"page_size=%zu iov_max=%zu aio_max=%zu aio_reqprio_max=%zu ram=%s swap=%s",
|
2020-03-16 19:36:49 +01:00
|
|
|
page_size,
|
|
|
|
iov_max,
|
|
|
|
aio_max,
|
|
|
|
aio_reqprio_max,
|
2020-03-16 19:59:08 +01:00
|
|
|
pretty(buf[0], iec(total_ram)),
|
|
|
|
pretty(buf[1], iec(total_swap)),
|
2020-03-16 19:36:49 +01:00
|
|
|
};
|
2018-12-19 21:23:38 +01:00
|
|
|
#endif
|
2020-03-16 19:36:49 +01:00
|
|
|
}
|
2018-12-19 21:23:38 +01:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
#ifdef HAVE_SYS_UTSNAME_H
|
|
|
|
decltype(ircd::info::utsname)
|
|
|
|
ircd::info::utsname{[]
|
2018-12-19 21:23:38 +01:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
struct ::utsname utsname;
|
|
|
|
syscall(::uname, &utsname);
|
|
|
|
return utsname;
|
|
|
|
}()};
|
|
|
|
#endif
|
2018-01-21 11:09:13 +01:00
|
|
|
|
2019-04-01 01:06:17 +02:00
|
|
|
//
|
2020-03-16 19:36:49 +01:00
|
|
|
// kernel
|
2019-04-01 01:06:17 +02:00
|
|
|
//
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::kernel_name)
|
|
|
|
ircd::info::kernel_name
|
2019-08-07 00:21:37 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
#ifdef HAVE_SYS_UTSNAME_H
|
|
|
|
utsname.sysname
|
|
|
|
#endif
|
2019-08-07 00:21:37 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::kernel_release)
|
|
|
|
ircd::info::kernel_release
|
2019-06-05 23:22:18 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
#ifdef HAVE_SYS_UTSNAME_H
|
|
|
|
utsname.release
|
2019-06-05 23:22:18 +02:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::kernel_version)
|
|
|
|
ircd::info::kernel_version
|
2019-06-05 23:22:18 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
"kernel", versions::ABI, 0,
|
|
|
|
{
|
|
|
|
[] // major
|
|
|
|
{
|
|
|
|
const auto str(split(kernel_release, '.').first);
|
|
|
|
return lex_castable<int>(str)?
|
|
|
|
lex_cast<int>(str):
|
|
|
|
0;
|
|
|
|
}(),
|
|
|
|
|
|
|
|
[] // minor
|
|
|
|
{
|
|
|
|
auto str(split(kernel_release, '.').second);
|
|
|
|
str = split(str, '.').first;
|
|
|
|
return lex_castable<int>(str)?
|
|
|
|
lex_cast<int>(str):
|
|
|
|
0;
|
|
|
|
}(),
|
|
|
|
|
|
|
|
0 // patch
|
|
|
|
},
|
|
|
|
|
|
|
|
[](auto &that, const auto &buf)
|
|
|
|
{
|
|
|
|
::snprintf(data(buf), size(buf), "%s %s",
|
|
|
|
utsname.sysname,
|
|
|
|
utsname.release);
|
|
|
|
}
|
2019-06-05 23:22:18 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:59:08 +01:00
|
|
|
//
|
|
|
|
// System configuration
|
|
|
|
//
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
#ifdef _SC_CLK_TCK
|
|
|
|
decltype(ircd::info::clk_tck)
|
|
|
|
ircd::info::clk_tck
|
2019-08-07 00:21:37 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
size_t(syscall(::sysconf, _SC_CLK_TCK))
|
2019-08-07 00:21:37 +02:00
|
|
|
};
|
2020-03-16 19:36:49 +01:00
|
|
|
#else
|
|
|
|
decltype(ircd::info::clk_tck)
|
|
|
|
ircd::info::clk_tck
|
2019-08-07 00:21:37 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
1 // prevent #DE
|
2019-08-07 00:21:37 +02:00
|
|
|
};
|
2020-03-16 19:36:49 +01:00
|
|
|
#endif
|
2019-08-07 00:21:37 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::aio_reqprio_max)
|
|
|
|
ircd::info::aio_reqprio_max
|
2019-08-07 00:21:37 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
#ifdef _SC_AIO_PRIO_DELTA_MAX
|
|
|
|
size_t(syscall(::sysconf, _SC_AIO_PRIO_DELTA_MAX))
|
|
|
|
#endif
|
2019-08-07 00:21:37 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::aio_max)
|
|
|
|
ircd::info::aio_max
|
2019-08-07 00:21:37 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
#ifdef _SC_AIO_MAX
|
|
|
|
0 //size_t(syscall(::sysconf, _SC_AIO_MAX))
|
|
|
|
#endif
|
2019-08-07 00:21:37 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::iov_max)
|
|
|
|
ircd::info::iov_max
|
2019-08-07 00:21:37 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
#ifdef _SC_IOV_MAX
|
|
|
|
size_t(syscall(::sysconf, _SC_IOV_MAX))
|
|
|
|
#endif
|
2019-08-07 00:21:37 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::page_size)
|
|
|
|
ircd::info::page_size
|
2019-08-07 00:21:37 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
#ifdef _SC_PAGESIZE
|
|
|
|
size_t(syscall(::sysconf, _SC_PAGESIZE))
|
|
|
|
#endif
|
2019-08-07 00:21:37 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:59:08 +01:00
|
|
|
//
|
|
|
|
// System information
|
|
|
|
//
|
|
|
|
|
|
|
|
namespace ircd::info
|
|
|
|
{
|
|
|
|
#ifdef HAVE_SYS_SYSINFO_H
|
|
|
|
extern struct ::sysinfo sysinfo;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_SYSINFO_H
|
|
|
|
decltype(ircd::info::sysinfo)
|
|
|
|
ircd::info::sysinfo{[]
|
|
|
|
{
|
|
|
|
struct ::sysinfo ret;
|
|
|
|
syscall(::sysinfo, &ret);
|
|
|
|
return ret;
|
|
|
|
}()};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
decltype(ircd::info::total_ram)
|
|
|
|
ircd::info::total_ram
|
|
|
|
{
|
|
|
|
#ifdef HAVE_SYS_SYSINFO_H
|
|
|
|
sysinfo.totalram
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
decltype(ircd::info::total_swap)
|
|
|
|
ircd::info::total_swap
|
|
|
|
{
|
|
|
|
#ifdef HAVE_SYS_SYSINFO_H
|
|
|
|
sysinfo.totalswap
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Userspace / Library
|
|
|
|
//
|
|
|
|
|
|
|
|
void
|
|
|
|
ircd::info::dump_lib_info()
|
2019-08-07 00:21:37 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
// This message flashes information about our API dependencies from compile time.
|
|
|
|
log::info
|
|
|
|
{
|
|
|
|
log::star, "%s SD-6 %s. glibcxx %s. glibc %s. boost %s. RocksDB %s. sodium %s. %s. magic %ld.",
|
|
|
|
string_view{RB_CXX},
|
|
|
|
string_view{sd6_version},
|
|
|
|
string_view{glibcxx_version_api},
|
|
|
|
string_view{glibc_version_api},
|
|
|
|
string_view{boost_version_api},
|
|
|
|
string_view{db::version_api},
|
|
|
|
string_view{nacl::version_api},
|
|
|
|
string_view{openssl::version_api},
|
|
|
|
long(magic::version_api),
|
|
|
|
};
|
|
|
|
|
|
|
|
// This message flashes information about our ABI dependencies on this system.
|
|
|
|
log::info
|
|
|
|
{
|
|
|
|
log::star, "Linked: glibc %s. boost %s. RocksDB %s. sodium %s. %s. magic %ld.",
|
|
|
|
string_view{glibc_version_abi},
|
|
|
|
string_view{boost_version_abi},
|
|
|
|
string_view{db::version_abi},
|
|
|
|
string_view{nacl::version_abi},
|
|
|
|
string_view{openssl::version_abi},
|
|
|
|
long(magic::version_abi),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// gnuc
|
|
|
|
//
|
|
|
|
|
|
|
|
decltype(ircd::info::gnuc_version)
|
|
|
|
ircd::info::gnuc_version
|
|
|
|
{
|
|
|
|
"gnuc", versions::API, 0,
|
|
|
|
{
|
|
|
|
#if defined(__GNUC__)
|
|
|
|
__GNUC__,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__GNUC_MINOR__)
|
|
|
|
__GNUC_MINOR__,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__GNUC_PATCHLEVEL__)
|
|
|
|
__GNUC_PATCHLEVEL__,
|
|
|
|
#endif
|
|
|
|
},
|
|
|
|
|
|
|
|
#if defined(__VERSION__)
|
|
|
|
__VERSION__
|
|
|
|
#endif
|
2019-08-07 00:21:37 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
//
|
|
|
|
// clang
|
|
|
|
//
|
|
|
|
|
|
|
|
decltype(ircd::info::clang_version)
|
|
|
|
ircd::info::clang_version
|
2019-08-07 00:21:37 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
"clang", versions::API, 0,
|
|
|
|
{
|
|
|
|
#if defined(__clang_major__)
|
|
|
|
__clang_major__,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__clang_minor__)
|
|
|
|
__clang_minor__,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__clang_patchlevel__)
|
|
|
|
__clang_patchlevel__,
|
|
|
|
#endif
|
|
|
|
},
|
|
|
|
|
|
|
|
#if defined(__clang_version__)
|
|
|
|
__clang_version__
|
|
|
|
#endif
|
2019-08-07 00:21:37 +02:00
|
|
|
};
|
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
//
|
|
|
|
// glibc
|
|
|
|
//
|
|
|
|
|
|
|
|
decltype(ircd::info::glibc_version_api)
|
|
|
|
ircd::info::glibc_version_api
|
2019-04-01 01:06:17 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
"glibc", versions::API, 0,
|
|
|
|
{
|
|
|
|
#if defined(__GNU_LIBRARY__)
|
|
|
|
__GNU_LIBRARY__,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__GLIBC__)
|
|
|
|
__GLIBC__,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__GLIBC_MINOR__)
|
|
|
|
__GLIBC_MINOR__,
|
|
|
|
#endif
|
|
|
|
},
|
2019-08-07 00:21:37 +02:00
|
|
|
};
|
2019-04-01 01:06:17 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::glibc_version_abi)
|
|
|
|
ircd::info::glibc_version_abi
|
2019-08-07 00:21:37 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
"glibc", versions::ABI, 0, {0},
|
2019-04-01 01:06:17 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
#if defined(HAVE_GNU_LIBC_VERSION_H)
|
|
|
|
::gnu_get_libc_version()
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// glibcxx
|
|
|
|
//
|
|
|
|
|
|
|
|
decltype(ircd::info::glibcxx_version_api)
|
|
|
|
ircd::info::glibcxx_version_api
|
2019-04-01 01:06:17 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
"glibcxx", versions::API,
|
|
|
|
|
|
|
|
#if defined(__GLIBCXX__)
|
|
|
|
__GLIBCXX__
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// sd6
|
|
|
|
//
|
|
|
|
|
|
|
|
decltype(ircd::info::sd6_version)
|
|
|
|
ircd::info::sd6_version
|
|
|
|
{
|
|
|
|
"SD-6", versions::API, __cplusplus
|
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Primary / Executable
|
|
|
|
//
|
2019-04-01 01:06:17 +02:00
|
|
|
|
2019-06-05 23:22:18 +02:00
|
|
|
void
|
2020-03-16 19:36:49 +01:00
|
|
|
ircd::info::dump_exe_info()
|
2018-01-21 11:09:13 +01:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
// This message flashes information about IRCd itself for this execution.
|
2019-08-07 00:21:37 +02:00
|
|
|
log::info
|
2019-06-05 23:22:18 +02:00
|
|
|
{
|
2020-03-16 19:36:49 +01:00
|
|
|
log::star, "%s %s configured: %s; compiled: %s; executed: %s; %s",
|
|
|
|
BRANDING_NAME,
|
|
|
|
BRANDING_VERSION,
|
|
|
|
configured,
|
|
|
|
compiled,
|
|
|
|
startup,
|
|
|
|
RB_DEBUG_LEVEL? "(DEBUG MODE)" : ""
|
2019-06-05 23:22:18 +02:00
|
|
|
};
|
2020-03-16 19:36:49 +01:00
|
|
|
}
|
2018-01-21 11:09:13 +01:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::server_agent)
|
|
|
|
ircd::info::server_agent
|
|
|
|
{
|
|
|
|
BRANDING_NAME " (IRCd " BRANDING_VERSION ")"
|
|
|
|
};
|
2019-08-13 12:11:42 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::user_agent)
|
|
|
|
ircd::info::user_agent
|
|
|
|
{
|
|
|
|
BRANDING_NAME " (IRCd " BRANDING_VERSION ")"
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::version)
|
|
|
|
ircd::info::version
|
|
|
|
{
|
|
|
|
RB_VERSION
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
decltype(ircd::info::name)
|
|
|
|
ircd::info::name
|
|
|
|
{
|
|
|
|
PACKAGE_NAME
|
|
|
|
};
|
2019-06-05 23:22:18 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
extern "C" const char *const
|
|
|
|
ircd_version
|
|
|
|
{
|
|
|
|
RB_VERSION
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2020-03-16 19:36:49 +01:00
|
|
|
extern "C" const char *const
|
|
|
|
ircd_name
|
|
|
|
{
|
|
|
|
PACKAGE_NAME
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::startup)
|
|
|
|
ircd::info::startup
|
|
|
|
{
|
2019-04-19 03:56:08 +02:00
|
|
|
rstrip(ctime(&startup_time), '\n')
|
2018-12-19 21:23:38 +01:00
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::compiled)
|
|
|
|
ircd::info::compiled
|
|
|
|
{
|
|
|
|
__TIMESTAMP__
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::configured)
|
|
|
|
ircd::info::configured
|
|
|
|
{
|
2019-04-19 03:56:08 +02:00
|
|
|
rstrip(ctime(&configured_time), '\n')
|
2018-12-19 21:23:38 +01:00
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::startup_time)
|
|
|
|
ircd::info::startup_time
|
|
|
|
{
|
|
|
|
std::time(nullptr)
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::configured_time)
|
|
|
|
ircd::info::configured_time
|
|
|
|
{
|
|
|
|
RB_TIME_CONFIGURED
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::commit)
|
|
|
|
ircd::info::commit
|
|
|
|
{
|
|
|
|
RB_VERSION_COMMIT
|
|
|
|
};
|
2016-11-29 16:23:38 +01:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::branch)
|
|
|
|
ircd::info::branch
|
|
|
|
{
|
|
|
|
RB_VERSION_BRANCH
|
|
|
|
};
|
2016-08-16 01:21:01 +02:00
|
|
|
|
2018-12-19 21:23:38 +01:00
|
|
|
decltype(ircd::info::tag)
|
|
|
|
ircd::info::tag
|
|
|
|
{
|
|
|
|
RB_VERSION_TAG
|
|
|
|
};
|