This is an automated email from the git hooks/post-receive script.
firstyear pushed a commit to branch master
in repository libsds.
commit e48be5d9309069e597eab8ba6b042371031dcd2d
Author: William Brown <firstyear(a)redhat.com>
Date: Thu Feb 16 13:33:12 2017 +1000
Fix GCC operations to use correct atomics.
---
src/sds/bpt_cow/txn.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/sds/bpt_cow/txn.c b/src/sds/bpt_cow/txn.c
index 161478d..676a41f 100644
--- a/src/sds/bpt_cow/txn.c
+++ b/src/sds/bpt_cow/txn.c
@@ -6,6 +6,9 @@
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
+
+/* See also
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html */
+
/* ========================= WARNING ============================
* UNLESS YOU HAVE READ:
*
https://www.kernel.org/doc/Documentation/memory-barriers.txt
@@ -49,7 +52,7 @@ sds_bptree_txn_create(sds_bptree_cow_instance *binst) {
// The initial ref count is 0, and we only up to 1 when we commit.
// Atomically set this to 0.
- __sync_and_and_fetch(&(btxn->reference_count), 0);
+ __atomic_and_fetch(&(btxn->reference_count), 0, __ATOMIC_SEQ_CST);
#ifdef DEBUG
// Update our needed checksums
@@ -104,7 +107,7 @@ sds_bptree_txn_free(sds_bptree_transaction *btxn) {
static void
sds_bptree_txn_increment(sds_bptree_transaction *btxn) {
- __sync_add_and_fetch(&(btxn->reference_count), 1);
+ __atomic_add_fetch(&(btxn->reference_count), 1, __ATOMIC_SEQ_CST);
// PR_AtomicIncrement(&(btxn->reference_count));
#ifdef DEBUG
@@ -132,7 +135,7 @@ sds_bptree_txn_decrement(sds_bptree_transaction *btxn) {
// Atomic dec the counter.
// PR_AtomicDecrement returns the set value.
- uint32_t result = __sync_sub_and_fetch(&(btxn->reference_count), 1);
+ uint32_t result = __atomic_sub_fetch(&(btxn->reference_count), 1,
__ATOMIC_SEQ_CST);
/* WARNING: After this point, another thread MAY free btxn under us.
* You MUST *not* deref btxn after this point.
*/
@@ -162,7 +165,7 @@ sds_bptree_txn_decrement(sds_bptree_transaction *btxn) {
// 0. So we may only "miss" freeing a now zerod txn in this case,
// but we never free "too much";
if (btxn != NULL) {
- result = btxn->reference_count;
+ __atomic_load(&(btxn->reference_count), &result,
__ATOMIC_SEQ_CST);
}
}
pthread_mutex_unlock(binst->vacuum_lock);
@@ -384,7 +387,7 @@ sds_result sds_bptree_cow_wrtxn_commit(sds_bptree_transaction **btxn)
{
// Take the read lock now at the last possible moment.
pthread_rwlock_wrlock((*btxn)->binst->read_lock);
// Say we are alive and commited.
- __sync_add_and_fetch(&((*btxn)->reference_count), 1);
+ __atomic_add_fetch(&((*btxn)->reference_count), 1, __ATOMIC_SEQ_CST);
// Set it.
(*btxn)->binst->txn = *btxn;
// Update our parent to reference us.
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.