Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Gramner <gramner@twoorioles.com>2022-04-28 16:58:13 +0300
committerHenrik Gramner <henrik@gramner.com>2022-04-28 17:17:08 +0300
commit601bfe21b7ad4397a8d12a3803f454b062279bc1 (patch)
treed8300a946bfbfc0f9177a2a48f1a555a9a62f386
parent6d0d066654d43d5eeffce958604c72d0c9cfbeed (diff)
Use a relaxed memory ordering in dav1d_ref_inc()
Increasing a reference counter only requires atomicity, but not ordering or synchronization.
-rw-r--r--include/compat/gcc/stdatomic.h1
-rw-r--r--include/compat/msvc/stdatomic.h1
-rw-r--r--src/ref.h2
3 files changed, 3 insertions, 1 deletions
diff --git a/include/compat/gcc/stdatomic.h b/include/compat/gcc/stdatomic.h
index 26e97d8..da38c52 100644
--- a/include/compat/gcc/stdatomic.h
+++ b/include/compat/gcc/stdatomic.h
@@ -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)
diff --git a/include/compat/msvc/stdatomic.h b/include/compat/msvc/stdatomic.h
index 4154da0..cd04a38 100644
--- a/include/compat/msvc/stdatomic.h
+++ b/include/compat/msvc/stdatomic.h
@@ -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 */
diff --git a/src/ref.h b/src/ref.h
index f6e3028..ec070a0 100644
--- a/src/ref.h
+++ b/src/ref.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 */