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 = ATOMIC_VAR_INIT(0) \
52 atomic_init(&rc->
refs, (uintptr_t)1);
58 uintptr_t prev = atomic_fetch_add_explicit(&rc->
refs, (uintptr_t)1,
59 memory_order_relaxed);
67 uintptr_t prev = atomic_fetch_sub_explicit(&rc->
refs, (uintptr_t)1,
68 memory_order_acq_rel);
78 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:301
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
int vlc_atomic_timedwait_daytime(void *addr, unsigned val, time_t deadline)
Definition: thread.c:133
struct vlc_atomic_rc_t vlc_atomic_rc_t
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:66
static uintptr_t vlc_atomic_rc_get(const vlc_atomic_rc_t *rc)
Returns the current reference count.
Definition: vlc_atomic.h:77
static void vlc_atomic_rc_inc(vlc_atomic_rc_t *rc)
Increment the RC.
Definition: vlc_atomic.h:57
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:1131
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_tick.h:45