summaryrefslogtreecommitdiff
path: root/kern/syscnt.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/syscnt.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/syscnt.h')
-rw-r--r--kern/syscnt.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/kern/syscnt.h b/kern/syscnt.h
index fef8115c..c28f3b52 100644
--- a/kern/syscnt.h
+++ b/kern/syscnt.h
@@ -26,9 +26,9 @@
#include <stdint.h>
+#include <kern/atomic.h>
#include <kern/macros.h>
#include <kern/spinlock.h>
-#include <machine/atomic.h>
/*
* Size of the buffer storing a system counter name.
@@ -57,21 +57,21 @@ void syscnt_setup(void);
*/
void syscnt_register(struct syscnt *syscnt, const char *name);
-#ifdef __LP64__
+#ifdef ATOMIC_HAVE_64B_OPS
static inline void
syscnt_add(struct syscnt *syscnt, int64_t delta)
{
- atomic_add_ulong(&syscnt->value, delta);
+ atomic_add(&syscnt->value, delta, ATOMIC_SEQ_CST);
}
static inline uint64_t
syscnt_read(const struct syscnt *syscnt)
{
- return read_once(syscnt->value);
+ return atomic_load((uint64_t *)&syscnt->value, ATOMIC_RELAXED);
}
-#else /* __LP64__ */
+#else /* ATOMIC_HAVE_64B_OPS */
static inline void
syscnt_add(struct syscnt *syscnt, int64_t delta)
@@ -96,7 +96,7 @@ syscnt_read(struct syscnt *syscnt)
return value;
}
-#endif /* __LP64__ */
+#endif /* ATOMIC_HAVE_64B_OPS */
static inline void
syscnt_inc(struct syscnt *syscnt)