CMake: Detect cache line size dynamically on AArch64 Linux

This commit is contained in:
Stenzek
2024-05-14 23:50:26 +10:00
parent d9003b10c3
commit 88ace6e4ae
4 changed files with 62 additions and 1 deletions

View File

@ -111,3 +111,6 @@ endif()
if(HOST_PAGE_SIZE)
target_compile_definitions(common PUBLIC "-DOVERRIDE_HOST_PAGE_SIZE=${HOST_PAGE_SIZE}")
endif()
if(HOST_CACHE_LINE_SIZE)
target_compile_definitions(common PUBLIC "-DOVERRIDE_HOST_CACHE_LINE_SIZE=${HOST_CACHE_LINE_SIZE}")
endif()

View File

@ -192,7 +192,9 @@ static constexpr u32 HOST_PAGE_SHIFT = 12;
#endif
// Host cache line sizes.
#if defined(__APPLE__) && defined(__aarch64__)
#if defined(OVERRIDE_HOST_CACHE_LINE_SIZE)
static constexpr u32 HOST_CACHE_LINE_SIZE = OVERRIDE_HOST_CACHE_LINE_SIZE;
#elif defined(__APPLE__) && defined(__aarch64__)
static constexpr u32 HOST_CACHE_LINE_SIZE = 128; // Apple Silicon uses 128b cache lines.
#else
static constexpr u32 HOST_CACHE_LINE_SIZE = 64; // Everything else is 64b.