diff options
author | ed <ed@FreeBSD.org> | 2013-06-15 22:17:59 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2013-06-15 22:17:59 +0000 |
commit | 4ea862e26e350153cca8c335600598f96a5eb125 (patch) | |
tree | 2734778c4c71a8686f6d671583d475365b8bce00 /sbin/hastd | |
parent | 5a0c7f1b394753e0c2e389b6050c62f9b827b146 (diff) | |
download | FreeBSD-src-4ea862e26e350153cca8c335600598f96a5eb125.zip FreeBSD-src-4ea862e26e350153cca8c335600598f96a5eb125.tar.gz |
Let hastd use C11 atomics.
C11 atomics now work on all the architectures. Have at least a single
piece of software in our base system that uses C11 atomics. This
somewhat makes it less likely that we break it because of LLVM imports,
etc.
Diffstat (limited to 'sbin/hastd')
-rw-r--r-- | sbin/hastd/refcnt.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sbin/hastd/refcnt.h b/sbin/hastd/refcnt.h index 1246043..5e3fb34 100644 --- a/sbin/hastd/refcnt.h +++ b/sbin/hastd/refcnt.h @@ -32,24 +32,24 @@ #ifndef __REFCNT_H__ #define __REFCNT_H__ -#include <machine/atomic.h> +#include <stdatomic.h> #include "pjdlog.h" -typedef unsigned int refcnt_t; +typedef atomic_uint refcnt_t; static __inline void refcnt_init(refcnt_t *count, unsigned int v) { - *count = v; + atomic_init(count, v); } static __inline void refcnt_acquire(refcnt_t *count) { - atomic_add_acq_int(count, 1); + atomic_fetch_add_explicit(count, 1, memory_order_acquire); } static __inline unsigned int @@ -58,7 +58,7 @@ refcnt_release(refcnt_t *count) unsigned int old; /* XXX: Should this have a rel membar? */ - old = atomic_fetchadd_int(count, -1); + old = atomic_fetch_sub(count, 1); PJDLOG_ASSERT(old > 0); return (old - 1); } |