use detail::fs in detail/turbo
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <fstream>
|
||||
|
||||
#include "perfect/result.hpp"
|
||||
#include "perfect/detail/fs.hpp"
|
||||
|
||||
namespace perfect {
|
||||
namespace detail {
|
||||
@@ -15,19 +16,12 @@ bool has_intel_pstate_no_turbo() {
|
||||
Result write_intel_pstate_no_turbo(const std::string &s) {
|
||||
assert(has_intel_pstate_no_turbo());
|
||||
std::string path("/sys/devices/system/cpu/intel_pstate/no_turbo");
|
||||
std::ofstream ofs(path, std::ofstream::out);
|
||||
ofs << s;
|
||||
ofs.close();
|
||||
if (ofs.fail()) {
|
||||
return Result::NO_PERMISSION;
|
||||
}
|
||||
return Result::SUCCESS;
|
||||
return write_str(path, s);
|
||||
}
|
||||
|
||||
std::string read_intel_pstate_no_turbo() {
|
||||
assert(has_intel_pstate_no_turbo());
|
||||
std::string path("/sys/devices/system/cpu/intel_pstate/no_turbo");
|
||||
// SPDLOG_LOGGER_TRACE(logger::console(), "reading {}", path);
|
||||
std::ifstream ifs(path, std::ifstream::in);
|
||||
std::string result;
|
||||
std::getline(ifs, result);
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "perfect/result.hpp"
|
||||
#include "perfect/detail/fs.hpp"
|
||||
|
||||
namespace perfect {
|
||||
namespace detail {
|
||||
@@ -9,16 +10,10 @@ bool has_acpi_cpufreq_boost() {
|
||||
return bool(std::ifstream("/sys/devices/system/cpu/cpufreq/boost"));
|
||||
}
|
||||
|
||||
int write_acpi_cpufreq_boost(const std::string &s) {
|
||||
Result write_acpi_cpufreq_boost(const std::string &s) {
|
||||
assert(has_acpi_cpufreq_boost());
|
||||
std::string path("/sys/devices/system/cpu/cpufreq/boost");
|
||||
std::ofstream ofs(path, std::ofstream::out);
|
||||
ofs << s;
|
||||
ofs.close();
|
||||
if (ofs.fail()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return write_str(path, s);
|
||||
}
|
||||
|
||||
std::string read_acpi_cpufeq_boost() {
|
||||
@@ -35,11 +30,11 @@ std::string read_acpi_cpufeq_boost() {
|
||||
}
|
||||
|
||||
Result disable_cpu_turbo() {
|
||||
write_acpi_cpufreq_boost("0");
|
||||
return write_acpi_cpufreq_boost("0");
|
||||
}
|
||||
|
||||
Result enable_cpu_turbo() {
|
||||
write_acpi_cpufreq_boost("1");
|
||||
return write_acpi_cpufreq_boost("1");
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
Reference in New Issue
Block a user