Fix additional warnings
Former-commit-id: 1531cfb7eea1824fb40da596b3446baa4312355c
This commit is contained in:
parent
15d37f3d65
commit
5aaa95ec11
@ -198,7 +198,7 @@ endif
|
|||||||
|
|
||||||
REDIS_SERVER_NAME=keydb-server
|
REDIS_SERVER_NAME=keydb-server
|
||||||
REDIS_SENTINEL_NAME=keydb-sentinel
|
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_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_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
|
REDIS_BENCHMARK_NAME=keydb-benchmark
|
||||||
|
@ -53,6 +53,10 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef UNUSED
|
||||||
|
#define UNUSED(x) ((void)x)
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************
|
/****************************************************
|
||||||
*
|
*
|
||||||
* Implementation of a fair spinlock. To promote fairness we
|
* 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);
|
unsigned myticket = __atomic_fetch_add(&lock->m_ticket.m_avail, 1, __ATOMIC_RELEASE);
|
||||||
|
#ifdef __linux__
|
||||||
unsigned mask = (1U << (myticket % 32));
|
unsigned mask = (1U << (myticket % 32));
|
||||||
|
#endif
|
||||||
int cloops = 0;
|
int cloops = 0;
|
||||||
ticket ticketT;
|
ticket ticketT;
|
||||||
while (((ticketT.u = __atomic_load_4(&lock->m_ticket.m_active, __ATOMIC_ACQUIRE)) & 0xffff) != myticket)
|
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 active = __atomic_load_2(&lock->m_ticket.m_active, __ATOMIC_RELAXED);
|
||||||
uint16_t next = active + 1;
|
uint16_t next = active + 1;
|
||||||
|
|
||||||
struct ticket ticket_expect { active, active };
|
struct ticket ticket_expect { { { active, active } } };
|
||||||
struct ticket ticket_setiflocked { active, next };
|
struct ticket ticket_setiflocked { { { active, next } } };
|
||||||
if (__atomic_compare_exchange(&lock->m_ticket, &ticket_expect, &ticket_setiflocked, fWeak /*weak*/, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
|
if (__atomic_compare_exchange(&lock->m_ticket, &ticket_expect, &ticket_setiflocked, fWeak /*weak*/, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
|
||||||
{
|
{
|
||||||
lock->m_depth = 1;
|
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
|
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__
|
#ifdef __linux__
|
||||||
unlock_futex(lock, activeNew);
|
unlock_futex(lock, activeNew);
|
||||||
|
#else
|
||||||
|
UNUSED(activeNew);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
src/new.cpp
Normal file
15
src/new.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <cstddef> // 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);
|
||||||
|
}
|
||||||
|
|
14
src/new.h
14
src/new.h
@ -2,22 +2,16 @@
|
|||||||
#include <cstddef> // std::size_t
|
#include <cstddef> // std::size_t
|
||||||
|
|
||||||
[[deprecated]]
|
[[deprecated]]
|
||||||
inline void *operator new(size_t size)
|
void *operator new(size_t size);
|
||||||
{
|
|
||||||
return zmalloc(size, MALLOC_LOCAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void *operator new(size_t size, enum MALLOC_CLASS mclass)
|
inline void *operator new(size_t size, enum MALLOC_CLASS mclass)
|
||||||
{
|
{
|
||||||
return zmalloc(size, 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
|
inline void operator delete(void *p, std::size_t) noexcept
|
||||||
{
|
{
|
||||||
zfree(p);
|
zfree(p);
|
||||||
}
|
}
|
||||||
|
@ -276,4 +276,5 @@ redisReply *sendScan(unsigned long long *it);
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
#define KEYDB_REAL_VERSION "0.0.0"
|
#define KEYDB_REAL_VERSION "0.0.0"
|
||||||
extern const char *KEYDB_SET_VERSION; // Unlike real version, this can be overriden by the config
|
extern const char *KEYDB_SET_VERSION; // Unlike real version, this can be overriden by the config
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user