mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-31 10:02:49 +01:00
Platform: detect system page size
This commit is contained in:
@@ -11,17 +11,12 @@ const char* ffDetectMemory(FFMemoryResult* ram)
|
||||
if (sysctl((int[]){ CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0))
|
||||
return "Failed to read hw.memsize";
|
||||
|
||||
uint32_t pagesize;
|
||||
length = sizeof(pagesize);
|
||||
if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pagesize, &length, NULL, 0))
|
||||
return "Failed to read hw.pagesize";
|
||||
|
||||
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
|
||||
vm_statistics64_data_t vmstat;
|
||||
if(host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) (&vmstat), &count) != KERN_SUCCESS)
|
||||
return "Failed to read host_statistics64";
|
||||
|
||||
ram->bytesUsed = ((uint64_t) vmstat.active_count + vmstat.wire_count) * pagesize;
|
||||
ram->bytesUsed = ((uint64_t) vmstat.active_count + vmstat.wire_count) * instance.state.platform.pageSize;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -7,17 +7,12 @@ const char* ffDetectMemory(FFMemoryResult* ram)
|
||||
if (sysctl((int[]){ CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0))
|
||||
return "Failed to read hw.physmem";
|
||||
|
||||
uint32_t pageSize;
|
||||
length = sizeof(pageSize);
|
||||
if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pageSize, &length, NULL, 0))
|
||||
return "Failed to read hw.pagesize";
|
||||
|
||||
// vm.stats.vm.* are int values
|
||||
int32_t pagesFree = ffSysctlGetInt("vm.stats.vm.v_free_count", 0)
|
||||
+ ffSysctlGetInt("vm.stats.vm.v_inactive_count", 0)
|
||||
+ ffSysctlGetInt("vm.stats.vm.v_cache_count", 0);
|
||||
|
||||
ram->bytesUsed = ram->bytesTotal - (uint64_t) pagesFree * pageSize;
|
||||
ram->bytesUsed = ram->bytesTotal - (uint64_t) pagesFree * instance.state.platform.pageSize;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
|
||||
const char* ffDetectSwap(FFSwapResult* swap)
|
||||
{
|
||||
SYSTEM_INFO sysInfo;
|
||||
GetNativeSystemInfo(&sysInfo);
|
||||
|
||||
ULONG size = sizeof(SYSTEM_PAGEFILE_INFORMATION);
|
||||
SYSTEM_PAGEFILE_INFORMATION* FF_AUTO_FREE pstart = (SYSTEM_PAGEFILE_INFORMATION*)malloc(size);
|
||||
while(true)
|
||||
@@ -24,8 +21,10 @@ const char* ffDetectSwap(FFSwapResult* swap)
|
||||
return "NtQuerySystemInformation(SystemPagefileInformation, size) failed";
|
||||
break;
|
||||
}
|
||||
swap->bytesUsed = (uint64_t)pstart->TotalUsed * sysInfo.dwPageSize;
|
||||
swap->bytesTotal = (uint64_t)pstart->CurrentSize * sysInfo.dwPageSize;
|
||||
|
||||
uint32_t pageSize = instance.state.platform.pageSize;
|
||||
swap->bytesUsed = (uint64_t)pstart->TotalUsed * pageSize;
|
||||
swap->bytesTotal = (uint64_t)pstart->CurrentSize * pageSize;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user