mirror of
https://github.com/google/benchmark.git
synced 2025-01-16 06:40:13 +08:00
parent
c45f01866b
commit
95a1435b81
@ -73,22 +73,14 @@ BENCHMARK_NORETURN void PrintErrorAndDie(Args&&... args) {
|
||||
|
||||
#ifdef BENCHMARK_HAS_SYSCTL
|
||||
|
||||
#ifdef __GNUC__
|
||||
// Suppress the warning generated by the C11 flexible array member below.
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
|
||||
/// ValueUnion - A type used to correctly alias the byte-for-byte output of
|
||||
/// `sysctl` with the result type it's to be interpreted as.
|
||||
struct ValueUnion {
|
||||
union DataT {
|
||||
uint32_t uint32_value;
|
||||
uint64_t uint64_value;
|
||||
// FIXME (Maybe?): This is a C11 flexible array member, and not technically
|
||||
// C++. However, all compilers support it and it allows for correct aliasing
|
||||
// of union members from bytes.
|
||||
char bytes[];
|
||||
// For correct aliasing of union members from bytes.
|
||||
char bytes[8];
|
||||
};
|
||||
using DataPtr = std::unique_ptr<DataT, decltype(&std::free)>;
|
||||
|
||||
@ -137,10 +129,6 @@ struct ValueUnion {
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
ValueUnion GetSysctlImp(std::string const& Name) {
|
||||
size_t CurBuffSize = 0;
|
||||
if (sysctlbyname(Name.c_str(), nullptr, &CurBuffSize, nullptr, 0) == -1)
|
||||
@ -177,7 +165,7 @@ bool GetSysctl(std::string const& Name, std::array<Tp, N>* Out) {
|
||||
if (!Buff) return false;
|
||||
*Out = Buff.GetAsArray<Tp, N>();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class ArgT>
|
||||
|
Loading…
Reference in New Issue
Block a user