Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
time-killer-games authored May 29, 2024
1 parent c9b5bde commit fbab782
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
10 changes: 2 additions & 8 deletions system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#elif defined(__linux__)
#include <sys/sysinfo.h>
#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 <hwloc.h>
#endif
#if ((defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun))
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit fbab782

Please sign in to comment.