summaryrefslogtreecommitdiff
path: root/src/upb_atomic.h
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-12-06 13:41:37 -0800
committerJoshua Haberman <joshua@reverberate.org>2009-12-06 13:41:37 -0800
commite15f834a916d64b80a0da9cdc4ee0bd4439b6bf4 (patch)
treeabd7dd38ceabf6aa75059551a0d339f6ed45cced /src/upb_atomic.h
parent08b4a91204ff7174c381f887d87878d8bb1181ff (diff)
Circular references truly work now, along with a test.
One simplification to come.
Diffstat (limited to 'src/upb_atomic.h')
-rw-r--r--src/upb_atomic.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/upb_atomic.h b/src/upb_atomic.h
index 22aa306..e425502 100644
--- a/src/upb_atomic.h
+++ b/src/upb_atomic.h
@@ -55,7 +55,8 @@ INLINE int upb_atomic_read(upb_atomic_refcount_t *a) {
}
INLINE bool upb_atomic_add(upb_atomic_refcount_t *a, int val) {
- return a->val += val;
+ a->val += val;
+ return a->val == 0;
}
typedef struct {
@@ -93,7 +94,7 @@ INLINE bool upb_atomic_ref(upb_atomic_refcount_t *a) {
}
INLINE bool upb_atomic_add(upb_atomic_refcount_t *a, int n) {
- return __sync_fetch_and_add(&a->val, n) == 0;
+ return __sync_add_and_fetch(&a->val, n) == 0;
}
INLINE bool upb_atomic_unref(upb_atomic_refcount_t *a) {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback