diff --git a/src/Makefile b/src/Makefile index 0d5801d45..6c4c4823b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -140,6 +140,7 @@ else # All the other OSes (notably Linux) FINAL_LDFLAGS+= -rdynamic FINAL_LIBS+=-ldl -pthread -lrt -luuid + FINAL_CFLAGS += -DMOTD endif endif endif diff --git a/src/fastlock.cpp b/src/fastlock.cpp index 1340e087c..00ad8884a 100644 --- a/src/fastlock.cpp +++ b/src/fastlock.cpp @@ -36,7 +36,9 @@ #include #include #include +#ifdef __linux__ #include +#endif #include #ifdef __APPLE__ @@ -67,6 +69,7 @@ uint64_t fastlock_getlongwaitcount() } #ifndef ASM_SPINLOCK +#ifdef __linux__ static int futex(volatile unsigned *uaddr, int futex_op, int val, const struct timespec *timeout, int val3) { @@ -74,6 +77,7 @@ static int futex(volatile unsigned *uaddr, int futex_op, int val, timeout, uaddr, val3); } #endif +#endif extern "C" pid_t gettid() { @@ -121,9 +125,11 @@ extern "C" void fastlock_lock(struct fastlock *lock) #endif if ((++cloops % 1024*1024) == 0) { +#ifdef __linux__ __atomic_fetch_or(&lock->futex, mask, __ATOMIC_ACQUIRE); futex(&lock->m_ticket.u, FUTEX_WAIT_BITSET_PRIVATE, ticketT.u, nullptr, mask); __atomic_fetch_and(&lock->futex, ~mask, __ATOMIC_RELEASE); +#endif ++g_longwaits; } } @@ -159,6 +165,7 @@ extern "C" int fastlock_trylock(struct fastlock *lock, int fWeak) return false; } +#ifdef __linux__ #define ROL32(v, shift) ((v << shift) | (v >> (32-shift))) void unlock_futex(struct fastlock *lock, uint16_t ifutex) { @@ -174,6 +181,8 @@ void unlock_futex(struct fastlock *lock, uint16_t ifutex) break; } } +#endif + extern "C" void fastlock_unlock(struct fastlock *lock) { --lock->m_depth; @@ -183,7 +192,9 @@ extern "C" void fastlock_unlock(struct fastlock *lock) lock->m_pidOwner = -1; std::atomic_thread_fence(std::memory_order_release); uint16_t activeNew = __atomic_add_fetch(&lock->m_ticket.m_active, 1, __ATOMIC_RELEASE); // on x86 the atomic is not required here, but ASM handles that case +#ifdef __linux__ unlock_futex(lock, activeNew); +#endif } } #endif diff --git a/src/redis-cli.c b/src/redis-cli.c index 50e2e8480..eae4a1d0e 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -6537,7 +6537,7 @@ static void intrinsicLatencyMode(void) { /*------------------------------------------------------------------------------ * Message of the day *--------------------------------------------------------------------------- */ -#ifndef NO_MOTD +#ifdef MOTD #include static const char *szMotdCachePath()