From fbab7820f05e041253534ee6a3dea4b5751f2a9e Mon Sep 17 00:00:00 2001 From: Samuel Venable Date: Wed, 29 May 2024 01:57:07 +0000 Subject: [PATCH] Add files via upload --- build.sh | 6 +++--- system.cpp | 10 ++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/build.sh b/build.sh index 0dd6bb2..bbcefb2 100755 --- a/build.sh +++ b/build.sh @@ -4,7 +4,7 @@ xxd -i pci.ids > pci.ids.hpp; if [ $(uname) = "Darwin" ]; then clang++ main.cpp system.cpp -o sysinfo -std=c++17 -arch x86_64 -arch arm64; ./sysinfo -h 2> /dev/null; elif [ $(uname) = "Linux" ]; then - g++ main.cpp system.cpp -o sysinfo -std=c++17 -DCREATE_CONTEXT -static-libgcc -static-libstdc++ `pkg-config --cflags --libs sdl2` `pkg-config --cflags --libs x11` -lGL -lpthread; ./sysinfo -h 2> /dev/null; + g++ main.cpp system.cpp -o sysinfo -std=c++17 -DCREATE_CONTEXT -static-libgcc -static-libstdc++ `pkg-config --cflags --libs sdl2` `pkg-config --cflags --libs x11` -lGL -lhwloc -lpthread; ./sysinfo -h 2> /dev/null; elif [ $(uname) = "FreeBSD" ]; then clang++ main.cpp system.cpp -o sysinfo -std=c++17 -DCREATE_CONTEXT `pkg-config --cflags --libs sdl2` `pkg-config --cflags --libs x11` -lGL -lhwloc -lkvm -lpthread; ./sysinfo -h 2> /dev/null; elif [ $(uname) = "DragonFly" ]; then @@ -14,7 +14,7 @@ elif [ $(uname) = "NetBSD" ]; then elif [ $(uname) = "OpenBSD" ]; then clang++ main.cpp system.cpp -o sysinfo -std=c++17 -DCREATE_CONTEXT `pkg-config --cflags --libs sdl2` `pkg-config --cflags --libs x11` -lGL -lhwloc -lpthread; ./sysinfo -h 2> /dev/null; elif [ $(uname) = "SunOS" ]; then - export PKG_CONFIG_PATH=/usr/lib/64/pkgconfig && g++ main.cpp system.cpp -o sysinfo -std=c++17 -DCREATE_CONTEXT -static-libgcc `pkg-config --cflags --libs sdl2` `pkg-config --cflags --libs x11` -lGL -lpthread; ./sysinfo -h 2> /dev/null; + export PKG_CONFIG_PATH=/usr/lib/64/pkgconfig && g++ main.cpp system.cpp -o sysinfo -std=c++17 -DCREATE_CONTEXT -static-libgcc `pkg-config --cflags --libs sdl2` `pkg-config --cflags --libs x11` -lGL -lhwloc -lpthread; ./sysinfo -h 2> /dev/null; else - g++ main.cpp system.cpp -o sysinfo.exe -std=c++17 -static-libgcc -static-libstdc++ -lws2_32 -ldxgi -lhwloc -lpsapi -static; ./sysinfo -h 2> /dev/null; + g++ main.cpp system.cpp -o sysinfo.exe -std=c++17 -static-libgcc -static-libstdc++ -lhwloc -lws2_32 -ldxgi -lpsapi -static; ./sysinfo -h 2> /dev/null; fi diff --git a/system.cpp b/system.cpp index afc9a7c..302ec77 100644 --- a/system.cpp +++ b/system.cpp @@ -65,7 +65,7 @@ #elif defined(__linux__) #include #endif -#if (defined(_WIN32) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)) +#if (defined(_WIN32) || defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun)) #include #endif #if ((defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun)) @@ -1547,11 +1547,7 @@ std::string cpu_core_count() { std::size_t sz = sizeof(int); if (!sysctlbyname("machdep.cpu.core_count", &buf, &sz, nullptr, 0)) numcores = buf; - #elif defined(__linux__) - int threads_per_core = (int)strtol(read_output("lscpu | grep 'Thread(s) per core:' | uniq | cut -d' ' -f4- | awk 'NR==1{$1=$1;print}'").c_str(), nullptr, 10); - numcores = (int)(strtol(((cpu_processor_count() != pointer_null()) ? cpu_processor_count().c_str() : "0"), nullptr, 10) / ((threads_per_core) ? threads_per_core : 1)); - #endif - #if (defined(_WIN32) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)) + #if (defined(_WIN32) || defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun)) #if defined(_WIN32) /* for windows programs run under WINE (no wmic cli) */ if (!numcores) @@ -1568,8 +1564,6 @@ std::string cpu_core_count() { } hwloc_topology_destroy(topology); } - #elif defined(__sun) - numcores = (int)strtol(read_output("kstat -m cpu_info | grep -w core_id | uniq | wc -l | awk '{print $1}'").c_str(), nullptr, 10); #endif if (!numcores) numcores = -1;