Skip to content

Commit 0321cd7

Browse files
move to snake_case all apple silicon gpu implementations
1 parent 102f2e1 commit 0321cd7

6 files changed

Lines changed: 214 additions & 216 deletions

File tree

src/osx/btop_collect.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,10 @@ namespace Cpu {
455455
CFDictionaryRef one_ps = IOPSGetPowerSourceDescription(ps_info(), CFArrayGetValueAtIndex(one_ps_descriptor(), 0));
456456
has_battery = true;
457457

458-
int32_t estimatedMinutesRemaining = SafeIOServiceGetNumberFromDictionary(one_ps, CFSTR(kIOPSTimeToEmptyKey)).value_or(0);
458+
int32_t estimatedMinutesRemaining = safe_cfdictionary_to_int64(one_ps, CFSTR(kIOPSTimeToEmptyKey)).value_or(0);
459459
seconds = estimatedMinutesRemaining * 60;
460-
percent = SafeIOServiceGetNumberFromDictionary(one_ps, CFSTR(kIOPSCurrentCapacityKey)).value_or(0);
461-
bool charging = SafeIOServiceBoolFromDictionary(one_ps, CFSTR(kIOPSIsChargingKey)).value_or(false);
460+
percent = safe_cfdictionary_to_int64(one_ps, CFSTR(kIOPSCurrentCapacityKey)).value_or(0);
461+
bool charging = safe_cfdictionary_to_bool(one_ps, CFSTR(kIOPSIsChargingKey)).value_or(false);
462462
if (charging) {
463463
status = "charging";
464464
}
@@ -631,8 +631,8 @@ namespace Mem {
631631

632632
CFMutableDictionaryRef properties = nullptr;
633633
if (IORegistryEntryCreateCFProperties(volumeRef, &properties, kCFAllocatorDefault, 0) == KERN_SUCCESS) {
634-
bsdName = SafeIOServiceGetStringFromDictionary(properties, CFSTR("BSD Name")).value_or("");
635-
device = SafeIOServiceGetStringFromDictionary(properties, CFSTR("VolGroupMntFromName")).value_or("");
634+
bsdName = safe_cfdictionary_to_std_string(properties, CFSTR("BSD Name")).value_or("");
635+
device = safe_cfdictionary_to_std_string(properties, CFSTR("VolGroupMntFromName")).value_or("");
636636
}
637637

638638
if (!mapping.contains(device)) {
@@ -647,15 +647,15 @@ namespace Mem {
647647
CFDictionaryRef statistics = (CFDictionaryRef)CFDictionaryGetValue(properties, CFSTR("Statistics"));
648648
if (statistics) {
649649
disk_ios++;
650-
int64_t readBytes = SafeIOServiceGetNumberFromDictionary(statistics, CFSTR("Bytes read from block device")).value_or(0);
650+
int64_t readBytes = safe_cfdictionary_to_int64(statistics, CFSTR("Bytes read from block device")).value_or(0);
651651
if (disk.io_read.empty())
652652
disk.io_read.push_back(0);
653653
else
654654
disk.io_read.push_back(max((int64_t)0, (readBytes - disk.old_io.at(0))));
655655
disk.old_io.at(0) = readBytes;
656656
while (cmp_greater(disk.io_read.size(), width * 2)) disk.io_read.pop_front();
657657

658-
int64_t writeBytes = SafeIOServiceGetNumberFromDictionary(statistics, CFSTR("Bytes written to block device")).value_or(0);
658+
int64_t writeBytes = safe_cfdictionary_to_int64(statistics, CFSTR("Bytes written to block device")).value_or(0);
659659
if (disk.io_write.empty())
660660
disk.io_write.push_back(0);
661661
else
@@ -1481,7 +1481,7 @@ namespace Gpu {
14811481
//? Initialize Apple Silicon GPU monitoring Although the chips always have 1 GPU, I assume we can reuse them later on Intel Macs.
14821482
bool init() {
14831483
const size_t index = gpus.size();
1484-
auto & io_gpus = io_gpu.getGPUs();
1484+
auto & io_gpus = io_gpu.get_gpus();
14851485
device_count += io_gpus.size();
14861486

14871487
if (io_gpus.empty())
@@ -1492,8 +1492,8 @@ namespace Gpu {
14921492
for(size_t i = 0; i < io_gpus.size() ; i++){
14931493
gpus.emplace_back();
14941494
std::string name = fmt::format("{} ({})",
1495-
io_gpus[i].getName(),
1496-
io_gpus[i].getCoreCount());
1495+
io_gpus[i].get_name(),
1496+
io_gpus[i].get_core_count());
14971497
gpu_names.emplace_back(name);
14981498
collect<true>(&gpus[index], i);
14991499
}
@@ -1517,9 +1517,9 @@ namespace Gpu {
15171517
gpus_slice->supported_functions = {
15181518
.gpu_utilization = true,
15191519
.mem_utilization = false,
1520-
.gpu_clock = IOReport::LibHandle ? true : false,
1520+
.gpu_clock = IOReport::lib_handle ? true : false,
15211521
.mem_clock = false,
1522-
.pwr_usage = IOReport::LibHandle ? true : false,
1522+
.pwr_usage = IOReport::lib_handle ? true : false,
15231523
.pwr_state = false,
15241524
.temp_info = false, // IOReport::LibHandle ? true : false
15251525
.mem_total = true,
@@ -1531,12 +1531,12 @@ namespace Gpu {
15311531
gpus_slice->pwr_max_usage = 30'000; //? 30w
15321532
}
15331533

1534-
auto& io_gpus = io_gpu.getGPUs();
1534+
auto& io_gpus = io_gpu.get_gpus();
15351535
if (io_gpus.empty())
15361536
return false;
15371537

1538-
io_gpus[i].Refesh();
1539-
auto gpu_data = io_gpus[i].getStatistics();
1538+
io_gpus[i].refesh();
1539+
auto gpu_data = io_gpus[i].get_statistics();
15401540

15411541
gpus_slice->gpu_percent.at("gpu-totals").push_back(gpu_data.device_utilization);
15421542

@@ -1551,7 +1551,7 @@ namespace Gpu {
15511551
gpus_slice->gpu_percent.at("gpu-vram-totals").push_back(mem_percent);
15521552
//gpus_slice->mem_utilization_percent.push_back(mem_percent);
15531553

1554-
if(IOReport::LibHandle){
1554+
if(IOReport::lib_handle){
15551555
gpus_slice->gpu_percent.at("gpu-pwr-totals").push_back(gpu_data.milliwatts);
15561556
gpus_slice->pwr_usage = gpu_data.milliwatts;
15571557
gpus_slice->gpu_clock_speed = gpu_data.gpu_frequency / 1'000'000;

0 commit comments

Comments
 (0)