31# include <stdatomic.h>
34using std::atomic_uintptr_t;
35using std::memory_order_relaxed;
36using std::memory_order_acq_rel;
41#define VLC_STATIC_RC { \
42 .refs = (uintptr_t) 1 \
53 atomic_init(&rc->
refs, (uintptr_t)1);
55 rc->
refs = (uintptr_t)1;
62 uintptr_t prev = atomic_fetch_add_explicit(&rc->
refs, (uintptr_t)1,
63 memory_order_relaxed);
71 uintptr_t prev = atomic_fetch_sub_explicit(&rc->
refs, (uintptr_t)1,
72 memory_order_acq_rel);
82 return atomic_load_explicit(&rc->
refs, memory_order_relaxed);
#define VLC_API
Definition fourcc_gen.c:31
#define vlc_assert(pred)
Run-time assertion.
Definition vlc_common.h:292
Definition vlc_atomic.h:46
atomic_uintptr_t refs
Definition vlc_atomic.h:47
int vlc_atomic_timedwait(void *addr, unsigned val, vlc_tick_t deadline)
Waits on an address with a time-out.
Definition thread.c:92
static void vlc_atomic_rc_init(vlc_atomic_rc_t *rc)
Init the RC to 1.
Definition vlc_atomic.h:51
void vlc_atomic_wait(void *addr, unsigned val)
Waits on an address.
Definition thread.c:85
void vlc_atomic_notify_one(void *addr)
Wakes up one thread on an address.
Definition thread.c:75
static bool vlc_atomic_rc_dec(vlc_atomic_rc_t *rc)
Decrement the RC and return true if it reaches 0.
Definition vlc_atomic.h:70
static uintptr_t vlc_atomic_rc_get(const vlc_atomic_rc_t *rc)
Returns the current reference count.
Definition vlc_atomic.h:81
static void vlc_atomic_rc_inc(vlc_atomic_rc_t *rc)
Increment the RC.
Definition vlc_atomic.h:61
void vlc_atomic_notify_all(void *addr)
Wakes up all thread on an address.
Definition thread.c:80
This file is a collection of common definitions and types.
#define VLC_UNUSED(x)
Definition vlc_common.h:1047
int64_t vlc_tick_t
High precision date or time interval.
Definition vlc_tick.h:48