2018-02-04 03:22:01 +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
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
2016-08-16 01:21:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_INFO_H
|
|
|
|
|
2018-02-19 22:32:34 +01:00
|
|
|
// legacy
|
2018-02-19 23:03:05 +01:00
|
|
|
extern "C" const char *const ircd_name;
|
2018-02-19 22:32:34 +01:00
|
|
|
extern "C" const char *const ircd_version;
|
|
|
|
|
2017-09-12 18:37:44 +02:00
|
|
|
/// Information & metadata about the library.
|
2017-08-28 23:51:22 +02:00
|
|
|
namespace ircd::info
|
|
|
|
{
|
|
|
|
struct line;
|
2019-05-31 05:12:32 +02:00
|
|
|
struct versions;
|
2017-08-28 23:51:22 +02:00
|
|
|
|
2019-09-07 23:02:51 +02:00
|
|
|
// Util
|
|
|
|
void dump();
|
|
|
|
|
|
|
|
// Primary information
|
|
|
|
extern const string_view name;
|
|
|
|
extern const string_view version;
|
|
|
|
extern const string_view user_agent;
|
|
|
|
extern const string_view server_agent;
|
|
|
|
|
|
|
|
// Extended information
|
|
|
|
extern const string_view credits[];
|
|
|
|
|
2018-02-19 22:32:34 +01:00
|
|
|
// Build information
|
2018-04-03 01:50:51 +02:00
|
|
|
extern const string_view tag;
|
|
|
|
extern const string_view branch;
|
|
|
|
extern const string_view commit;
|
2017-08-28 23:51:22 +02:00
|
|
|
extern const time_t configured_time;
|
2018-02-19 22:32:34 +01:00
|
|
|
extern const string_view configured;
|
2018-09-06 08:32:52 +02:00
|
|
|
extern const string_view compiled;
|
2020-09-29 09:12:12 +02:00
|
|
|
extern const string_view compiler;
|
2020-04-27 06:05:49 +02:00
|
|
|
|
|
|
|
// Toolchain and library information
|
|
|
|
extern const versions gnuc_version;
|
|
|
|
extern const versions clang_version;
|
|
|
|
extern const versions glibc_version_api;
|
|
|
|
extern const versions glibc_version_abi;
|
|
|
|
extern const versions glibcxx_version_api;
|
|
|
|
extern const versions sd6_version;
|
2018-01-17 12:55:36 +01:00
|
|
|
|
2020-03-16 19:59:08 +01:00
|
|
|
// System configuration / information
|
2020-08-01 04:17:06 +02:00
|
|
|
extern const size_t clk_tck;
|
2020-06-11 15:36:58 +02:00
|
|
|
extern const string_view clock_source;
|
|
|
|
extern const size_t aio_reqprio_max;
|
|
|
|
extern const size_t aio_max;
|
|
|
|
extern const size_t iov_max;
|
|
|
|
extern const size_t page_size;
|
2020-03-16 19:59:08 +01:00
|
|
|
extern const size_t total_ram;
|
|
|
|
extern const size_t total_swap;
|
2019-09-14 21:13:51 +02:00
|
|
|
|
2019-06-01 01:06:55 +02:00
|
|
|
// Host & third-party information
|
2018-01-21 11:09:13 +01:00
|
|
|
#ifdef HAVE_SYS_UTSNAME_H
|
|
|
|
extern const ::utsname utsname;
|
|
|
|
#endif
|
|
|
|
|
2019-06-02 07:03:53 +02:00
|
|
|
// Kernel information
|
2019-06-01 01:06:55 +02:00
|
|
|
extern const string_view kernel_name;
|
|
|
|
extern const string_view kernel_release;
|
|
|
|
extern const versions kernel_version;
|
2020-04-27 06:05:49 +02:00
|
|
|
extern const intptr_t vsyscall_p;
|
|
|
|
extern const intptr_t vdso_p;
|
2019-06-01 01:06:55 +02:00
|
|
|
|
2020-04-27 06:05:49 +02:00
|
|
|
// Execution information
|
|
|
|
extern const time_t startup_time;
|
|
|
|
extern const string_view startup;
|
|
|
|
extern const uint64_t random;
|
|
|
|
extern const uint uid, euid;
|
|
|
|
extern const uint gid, egid;
|
|
|
|
extern const bool secure;
|
2017-08-28 23:51:22 +02:00
|
|
|
}
|
2019-05-31 05:12:32 +02:00
|
|
|
|
2019-08-07 00:21:37 +02:00
|
|
|
namespace ircd::info::hardware
|
|
|
|
{
|
2020-09-29 09:12:12 +02:00
|
|
|
extern const string_view arch;
|
|
|
|
extern const string_view endian;
|
2019-08-07 00:21:37 +02:00
|
|
|
extern const size_t max_align;
|
|
|
|
extern const size_t hardware_concurrency;
|
|
|
|
extern const size_t destructive_interference;
|
|
|
|
extern const size_t constructive_interference;
|
2020-04-27 06:05:49 +02:00
|
|
|
extern const size_t inst_blksz, data_blksz, uni_blksz;
|
|
|
|
extern const size_t l1i, l1i_line, l1i_tag, l1i_assoc;
|
|
|
|
extern const size_t l1i_tlb, l1i_tlb_assoc;
|
|
|
|
extern const size_t l1d, l1d_line, l1d_tag, l1d_assoc;
|
|
|
|
extern const size_t l1d_tlb, l1d_tlb_assoc;
|
|
|
|
extern const size_t l2, l2_line, l2_tag, l2_assoc;
|
|
|
|
extern const size_t l2_itlb, l2_itlb_assoc;
|
|
|
|
extern const size_t l2_dtlb, l2_dtlb_assoc;
|
|
|
|
extern const size_t l3, l3_line, l3_tag, l3_assoc;
|
|
|
|
extern const size_t page_size;
|
|
|
|
extern const ulonglong cap[2];
|
2020-07-11 08:43:52 +02:00
|
|
|
extern const bool virtualized;
|
2019-08-07 00:21:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace ircd::info::hardware::x86
|
|
|
|
{
|
2020-04-27 06:05:49 +02:00
|
|
|
uint8_t llc_assoc(const uint8_t) noexcept;
|
|
|
|
uint128_t cpuid(const uint &leaf, const uint &subleaf) noexcept;
|
2019-08-07 00:21:37 +02:00
|
|
|
|
|
|
|
extern const uint128_t manufact;
|
|
|
|
extern const uint128_t features;
|
|
|
|
extern const uint128_t extended_features;
|
|
|
|
extern const uint128_t _manufact;
|
|
|
|
extern const uint128_t _features;
|
2020-04-27 06:05:49 +02:00
|
|
|
extern const uint128_t _l1cache;
|
|
|
|
extern const uint128_t _llcache;
|
2019-08-07 00:21:37 +02:00
|
|
|
extern const uint128_t _apmi;
|
|
|
|
extern const uint128_t _lwp;
|
|
|
|
|
|
|
|
extern const string_view vendor;
|
2020-07-12 20:17:41 +02:00
|
|
|
extern const bool sse, sse2, sse3, ssse3, sse4a, sse4_1, sse4_2;
|
|
|
|
extern const bool avx, avx2, avx512f;
|
2020-06-11 15:36:58 +02:00
|
|
|
extern const bool tsc, tsc_constant;
|
2019-08-07 00:21:37 +02:00
|
|
|
};
|
|
|
|
|
2020-10-02 12:16:24 +02:00
|
|
|
namespace ircd::info::hardware::arm
|
|
|
|
{
|
|
|
|
extern const uint64_t midr;
|
|
|
|
extern const uint64_t revidr;
|
|
|
|
extern const uint64_t isar[1];
|
|
|
|
extern const uint64_t mmfr[1];
|
|
|
|
extern const uint64_t pfr[1];
|
|
|
|
extern const uint64_t ctr;
|
|
|
|
|
|
|
|
extern const string_view vendor;
|
|
|
|
};
|
|
|
|
|
2019-05-31 05:12:32 +02:00
|
|
|
/// Instances of `versions` create a dynamic version registry identifying
|
|
|
|
/// third-party dependencies throughout the project and its loaded modules.
|
|
|
|
///
|
|
|
|
/// Create a static instance of this class in a definition file or module
|
|
|
|
/// which has access to the version information of the dependency. Often there
|
|
|
|
/// can be two version identifiers for a dependency, one for headers and the
|
|
|
|
/// other for dynamically loaded shared object. In that case, create two
|
|
|
|
/// instances of this class with the same name.
|
|
|
|
///
|
|
|
|
struct ircd::info::versions
|
|
|
|
:instance_list<versions>
|
|
|
|
{
|
|
|
|
/// Our own name for the dependency.
|
|
|
|
string_view name;
|
|
|
|
|
2019-06-01 00:27:48 +02:00
|
|
|
/// Set the type to either API or ABI to indicate where this version
|
|
|
|
/// information has been sourced. Defaults to API.
|
|
|
|
enum type {API, ABI} type {API};
|
2019-05-31 05:12:32 +02:00
|
|
|
|
2019-05-31 23:50:25 +02:00
|
|
|
/// If the version number is a single (likely monotonic) integer.
|
|
|
|
long monotonic {0};
|
|
|
|
|
|
|
|
/// Alternative semantic version number.
|
|
|
|
std::array<long, 3> semantic {0};
|
2019-05-31 05:12:32 +02:00
|
|
|
|
|
|
|
/// Version string buffer. Copy any provided version string here.
|
|
|
|
char string[128] {0};
|
|
|
|
|
2019-06-01 00:13:50 +02:00
|
|
|
/// Convenience access to read the semantic version numbers.
|
|
|
|
auto &operator[](const int &idx) const;
|
|
|
|
|
|
|
|
/// Convenience access to read the monotonic integer; note that if zero
|
|
|
|
/// the semantic major number is read instead.
|
|
|
|
explicit operator const long &() const;
|
|
|
|
|
|
|
|
/// Convenience access to read the string
|
|
|
|
explicit operator string_view() const;
|
|
|
|
|
2019-05-31 23:50:25 +02:00
|
|
|
versions(const string_view &name,
|
2019-06-01 00:27:48 +02:00
|
|
|
const enum type &type = type::API,
|
2019-05-31 23:50:25 +02:00
|
|
|
const long &monotonic = 0,
|
|
|
|
const std::array<long, 3> &semantic = {0L},
|
|
|
|
const string_view &string = {});
|
|
|
|
|
2019-05-31 05:12:32 +02:00
|
|
|
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,
|
|
|
|
const std::function<void (versions &, const mutable_buffer &)> &generator);
|
2019-05-31 05:12:32 +02:00
|
|
|
|
|
|
|
versions() = default;
|
|
|
|
versions(versions &&) = delete;
|
|
|
|
versions(const versions &) = delete;
|
2019-06-24 06:28:50 +02:00
|
|
|
~versions() noexcept;
|
2019-05-31 05:12:32 +02:00
|
|
|
};
|
2019-06-01 00:13:50 +02:00
|
|
|
|
|
|
|
inline ircd::info::versions::operator
|
|
|
|
const long &()
|
|
|
|
const
|
|
|
|
{
|
|
|
|
return monotonic?: semantic[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ircd::info::versions::operator
|
|
|
|
ircd::string_view()
|
|
|
|
const
|
|
|
|
{
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline auto &
|
|
|
|
ircd::info::versions::operator[](const int &idx)
|
|
|
|
const
|
|
|
|
{
|
|
|
|
return semantic.at(idx);
|
|
|
|
}
|