From fd46d44fefad3a8c65ffd6859c13348deed08182 Mon Sep 17 00:00:00 2001 From: John Sully Date: Thu, 21 Mar 2019 21:57:18 +0000 Subject: [PATCH 1/3] Compile issues at O0 optimization Former-commit-id: 27a420fbc2ada275376982b880dc8f6da935d53e --- deps/hiredis/sds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/hiredis/sds.h b/deps/hiredis/sds.h index 404f246c4..6b46297c2 100644 --- a/deps/hiredis/sds.h +++ b/deps/hiredis/sds.h @@ -83,7 +83,7 @@ struct __attribute__ ((__packed__)) sdshdr64 { #define SDS_HDR(T,s) ((struct sdshdr##T *)((s)-(sizeof(struct sdshdr##T)))) #define SDS_TYPE_5_LEN(f) ((f)>>SDS_TYPE_BITS) -inline size_t sdslen(const sds s) { +static inline size_t sdslen(const sds s) { unsigned char flags = s[-1]; switch(__builtin_expect((flags&SDS_TYPE_MASK), SDS_TYPE_5)) { From 4ed44398fdb484932bb0f5383a5056e103d21150 Mon Sep 17 00:00:00 2001 From: John Sully Date: Thu, 21 Mar 2019 22:17:04 +0000 Subject: [PATCH 2/3] Polarity of the weak flag was wrong. We want to use the strong variant of atomic_compare_exchange always Former-commit-id: ab9122f2cb910bb5560a9fde16bc3c096ecfb510 --- src/fastlock.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fastlock.cpp b/src/fastlock.cpp index 1a8d51165..6dd2893bb 100644 --- a/src/fastlock.cpp +++ b/src/fastlock.cpp @@ -113,7 +113,7 @@ extern "C" int fastlock_trylock(struct fastlock *lock) struct ticket ticket_expect { active, active }; struct ticket ticket_setiflocked { active, next }; - if (__atomic_compare_exchange(&lock->m_ticket, &ticket_expect, &ticket_setiflocked, true /*strong*/, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) + if (__atomic_compare_exchange(&lock->m_ticket, &ticket_expect, &ticket_setiflocked, false /*strong*/, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) { lock->m_depth = 1; __atomic_store_4(&lock->m_pidOwner, gettid(), __ATOMIC_RELEASE); @@ -147,4 +147,4 @@ extern "C" void fastlock_free(struct fastlock *lock) bool fastlock::fOwnLock() { return gettid() == m_pidOwner; -} \ No newline at end of file +} From 4def2bad94036c6c5a49567d5f9c0a00389660ad Mon Sep 17 00:00:00 2001 From: John Sully Date: Thu, 21 Mar 2019 22:18:48 +0000 Subject: [PATCH 3/3] comment issue Former-commit-id: 19956b3807aa6895b438162f39d17db17ef726f4 --- src/fastlock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fastlock.cpp b/src/fastlock.cpp index 6dd2893bb..dcbcff688 100644 --- a/src/fastlock.cpp +++ b/src/fastlock.cpp @@ -113,7 +113,7 @@ extern "C" int fastlock_trylock(struct fastlock *lock) struct ticket ticket_expect { active, active }; struct ticket ticket_setiflocked { active, next }; - if (__atomic_compare_exchange(&lock->m_ticket, &ticket_expect, &ticket_setiflocked, false /*strong*/, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) + if (__atomic_compare_exchange(&lock->m_ticket, &ticket_expect, &ticket_setiflocked, false /*weak*/, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) { lock->m_depth = 1; __atomic_store_4(&lock->m_pidOwner, gettid(), __ATOMIC_RELEASE);