diff options
author | Sven Göthel <[email protected]> | 2024-05-12 07:42:44 +0200 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-05-12 07:42:44 +0200 |
commit | 3d1503ccb20f3c0f2b23940fc9395f3395c503c0 (patch) | |
tree | cc903ddb7ab983d30d502cb1abbc34f464bf7219 | |
parent | 1e5b78f1cc8c2a7a641ee6e9211edf07598ba6b3 (diff) |
cpuid: Add page_size for Windows, use zero for undefined (not 1)
-rw-r--r-- | include/jau/cpuid.hpp | 2 | ||||
-rw-r--r-- | src/cpuid.cpp | 22 |
2 files changed, 16 insertions, 8 deletions
diff --git a/include/jau/cpuid.hpp b/include/jau/cpuid.hpp index e52583e..15f9f13 100644 --- a/include/jau/cpuid.hpp +++ b/include/jau/cpuid.hpp @@ -317,7 +317,7 @@ namespace jau::cpu { public: /** See pointer_bit_size() */ size_t pointer_bits; - /** Size of a page in bytes */ + /** Size of a page in bytes or zero if not available */ size_t page_size; /** True if successfully queried l1_share_max and l1_apart_min. */ bool has_l1_minmax; diff --git a/src/cpuid.cpp b/src/cpuid.cpp index 0500c4d..3870fcf 100644 --- a/src/cpuid.cpp +++ b/src/cpuid.cpp @@ -26,7 +26,6 @@ #include <string> #include <cstdint> #include <cstdlib> -#include <unistd.h> #include <thread> #include <new> @@ -35,10 +34,15 @@ #include <jau/debug.hpp> #include <jau/os/os_support.hpp> -#ifdef __linux__ - extern "C" { - #include <sys/auxv.h> - } +#if defined(_WIN32) + #include <windows.h> +#else /* assume POSIX sysconf() availability */ + #include <unistd.h> + #ifdef __linux__ + extern "C" { + #include <sys/auxv.h> + } + #endif #endif using namespace jau; @@ -57,10 +61,14 @@ static bool get_cache_line_size(size_t& l1_share_max, size_t& l1_apart_min) noex } static size_t get_page_size() noexcept { - #if defined(JAU_OS_TYPE_UNIX) && defined(_SC_PAGESIZE) + #if defined(_WIN32) + SYSTEM_INFO si; + GetSystemInfo(&si); + return (jlong) si.dwPageSize; + #elif defined(JAU_OS_TYPE_UNIX) && defined(_SC_PAGESIZE) return sysconf(_SC_PAGESIZE); #else - return 1; // FIXME + return 0; #endif } static size_t get_concurrent_thread_count() noexcept { |