summaryrefslogtreecommitdiff
path: root/kern/semaphore_i.h
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/semaphore_i.h
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/semaphore_i.h')
-rw-r--r--kern/semaphore_i.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/kern/semaphore_i.h b/kern/semaphore_i.h
index c6769c1..9aa68e0 100644
--- a/kern/semaphore_i.h
+++ b/kern/semaphore_i.h
@@ -19,7 +19,7 @@
#define _KERN_SEMAPHORE_I_H
#include <kern/assert.h>
-#include <machine/atomic.h>
+#include <kern/atomic.h>
struct semaphore {
unsigned int value;
@@ -37,7 +37,7 @@ semaphore_dec(struct semaphore *semaphore)
break;
}
- prev = atomic_cas_uint(&semaphore->value, value, value - 1);
+ prev = atomic_cas_seq_cst(&semaphore->value, value, value - 1);
} while (prev != value);
return value;
@@ -48,7 +48,7 @@ semaphore_inc(struct semaphore *semaphore)
{
unsigned int prev;
- prev = atomic_fetchadd_uint(&semaphore->value, 1);
+ prev = atomic_fetch_add(&semaphore->value, 1, ATOMIC_SEQ_CST);
assert(prev != SEMAPHORE_VALUE_MAX);
return prev;
}