| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/info/common/cpuinfoproccpuinfo.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "cpuinfoproccpuinfo.h"cxx . . $ `<file>/src/core/info/common/cpuinfoproccpuinfo.h`/ |
| 5 | |
| 6 | #include "../infoproviderregistry.h"cxx . . $ `<file>/src/core/info/infoproviderregistry.h`/ |
| 7 | #include "common/fileutils.h"cxx . . $ `<file>/src/common/fileutils.h`/ |
| 8 | #include "core/components/cpuutils.h"cxx . . $ `<file>/src/core/components/cpuutils.h`/ |
| 9 | #include <spdlog/spdlog.h> |
| 10 | |
| 11 | class CPUInfoProcCpuInfoDataSourcecxx . . $ CPUInfoProcCpuInfoDataSource# : public IDataSourcecxx . . $ IDataSource#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#>> |
| 12 | { |
| 13 | public: |
| 14 | stdcxx . . $ std/::stringcxx . . $ std/string# sourcecxx . . $ CPUInfoProcCpuInfoDataSource#source(219584694fe2b248).() const override |
| 15 | { |
| 16 | return "/proc/cpuinfo"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 17 | } |
| 18 | |
| 19 | bool readcxx . . $ CPUInfoProcCpuInfoDataSource#read(63ce86d3e6026f1d).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> &data) override |
| 20 | { |
| 21 | auto lines = Utilscxx . . $ Utils/::Filecxx . . $ Utils/File/::readFileLinescxx . . $ Utils/File/readFileLines(951e54d16e2206f).(sourcecxx . . $ std/filesystem/__cxx11/path#path(2f6c7066048c5333).()); |
| 22 | if (!lines.emptycxx . . $ std/vector#empty(3482b152b9333168).()) { |
| 23 | stdcxx . . $ std/::swapcxx . . $ std/swap(90aec5ea4c4ede5e).(data, lines); |
| 24 | return true; |
| 25 | } |
| 26 | |
| 27 | SPDLOG_WARNcxx . . $ `<external>/13613935168682455490/spdlog.h:329:13`!("Cannot retrieve device information from {}", source()); |
| 28 | return false; |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | CPUInfoProcCpuInfocxx . . $ CPUInfoProcCpuInfo#::CPUInfoProcCpuInfocxx . . $ CPUInfoProcCpuInfo#CPUInfoProcCpuInfo(2fc9eef85304919b).( |
| 33 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IDataSourcecxx . . $ IDataSource#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#>>> &&dataSource) noexcept |
| 34 | : dataSource_cxx . . $ CPUInfoProcCpuInfo#dataSource_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(dataSource)) |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>> CPUInfoProcCpuInfocxx . . $ CPUInfoProcCpuInfo#::provideInfocxx . . $ CPUInfoProcCpuInfo#provideInfo(ba0be1eb8c175b81).( |
| 39 | int, stdcxx . . $ std/::vectorcxx . . $ std/vector#<ICPUInfocxx . . $ ICPUInfo#::ExecutionUnitcxx . . $ ICPUInfo#ExecutionUnit#> const &executionUnits) |
| 40 | { |
| 41 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>> infocxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 42 | |
| 43 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> datacxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 44 | if (!executionUnits.emptycxx . . $ std/vector#empty(3482b152b9333168).() && dataSource_cxx . . $ CPUInfoProcCpuInfo#dataSource_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).readcxx . . $ IDataSource#read(ad81cd1bcc32f58b).(data)) { |
| 45 | |
| 46 | info.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(ICPUInfocxx . . $ ICPUInfo#::Keyscxx . . $ ICPUInfo#Keys#::executionUnitscxx . . $ ICPUInfo#Keys#executionUnits., |
| 47 | stdcxx . . $ std/::to_stringcxx . . $ std/__cxx11/to_string(354ce04007c9ea85).(executionUnits.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).())); |
| 48 | auto cpuId = executionUnits.frontcxx . . $ std/vector#front(af0004c3ce7cab93).().cpuIdcxx . . $ ICPUInfo#ExecutionUnit#cpuId.; |
| 49 | |
| 50 | addInfocxx . . $ CPUInfoProcCpuInfo#addInfo(11ee9c4fbcc7b2ce).("vendor_id"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792)., ICPUInfocxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Keyscxx . . $ ICPUInfo#Keys#::vendorIdcxx . . $ ICPUInfo#Keys#vendorId., cpuId, info, data); |
| 51 | addInfocxx . . $ CPUInfoProcCpuInfo#addInfo(11ee9c4fbcc7b2ce).("cpu family"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792)., ICPUInfocxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Keyscxx . . $ ICPUInfo#Keys#::cpuFamilycxx . . $ ICPUInfo#Keys#cpuFamily., cpuId, info, data); |
| 52 | addInfocxx . . $ CPUInfoProcCpuInfo#addInfo(11ee9c4fbcc7b2ce).("model"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792)., ICPUInfocxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Keyscxx . . $ ICPUInfo#Keys#::modelcxx . . $ ICPUInfo#Keys#model., cpuId, info, data); |
| 53 | addInfocxx . . $ CPUInfoProcCpuInfo#addInfo(11ee9c4fbcc7b2ce).("model name"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792)., ICPUInfocxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Keyscxx . . $ ICPUInfo#Keys#::modelNamecxx . . $ ICPUInfo#Keys#modelName., cpuId, info, data); |
| 54 | addInfocxx . . $ CPUInfoProcCpuInfo#addInfo(11ee9c4fbcc7b2ce).("stepping"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792)., ICPUInfocxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Keyscxx . . $ ICPUInfo#Keys#::steppingcxx . . $ ICPUInfo#Keys#stepping., cpuId, info, data); |
| 55 | addInfocxx . . $ CPUInfoProcCpuInfo#addInfo(11ee9c4fbcc7b2ce).("microcode"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792)., ICPUInfocxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Keyscxx . . $ ICPUInfo#Keys#::ucodecxx . . $ ICPUInfo#Keys#ucode., cpuId, info, data); |
| 56 | addInfocxx . . $ CPUInfoProcCpuInfo#addInfo(11ee9c4fbcc7b2ce).("cache size"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792)., ICPUInfocxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Keyscxx . . $ ICPUInfo#Keys#::l3Cachecxx . . $ ICPUInfo#Keys#l3Cache., cpuId, info, data); |
| 57 | addInfocxx . . $ CPUInfoProcCpuInfo#addInfo(11ee9c4fbcc7b2ce).("cpu cores"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792)., ICPUInfocxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Keyscxx . . $ ICPUInfo#Keys#::corescxx . . $ ICPUInfo#Keys#cores., cpuId, info, data); |
| 58 | addInfocxx . . $ CPUInfoProcCpuInfo#addInfo(11ee9c4fbcc7b2ce).("flags"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792)., ICPUInfocxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Keyscxx . . $ ICPUInfo#Keys#::flagscxx . . $ ICPUInfo#Keys#flags., cpuId, info, data); |
| 59 | addInfocxx . . $ CPUInfoProcCpuInfo#addInfo(11ee9c4fbcc7b2ce).("bugs"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792)., ICPUInfocxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Keyscxx . . $ ICPUInfo#Keys#::bugscxx . . $ ICPUInfo#Keys#bugs., cpuId, info, data); |
| 60 | addInfocxx . . $ CPUInfoProcCpuInfo#addInfo(11ee9c4fbcc7b2ce).("bogomips"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792)., ICPUInfocxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Keyscxx . . $ ICPUInfo#Keys#::bogomipscxx . . $ ICPUInfo#Keys#bogomips., cpuId, info, data); |
| 61 | } |
| 62 | |
| 63 | return infocxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 64 | } |
| 65 | |
| 66 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> CPUInfoProcCpuInfocxx . . $ CPUInfoProcCpuInfo#::provideCapabilitiescxx . . $ CPUInfoProcCpuInfo#provideCapabilities(61866227792b2a60).( |
| 67 | int, stdcxx . . $ std/::vectorcxx . . $ std/vector#<ICPUInfocxx . . $ ICPUInfo#::ExecutionUnitcxx . . $ ICPUInfo#ExecutionUnit#> const &) |
| 68 | { |
| 69 | return {cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).}; |
| 70 | } |
| 71 | |
| 72 | void CPUInfoProcCpuInfocxx . . $ CPUInfoProcCpuInfo#::addInfocxx . . $ CPUInfoProcCpuInfo#addInfo(11ee9c4fbcc7b2ce).( |
| 73 | stdcxx . . $ std/::string_viewcxx . . $ std/string_view# target, stdcxx . . $ std/::string_viewcxx . . $ std/string_view# key, int cpuId, |
| 74 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>> &info, |
| 75 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> const &lines) const |
| 76 | { |
| 77 | auto data = Utilscxx . . $ Utils/::CPUcxx . . $ Utils/CPU/::parseProcCpuInfocxx . . $ Utils/CPU/parseProcCpuInfo(6ce55c29d0623432).(lines, cpuId, targetcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).); |
| 78 | if (data.has_valuecxx . . $ std/optional#has_value(3482b152b9333168).()) |
| 79 | info.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(key, *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).data); |
| 80 | } |
| 81 | |
| 82 | bool CPUInfoProcCpuInfocxx . . $ CPUInfoProcCpuInfo#::registered_cxx . . $ CPUInfoProcCpuInfo#registered_. = |
| 83 | InfoProviderRegistrycxx . . $ InfoProviderRegistry#::addcxx . . $ InfoProviderRegistry#add(b26eb1c59e57874a).(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<CPUInfoProcCpuInfocxx . . $ CPUInfoProcCpuInfo#>( |
| 84 | stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<CPUInfoProcCpuInfoDataSourcecxx . . $ CPUInfoProcCpuInfoDataSource#>())); |