mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Global: don't require sysinfo.h globally
... which is Linux specific
This commit is contained in:
@@ -497,12 +497,6 @@ add_library(libfastfetch OBJECT
|
||||
|
||||
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE)
|
||||
|
||||
CHECK_INCLUDE_FILE("sys/sysinfo.h" HAVE_SYSINFO_H)
|
||||
if(HAVE_SYSINFO_H)
|
||||
# needs to be public, because changes fastfech.h ABI
|
||||
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_SYSINFO_H)
|
||||
endif()
|
||||
|
||||
CHECK_INCLUDE_FILE("utmpx.h" HAVE_UTMPX_H)
|
||||
if(HAVE_UTMPX_H)
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_UTMPX_H)
|
||||
|
||||
@@ -112,10 +112,6 @@ static void initState(FFstate* state)
|
||||
#endif
|
||||
uname(&state->utsname);
|
||||
|
||||
#if FF_HAVE_SYSINFO_H
|
||||
sysinfo(&state->sysinfo);
|
||||
#endif
|
||||
|
||||
initConfigDirs(state);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "common/properties.h"
|
||||
#include "detection/temps/temps_linux.h"
|
||||
|
||||
#include <sys/sysinfo.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -99,13 +100,8 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
|
||||
|
||||
cpu->coresPhysical = ffStrbufToUInt16(&physicalCoresBuffer, 1);
|
||||
|
||||
#ifdef FF_HAVE_SYSINFO_H
|
||||
cpu->coresLogical = (uint16_t) get_nprocs_conf();
|
||||
cpu->coresOnline = (uint16_t) get_nprocs();
|
||||
#else
|
||||
cpu->coresLogical = 1;
|
||||
cpu->coresOnline = 1;
|
||||
#endif
|
||||
cpu->coresLogical = (uint16_t) get_nprocs_conf();
|
||||
cpu->coresOnline = (uint16_t) get_nprocs();
|
||||
|
||||
#define BP "/sys/devices/system/cpu/cpufreq/policy0/"
|
||||
if(ffFileExists(BP, S_IFDIR))
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
uint32_t ffDetectProcesses(FFinstance* instance, FFstrbuf* error);
|
||||
uint32_t ffDetectProcesses(FFstrbuf* error);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
#include <sys/user.h>
|
||||
#endif
|
||||
|
||||
uint32_t ffDetectProcesses(FFinstance* instance, FFstrbuf* error)
|
||||
uint32_t ffDetectProcesses(FFstrbuf* error)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
|
||||
int request[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
|
||||
size_t length;
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#include "processes.h"
|
||||
|
||||
uint32_t ffDetectProcesses(FFinstance* instance, FFstrbuf* error)
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
uint32_t ffDetectProcesses(FFstrbuf* error)
|
||||
{
|
||||
#if FF_HAVE_SYSINFO_H
|
||||
FF_UNUSED(error);
|
||||
return (uint32_t) instance->state.sysinfo.procs;
|
||||
#else
|
||||
ffStrbufAppendS(error, "Unimplemented");
|
||||
return 0;
|
||||
#endif
|
||||
struct sysinfo info;
|
||||
if(sysinfo(&info) != 0)
|
||||
ffStrbufAppendS(error, "sysinfo() failed");
|
||||
return (uint32_t) info.procs;
|
||||
}
|
||||
|
||||
@@ -8,10 +8,8 @@ extern "C" {
|
||||
#include <ntstatus.h>
|
||||
#include <winternl.h>
|
||||
|
||||
uint32_t ffDetectProcesses(FFinstance* instance, FFstrbuf* error)
|
||||
uint32_t ffDetectProcesses(FFstrbuf* error)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
|
||||
ULONG size = 0;
|
||||
if(NtQuerySystemInformation(SystemProcessInformation, nullptr, 0, &size) != STATUS_INFO_LENGTH_MISMATCH)
|
||||
{
|
||||
@@ -44,7 +42,7 @@ uint32_t ffDetectProcesses(FFinstance* instance, FFstrbuf* error)
|
||||
|
||||
#include "util/windows/wmi.hpp"
|
||||
|
||||
uint32_t ffDetectProcesses(FFinstance* instance, FFstrbuf* error)
|
||||
uint32_t ffDetectProcesses(FFstrbuf* error)
|
||||
{
|
||||
FFWmiQuery query(L"SELECT NumberOfProcesses FROM Win32_OperatingSystem", error);
|
||||
if(!query)
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
uint64_t ffDetectUptime(const FFinstance* instance);
|
||||
uint64_t ffDetectUptime();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
uint64_t ffDetectUptime(const FFinstance* instance)
|
||||
uint64_t ffDetectUptime()
|
||||
{
|
||||
FF_UNUSED(instance)
|
||||
struct timeval bootTime;
|
||||
size_t bootTimeSize = sizeof(bootTime);
|
||||
if(sysctl(
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "uptime.h"
|
||||
|
||||
uint64_t ffDetectUptime(const FFinstance* instance)
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
uint64_t ffDetectUptime()
|
||||
{
|
||||
#if FF_HAVE_SYSINFO_H
|
||||
return (uint64_t) instance->state.sysinfo.uptime;
|
||||
#else
|
||||
FF_UNUSED(instance)
|
||||
struct sysinfo info;
|
||||
if(sysinfo(&info) != 0)
|
||||
return 0;
|
||||
#endif
|
||||
return (uint32_t) info.uptime;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <sysinfoapi.h>
|
||||
|
||||
uint64_t ffDetectUptime(const FFinstance* instance)
|
||||
uint64_t ffDetectUptime()
|
||||
{
|
||||
FF_UNUSED(instance)
|
||||
return GetTickCount64() / 1000;
|
||||
}
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
#include "util/windows/utsname.h"
|
||||
#endif
|
||||
|
||||
#if FF_HAVE_SYSINFO_H
|
||||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
|
||||
#include "util/FFstrbuf.h"
|
||||
#include "util/FFlist.h"
|
||||
|
||||
@@ -212,10 +208,6 @@ typedef struct FFstate
|
||||
struct passwd* passwd;
|
||||
struct utsname utsname;
|
||||
|
||||
#if FF_HAVE_SYSINFO_H
|
||||
struct sysinfo sysinfo;
|
||||
#endif
|
||||
|
||||
FFlist configDirs;
|
||||
} FFstate;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ void ffPrintProcesses(FFinstance* instance)
|
||||
{
|
||||
FFstrbuf error;
|
||||
ffStrbufInit(&error);
|
||||
uint32_t numProcesses = ffDetectProcesses(instance, &error);
|
||||
uint32_t numProcesses = ffDetectProcesses(&error);
|
||||
|
||||
if(error.length > 0)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
void ffPrintUptime(FFinstance* instance)
|
||||
{
|
||||
uint64_t uptime = ffDetectUptime(instance);
|
||||
uint64_t uptime = ffDetectUptime();
|
||||
|
||||
if(uptime == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user