From c90a2c9ea1644507c0993513d1fc7925e19b4ea8 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Wed, 31 Aug 2022 13:30:01 +0200 Subject: windows implementation for get_core_count() --- src/CMakeLists.txt | 3 +-- src/threading/cpu.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f3113e0..80a59bb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,8 +6,7 @@ add_subdirectory(vdf) add_subdirectory(threading) set(CFLAGS - -Wall -Wextra -pedantic - -Wfloat-equal -Wundef + -Wall -Wextra -pedantic -Wfloat-equal -Wstrict-overflow=5 -Wunreachable-code -Wcast-qual -Wswitch-default -Wconversion -Wshadow -Wstrict-aliasing diff --git a/src/threading/cpu.c b/src/threading/cpu.c index 45671df..381abeb 100644 --- a/src/threading/cpu.c +++ b/src/threading/cpu.c @@ -1,6 +1,17 @@ +#ifdef _WIN32 +#include +#else #include +#endif int get_core_count() { - return get_nprocs(); +#ifdef _WIN32 + SYSTEM_INFO sysinfo; + GetSystemInfo( &sysinfo ); + + return sysinfo.dwNumberOfProcessors; +#else + return get_nprocs(); +#endif } -- cgit v1.2.3