summaryrefslogtreecommitdiff
path: root/kern/sref.c
diff options
context:
space:
mode:
authorAgustina Arzille <avarzille@riseup.net>2017-04-03 16:09:51 +0200
committerRichard Braun <rbraun@sceen.net>2017-04-04 22:07:06 +0200
commitb1730c99f882fc2662c6b64371a4b11a8231bb9f (patch)
treec4fa5fa51287aee6d6cb372f1cfa8f6413ababd6 /kern/sref.c
parentd5bb14cf6a8305bda2a5a73ce727e5309996a20a (diff)
Use the new atomic operations interface
Stick to a sequentially consistent model for most atomic operations as it matches the semantics of the existing code. Each call site will have to be reevaluated in order to switch to more relaxed accesses where possible.
Diffstat (limited to 'kern/sref.c')
-rw-r--r--kern/sref.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/kern/sref.c b/kern/sref.c
index 4ae6ae1..23fb0ad 100644
--- a/kern/sref.c
+++ b/kern/sref.c
@@ -259,13 +259,13 @@ sref_weakref_init(struct sref_weakref *weakref, struct sref_counter *counter)
static void
sref_weakref_mark_dying(struct sref_weakref *weakref)
{
- atomic_or_uintptr(&weakref->addr, SREF_WEAKREF_DYING);
+ atomic_or(&weakref->addr, SREF_WEAKREF_DYING, ATOMIC_SEQ_CST);
}
static void
sref_weakref_clear_dying(struct sref_weakref *weakref)
{
- atomic_and_uintptr(&weakref->addr, SREF_WEAKREF_MASK);
+ atomic_and(&weakref->addr, SREF_WEAKREF_MASK, ATOMIC_SEQ_CST);
}
static int
@@ -274,7 +274,7 @@ sref_weakref_kill(struct sref_weakref *weakref)
uintptr_t addr, oldval;
addr = weakref->addr | SREF_WEAKREF_DYING;
- oldval = atomic_cas_uintptr(&weakref->addr, addr, (uintptr_t)NULL);
+ oldval = atomic_cas_seq_cst(&weakref->addr, addr, (uintptr_t)NULL);
if (oldval != addr) {
assert((oldval & SREF_WEAKREF_MASK) == (addr & SREF_WEAKREF_MASK));
@@ -292,7 +292,7 @@ sref_weakref_tryget(struct sref_weakref *weakref)
do {
addr = weakref->addr;
newval = addr & SREF_WEAKREF_MASK;
- oldval = atomic_cas_uintptr(&weakref->addr, addr, newval);
+ oldval = atomic_cas_seq_cst(&weakref->addr, addr, newval);
} while (oldval != addr);
return (struct sref_counter *)newval;