build: don't clash with FreeBSD native defines

FreeBSD has an existing CACHE_LINE_SIZE parameter as a platform-specific define.

```
# /usr/include/machine/param.h
/*
 * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
 * architecture.  It should be used with appropriate caution.
 */
#define CACHE_LINE_SHIFT        6
#define CACHE_LINE_SIZE         (1 << CACHE_LINE_SHIFT)
```
This commit is contained in:
Dave Cottlehuber 2021-01-04 13:13:06 +00:00
parent c8950490be
commit 96a37e4d46
1 changed files with 3 additions and 3 deletions

View File

@ -47,9 +47,9 @@
// TODO: We should make this dependent on the CPU. Maybe cmake
// can set this variable properly?
constexpr size_t CACHE_LINE_SIZE = 64;
constexpr size_t MAX_CACHE_LINE_SIZE = 64;
class alignas(CACHE_LINE_SIZE) ThreadSpinLock {
class alignas(MAX_CACHE_LINE_SIZE) ThreadSpinLock {
public:
// #ifdef _WIN32
ThreadSpinLock() {
@ -90,7 +90,7 @@ private:
std::atomic_flag isLocked = ATOMIC_FLAG_INIT;
// We want a spin lock to occupy a cache line in order to
// prevent false sharing.
std::array<uint8_t, CACHE_LINE_SIZE - sizeof(isLocked)> padding;
std::array<uint8_t, MAX_CACHE_LINE_SIZE - sizeof(isLocked)> padding;
};
class ThreadSpinLockHolder {