diff options
Diffstat (limited to 'upb')
-rw-r--r-- | upb/refcounted.c | 2 | ||||
-rw-r--r-- | upb/refcounted.h | 11 | ||||
-rw-r--r-- | upb/table.c | 1 |
3 files changed, 9 insertions, 5 deletions
diff --git a/upb/refcounted.c b/upb/refcounted.c index cba535f..ca97d9f 100644 --- a/upb/refcounted.c +++ b/upb/refcounted.c @@ -35,7 +35,7 @@ const void *UPB_UNTRACKED_REF = &untracked_val; static void atomic_inc(uint32_t *a) { (*a)++; } static bool atomic_dec(uint32_t *a) { return --(*a) == 0; } -#elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || __GNUC__ > 4 /////////////////// +#elif defined(__GNUC__) || defined(__clang__) ////////////////////////////////// static void atomic_inc(uint32_t *a) { __sync_fetch_and_add(a, 1); } static bool atomic_dec(uint32_t *a) { return __sync_sub_and_fetch(a, 1) == 0; } diff --git a/upb/refcounted.h b/upb/refcounted.h index 42251b1..3de4a12 100644 --- a/upb/refcounted.h +++ b/upb/refcounted.h @@ -21,10 +21,13 @@ #include "upb/table.int.h" -// Reference tracking is designed to be used with a tool like Valgrind; when -// enabled, it will cause reference leaks to show up as actual memory leaks -// that are attributed to the code that leaked the ref, *not* the code that -// originally created the object. +// Reference tracking will check ref()/unref() operations to make sure the +// ref ownership is correct. Where possible it will also make tools like +// Valgrind attribute ref leaks to the code that took the leaked ref, not +// the code that originally created the object. +// +// Enabling this requires the application to define upb_lock()/upb_unlock() +// functions that acquire/release a global mutex (or #define UPB_THREAD_UNSAFE). #ifndef NDEBUG #define UPB_DEBUG_REFS #endif diff --git a/upb/table.c b/upb/table.c index e0cac64..3fd4b0f 100644 --- a/upb/table.c +++ b/upb/table.c @@ -112,6 +112,7 @@ static bool lookup(const upb_table *t, upb_tabkey key, upb_value *v, // The given key must not already exist in the table. static void insert(upb_table *t, upb_tabkey key, upb_value val, hashfunc_t *hash, eqlfunc_t *eql) { + UPB_UNUSED(eql); assert(findentry(t, key, hash, eql) == NULL); assert(val.ctype == t->ctype); t->count++; |