atomic.c File Reference
#include "atomic.h"
Include dependency graph for atomic.c:

Go to the source code of this file.

Functions

int avpriv_atomic_int_get (volatile int *ptr)
 Load the current value stored in an atomic integer. More...
 
void avpriv_atomic_int_set (volatile int *ptr, int val)
 Store a new value in an atomic integer. More...
 
int avpriv_atomic_int_add_and_fetch (volatile int *ptr, int inc)
 Add a value to an atomic integer. More...
 
voidavpriv_atomic_ptr_cas (void *volatile *ptr, void *oldval, void *newval)
 Atomic pointer compare and swap. More...
 

Function Documentation

int avpriv_atomic_int_add_and_fetch ( volatile int *  ptr,
int  inc 
)

Add a value to an atomic integer.

Parameters
ptratomic integer
incthe value to add to the atomic integer (may be negative)
Returns
the new value of the atomic integer.
Note
This does NOT act as a memory barrier. This is primarily intended for reference counting.

Definition at line 84 of file atomic.c.

Referenced by avpriv_atomic_ptr_cas().

int avpriv_atomic_int_get ( volatile int *  ptr)

Load the current value stored in an atomic integer.

Parameters
ptratomic integer
Returns
the current value of the atomic integer
Note
This acts as a memory barrier.

Definition at line 74 of file atomic.c.

Referenced by avpriv_atomic_ptr_cas().

void avpriv_atomic_int_set ( volatile int *  ptr,
int  val 
)

Store a new value in an atomic integer.

Parameters
ptratomic integer
valthe value to store in the atomic integer
Note
This acts as a memory barrier.

Definition at line 79 of file atomic.c.

Referenced by avpriv_atomic_ptr_cas().

void* avpriv_atomic_ptr_cas ( void *volatile *  ptr,
void oldval,
void newval 
)

Atomic pointer compare and swap.

Parameters
ptrpointer to the pointer to operate on
oldvaldo the swap if the current value of *ptr equals to oldval
newvalvalue to replace *ptr with
Returns
the value of *ptr before comparison

Definition at line 90 of file atomic.c.