diff --git a/src/Makefile b/src/Makefile index 6c4c4823b..5e035fb17 100644 --- a/src/Makefile +++ b/src/Makefile @@ -198,7 +198,7 @@ endif REDIS_SERVER_NAME=keydb-server REDIS_SENTINEL_NAME=keydb-sentinel -REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o acl.o storage.o rdb-s3.o fastlock.o $(ASM_OBJ) +REDIS_SERVER_OBJ=adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o acl.o storage.o rdb-s3.o fastlock.o new.o $(ASM_OBJ) REDIS_CLI_NAME=keydb-cli REDIS_CLI_OBJ=anet.o adlist.o dict.o redis-cli.o redis-cli-cpphelper.o zmalloc.o release.o anet.o ae.o crc64.o siphash.o crc16.o storage-lite.o fastlock.o $(ASM_OBJ) REDIS_BENCHMARK_NAME=keydb-benchmark diff --git a/src/fastlock.cpp b/src/fastlock.cpp index 00ad8884a..fdf85044a 100644 --- a/src/fastlock.cpp +++ b/src/fastlock.cpp @@ -53,6 +53,10 @@ #endif #endif +#ifndef UNUSED +#define UNUSED(x) ((void)x) +#endif + /**************************************************** * * Implementation of a fair spinlock. To promote fairness we @@ -115,7 +119,9 @@ extern "C" void fastlock_lock(struct fastlock *lock) } unsigned myticket = __atomic_fetch_add(&lock->m_ticket.m_avail, 1, __ATOMIC_RELEASE); +#ifdef __linux__ unsigned mask = (1U << (myticket % 32)); +#endif int cloops = 0; ticket ticketT; while (((ticketT.u = __atomic_load_4(&lock->m_ticket.m_active, __ATOMIC_ACQUIRE)) & 0xffff) != myticket) @@ -154,8 +160,8 @@ extern "C" int fastlock_trylock(struct fastlock *lock, int fWeak) uint16_t active = __atomic_load_2(&lock->m_ticket.m_active, __ATOMIC_RELAXED); uint16_t next = active + 1; - struct ticket ticket_expect { active, active }; - struct ticket ticket_setiflocked { active, next }; + struct ticket ticket_expect { { { active, active } } }; + struct ticket ticket_setiflocked { { { active, next } } }; if (__atomic_compare_exchange(&lock->m_ticket, &ticket_expect, &ticket_setiflocked, fWeak /*weak*/, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { lock->m_depth = 1; @@ -194,6 +200,8 @@ extern "C" void fastlock_unlock(struct fastlock *lock) 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); +#else + UNUSED(activeNew); #endif } } diff --git a/src/new.cpp b/src/new.cpp new file mode 100644 index 000000000..c94a3bc18 --- /dev/null +++ b/src/new.cpp @@ -0,0 +1,15 @@ +#include // std::size_t +#include "server.h" +#include "new.h" + +[[deprecated]] +void *operator new(size_t size) +{ + return zmalloc(size, MALLOC_LOCAL); +} + +void operator delete(void * p) noexcept +{ + zfree(p); +} + diff --git a/src/new.h b/src/new.h index 7ea65e979..6d33cf48d 100644 --- a/src/new.h +++ b/src/new.h @@ -2,22 +2,16 @@ #include // std::size_t [[deprecated]] -inline void *operator new(size_t size) -{ - return zmalloc(size, MALLOC_LOCAL); -} +void *operator new(size_t size); inline void *operator new(size_t size, enum MALLOC_CLASS mclass) { return zmalloc(size, mclass); -} - -inline void operator delete(void * p) noexcept -{ - zfree(p); } +void operator delete(void * p) noexcept; + inline void operator delete(void *p, std::size_t) noexcept { zfree(p); -} \ No newline at end of file +} diff --git a/src/redis-cli.h b/src/redis-cli.h index bda80c42b..33910c2ce 100644 --- a/src/redis-cli.h +++ b/src/redis-cli.h @@ -276,4 +276,5 @@ redisReply *sendScan(unsigned long long *it); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif + diff --git a/src/version.h b/src/version.h index 0c56a20a9..db32931f1 100644 --- a/src/version.h +++ b/src/version.h @@ -1,2 +1,3 @@ #define KEYDB_REAL_VERSION "0.0.0" -extern const char *KEYDB_SET_VERSION; // Unlike real version, this can be overriden by the config \ No newline at end of file +extern const char *KEYDB_SET_VERSION; // Unlike real version, this can be overriden by the config +