31# include <stdatomic.h>
34using std::atomic_uintptr_t;
35using std::memory_order_relaxed;
36using std::memory_order_acq_rel;
43#define VLC_STATIC_RC { \
44 .refs = (uintptr_t) 1 \
54 atomic_init(&rc->
refs, (uintptr_t)1);
60 uintptr_t prev = atomic_fetch_add_explicit(&rc->
refs, (uintptr_t)1,
61 memory_order_relaxed);
69 uintptr_t prev = atomic_fetch_sub_explicit(&rc->
refs, (uintptr_t)1,
70 memory_order_acq_rel);
80 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:290
Definition vlc_atomic.h:48
atomic_uintptr_t refs
Definition vlc_atomic.h:49
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:53
int vlc_atomic_timedwait_daytime(void *addr, unsigned val, time_t deadline)
Definition thread.c:133
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:68
static uintptr_t vlc_atomic_rc_get(const vlc_atomic_rc_t *rc)
Returns the current reference count.
Definition vlc_atomic.h:79
static void vlc_atomic_rc_inc(vlc_atomic_rc_t *rc)
Increment the RC.
Definition vlc_atomic.h:59
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:1045
int64_t vlc_tick_t
High precision date or time interval.
Definition vlc_tick.h:48