Add fallback for cache line size detection
Some checks failed
Build Alpine Package / build-alpine (push) Failing after 1m50s
Build Debian Package / build-debian (push) Successful in 1m58s

- Provide default cache line size for systems without _SC_LEVEL1_DCACHE_LINESIZE
- Set default to 64 bytes, which is common on x86_64 architectures
- Improve portability of cache line size detection
This commit is contained in:
2025-02-01 06:52:15 +00:00
parent 79c652cd7c
commit b9f6ef50af

View File

@@ -127,7 +127,12 @@ void MalignBuffer::InitializeMemoryForSanitizer(char *addr, size_t size) {
}
const size_t MalignBuffer::kPageSize = sysconf(_SC_PAGESIZE);
#ifdef _SC_LEVEL1_DCACHE_LINESIZE
const size_t MalignBuffer::kCacheLineSize = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
#else
// Default to 64 bytes which is common on x86_64
const size_t MalignBuffer::kCacheLineSize = 64;
#endif
std::string MalignBuffer::ToString(CopyMethod m) {
switch (m) {