mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-02 11:23:41 +01:00
Basic BSD support
This commit is contained in:
@@ -259,7 +259,6 @@ if(LINUX OR BSD)
|
||||
src/detection/host/host_linux.c
|
||||
src/detection/os/os_linux.c
|
||||
src/detection/gpu/gpu_linux.c
|
||||
src/detection/memory/memory_linux.c
|
||||
src/detection/battery/battery_linux.c
|
||||
src/detection/displayserver/linux/displayserver_linux.c
|
||||
src/detection/displayserver/linux/wayland.c
|
||||
|
||||
+3
-3
@@ -5,13 +5,13 @@
|
||||
void ffSysctlGetString(const char* propName, FFstrbuf* result)
|
||||
{
|
||||
size_t neededLength;
|
||||
if(sysctlbyname(propName, NULL, &neededLength, NULL, 0) != 0 || neededLength == 0)
|
||||
if(sysctlbyname(propName, NULL, &neededLength, NULL, 0) != 0 || neededLength == 1) //neededLength is 1 for empty strings, because of the null terminator
|
||||
return;
|
||||
|
||||
ffStrbufEnsureFree(result, (uint32_t) neededLength);
|
||||
ffStrbufEnsureFree(result, (uint32_t) neededLength - 1);
|
||||
|
||||
if(sysctlbyname(propName, result->chars + result->length, &neededLength, NULL, 0) == 0)
|
||||
result->length += (uint32_t) neededLength;
|
||||
result->length += (uint32_t) neededLength - 1;
|
||||
|
||||
result->chars[result->length] = '\0';
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define FF_INCLUDED_common_sysctl
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
void ffSysctlGetString(const char* propName, FFstrbuf* result);
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
#include "cpu.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
void ffDetectCPUImpl(FFCPUResult* cpu)
|
||||
{
|
||||
ffStrbufInit(&cpu->vendor);
|
||||
ffStrbufInitA(&cpu->vendor, 0);
|
||||
|
||||
ffStrbufInit(&cpu->name);
|
||||
cpu->coresPhysical = 1;
|
||||
cpu->coresLogical = 1;
|
||||
cpu->coresOnline = 1;
|
||||
frequencyMin = 0.0;
|
||||
frequencyMax = 0.0;
|
||||
temperature = FF_CPU_TEMP_UNSET;
|
||||
ffSysctlGetString("hw.model", &cpu->name);
|
||||
|
||||
cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1);
|
||||
cpu->coresLogical = cpu->coresPhysical;
|
||||
cpu->coresOnline = cpu->coresPhysical;
|
||||
|
||||
cpu->frequencyMin = ffSysctlGetInt("hw.clockrate", 0) / 1000.0;
|
||||
cpu->frequencyMax = cpu->frequencyMin;
|
||||
|
||||
cpu->temperature = FF_CPU_TEMP_UNSET;
|
||||
}
|
||||
|
||||
@@ -234,9 +234,11 @@ static const char* pciDetectGPUs(const FFinstance* instance, FFlist* gpus)
|
||||
|
||||
#endif
|
||||
|
||||
const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
|
||||
void ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
|
||||
{
|
||||
#ifdef FF_HAVE_LIBPCI
|
||||
return pciDetectGPUs(instance, gpus);
|
||||
pciDetectGPUs(instance, gpus);
|
||||
#else
|
||||
FF_UNUSED(gpus, instance);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "memory.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
void ffDetectMemoryImpl(FFMemoryResult* memory)
|
||||
{
|
||||
memory->ram.bytesTotal = 0;
|
||||
memory->ram.bytesTotal = (uint64_t) ffSysctlGetInt64("hw.physmem", 0);
|
||||
memory->ram.bytesUsed = 0;
|
||||
|
||||
memory->swap.bytesTotal = 0;
|
||||
memory->swap.bytesUsed = 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ void ffPrintCPU(FFinstance* instance)
|
||||
|
||||
const FFCPUResult* cpu = ffDetectCPU();
|
||||
|
||||
if(cpu->vendor.length == 0 && cpu->name.length == 0 && cpu->coresOnline == 0)
|
||||
if(cpu->vendor.length == 0 && cpu->name.length == 0 && cpu->coresOnline <= 1)
|
||||
{
|
||||
ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpu, "No CPU detected");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user