mirror of
https://code.videolan.org/videolan/dav1d
synced 2026-06-11 04:03:05 +00:00
Use a relaxed memory ordering in dav1d_ref_inc()
Increasing a reference counter only requires atomicity, but not ordering or synchronization.
This commit is contained in:
committed by
Henrik Gramner
co-authored by
Henrik Gramner
parent
6d0d066654
commit
601bfe21b7
@@ -40,6 +40,7 @@ typedef unsigned int atomic_uint;
|
||||
#define atomic_load(p_a) __atomic_load_n(p_a, __ATOMIC_SEQ_CST)
|
||||
#define atomic_load_explicit(p_a, mo) __atomic_load_n(p_a, mo)
|
||||
#define atomic_fetch_add(p_a, inc) __atomic_fetch_add(p_a, inc, __ATOMIC_SEQ_CST)
|
||||
#define atomic_fetch_add_explicit(p_a, inc, mo) __atomic_fetch_add(p_a, inc, mo)
|
||||
#define atomic_fetch_sub(p_a, dec) __atomic_fetch_sub(p_a, dec, __ATOMIC_SEQ_CST)
|
||||
#define atomic_exchange(p_a, v) __atomic_exchange_n(p_a, v, __ATOMIC_SEQ_CST)
|
||||
#define atomic_fetch_or(p_a, v) __atomic_fetch_or(p_a, v, __ATOMIC_SEQ_CST)
|
||||
|
||||
@@ -62,6 +62,7 @@ typedef enum {
|
||||
#define atomic_fetch_add(p_a, inc) InterlockedExchangeAdd(p_a, inc)
|
||||
#define atomic_fetch_sub(p_a, dec) InterlockedExchangeAdd(p_a, -(dec))
|
||||
#define atomic_fetch_or(p_a, v) InterlockedOr(p_a, v)
|
||||
#define atomic_fetch_add_explicit(p_a, inc, mo) atomic_fetch_add(p_a, inc)
|
||||
|
||||
#endif /* ! stdatomic.h */
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ void dav1d_ref_dec(Dav1dRef **ref);
|
||||
int dav1d_ref_is_writable(Dav1dRef *ref);
|
||||
|
||||
static inline void dav1d_ref_inc(Dav1dRef *const ref) {
|
||||
atomic_fetch_add(&ref->ref_cnt, 1);
|
||||
atomic_fetch_add_explicit(&ref->ref_cnt, 1, memory_order_relaxed);
|
||||
}
|
||||
|
||||
#endif /* DAV1D_SRC_REF_H */
|
||||
|
||||
Reference in New Issue
Block a user