Lines Matching refs:std

83 void PrintImp(std::ostream& out) { out << std::endl; }
86 void PrintImp(std::ostream& out, First&& f, Rest&&... rest) {
87 out << std::forward<First>(f);
88 PrintImp(out, std::forward<Rest>(rest)...);
93 PrintImp(std::cerr, std::forward<Args>(args)...);
94 std::exit(EXIT_FAILURE);
108 using DataPtr = std::unique_ptr<DataT, decltype(&std::free)>;
111 std::size_t size;
115 ValueUnion() : size(0), buff(nullptr, &std::free) {}
117 explicit ValueUnion(std::size_t buff_size)
119 buff(::new (std::malloc(size)) DataT(), &std::free) {}
127 std::string GetAsString() const { return std::string(data()); }
138 std::array<T, N> GetAsArray() {
141 std::array<T, N> arr;
142 std::memcpy(arr.data(), data(), arr_size);
147 ValueUnion GetSysctlImp(std::string const& name) {
168 std::size_t cur_buff_size = 0;
180 bool GetSysctl(std::string const& name, std::string* out) {
189 class = typename std::enable_if<std::is_integral<Tp>::value>::type>
190 bool GetSysctl(std::string const& name, Tp* out) {
199 bool GetSysctl(std::string const& name, std::array<Tp, N>* out) {
208 bool ReadFromFile(std::string const& fname, ArgT* arg) {
210 std::ifstream f(fname.c_str());
225 std::string res;
227 std::string governor_file =
238 int CountSetBitsInCPUMap(std::string val) {
239 auto CountBits = [](std::string part) {
240 using CPUMask = std::bitset<sizeof(std::uintptr_t) * CHAR_BIT>;
245 std::size_t pos;
247 while ((pos = val.find(',')) != std::string::npos) {
258 std::vector<CPUInfo::CacheInfo> GetCacheSizesFromKVFS() {
259 std::vector<CPUInfo::CacheInfo> res;
260 std::string dir = "/sys/devices/system/cpu/cpu0/cache/";
264 std::string fpath = StrCat(dir, "index", idx++, "/");
265 std::ifstream f(StrCat(fpath, "size").c_str());
267 std::string suffix;
285 std::string map_str;
296 std::vector<CPUInfo::CacheInfo> GetCacheSizesMacOSX() {
297 std::vector<CPUInfo::CacheInfo> res;
298 std::array<int, 4> cache_counts{{0, 0, 0, 0}};
302 std::string name;
303 std::string type;
318 res.push_back(std::move(info));
323 std::vector<CPUInfo::CacheInfo> GetCacheSizesWindows() {
324 std::vector<CPUInfo::CacheInfo> res;
329 using UPtr = std::unique_ptr<PInfo, decltype(&std::free)>;
331 UPtr buff(static_cast<PInfo*>(std::malloc(buffer_size)), &std::free);
341 using BitSet = std::bitset<sizeof(ULONG_PTR) * CHAR_BIT>;
370 std::vector<CPUInfo::CacheInfo> GetCacheSizesQNX() {
371 std::vector<CPUInfo::CacheInfo> res;
400 res.push_back(std::move(info));
407 std::vector<CPUInfo::CacheInfo> GetCacheSizes() {
415 return std::vector<CPUInfo::CacheInfo>();
421 std::string GetSystemName() {
423 std::string str;
427 if (!GetComputerName(hostname, &DWCOUNT)) return std::string("");
429 str = std::string(hostname, DWCOUNT);
440 std::string str = "Hexagon DSP";
444 str += std::to_string(arch_version_struct.arch_version);
466 if (retVal != 0) return std::string("");
467 return std::string(hostname);
476 std::exit(EXIT_FAILURE);
481 std::memset(&sysinfo, 0, sizeof(SYSTEM_INFO));
505 std::ifstream f("/proc/cpuinfo");
507 std::cerr << "failed to open /proc/cpuinfo\n";
510 const std::string Key = "processor";
511 std::string ln;
512 while (std::getline(f, ln)) {
514 std::size_t split_idx = ln.find(':');
515 std::string value;
519 if (split_idx != std::string::npos)
522 if (split_idx != std::string::npos) value = ln.substr(split_idx + 1);
528 max_id = std::max(cur_id, max_id);
533 std::cerr << "Failure reading /proc/cpuinfo\n";
537 std::cerr << "Failed to read to end of /proc/cpuinfo\n";
556 std::cerr << "***WARNING*** Failed to set thread affinity. Estimated CPU "
558 << std::endl;
660 std::ifstream f("/proc/cpuinfo");
662 std::cerr << "failed to open /proc/cpuinfo\n";
666 auto StartsWithKey = [](std::string const& Value, std::string const& Key) {
669 return std::tolower(X) == std::tolower(Y);
671 return std::equal(Key.begin(), Key.end(), Value.begin(), Cmp);
674 std::string ln;
675 while (std::getline(f, ln)) {
677 std::size_t split_idx = ln.find(':');
678 std::string value;
679 if (split_idx != std::string::npos) value = ln.substr(split_idx + 1);
696 std::cerr << "Failure reading /proc/cpuinfo\n";
700 std::cerr << "Failed to read to end of /proc/cpuinfo\n";
746 std::cerr << "failed to open /dev/kstat\n";
752 std::cerr << "failed to lookup in /dev/kstat\n";
756 std::cerr << "failed to read from /dev/kstat\n";
762 std::cerr << "failed to lookup data in /dev/kstat\n";
766 std::cerr << "current_clock_Hz is of unexpected data type: "
793 using PRNG = std::minstd_rand;
816 std::vector<double> GetLoadAvg() {
822 std::vector<double> res(kMaxSamples, 0.0);