spa: Fix SPA_LOAD_ONCE and SPA_STORE_ONCE atomic macros

These expected pointer to variables instead of variables directly, which
is inconsistent with how the other atomic macros behave. Furthermore,
SPA_STORE_ONCE was plain broken, since the underlying operation expects
an additional argument that was not included.
This commit is contained in:
Carlos Rafael Giani 2026-02-21 14:38:23 +01:00
parent 551eb0a473
commit 67ac1d101b
2 changed files with 4 additions and 4 deletions

View file

@ -143,8 +143,8 @@ SPA_API_POD_BODY int spa_pod_is_bool(const struct spa_pod *pod)
return SPA_POD_CHECK(pod, SPA_TYPE_Bool, sizeof(int32_t));
}
#define SPA_POD_BODY_LOAD_ONCE(a, b) (*(a) = SPA_LOAD_ONCE((__typeof__(a))(b)))
#define SPA_POD_BODY_LOAD_FIELD_ONCE(a, b, field) ((a)->field = SPA_LOAD_ONCE(&((__typeof__(a))(b))->field))
#define SPA_POD_BODY_LOAD_ONCE(a, b) (*(a) = SPA_LOAD_ONCE(*(__typeof__(a))(b)))
#define SPA_POD_BODY_LOAD_FIELD_ONCE(a, b, field) ((a)->field = SPA_LOAD_ONCE(((__typeof__(a))(b))->field))
SPA_API_POD_BODY int spa_pod_body_get_bool(const struct spa_pod *pod, const void *body, bool *value)
{

View file

@ -19,8 +19,8 @@ extern "C" {
#define SPA_ATOMIC_DEC(s) __atomic_sub_fetch(&(s), 1, __ATOMIC_SEQ_CST)
#define SPA_ATOMIC_INC(s) __atomic_add_fetch(&(s), 1, __ATOMIC_SEQ_CST)
#define SPA_ATOMIC_LOAD(s) __atomic_load_n(&(s), __ATOMIC_SEQ_CST)
#define SPA_LOAD_ONCE(s) __atomic_load_n((s), __ATOMIC_RELAXED)
#define SPA_STORE_ONCE(s) __atomic_store_n((s), __ATOMIC_RELAXED)
#define SPA_LOAD_ONCE(s) __atomic_load_n(&(s), __ATOMIC_RELAXED)
#define SPA_STORE_ONCE(s,v) __atomic_store_n(&(s), (v), __ATOMIC_RELAXED)
#define SPA_ATOMIC_STORE(s,v) __atomic_store_n(&(s), (v), __ATOMIC_SEQ_CST)
#define SPA_ATOMIC_XCHG(s,v) __atomic_exchange_n(&(s), (v), __ATOMIC_SEQ_CST)