FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
atomic.c File Reference
#include "config.h"
#include "atomic.h"

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.
 
void avpriv_atomic_int_set (volatile int *ptr, int val)
 Store a new value in an atomic integer.
 
int avpriv_atomic_int_add_and_fetch (volatile int *ptr, int inc)
 Add a value to an atomic integer.
 
voidavpriv_atomic_ptr_cas (void *volatile *ptr, void *oldval, void *newval)
 Atomic pointer compare and swap.
 

Function Documentation

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 75 of file atomic.c.

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 80 of file atomic.c.

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 85 of file atomic.c.

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 91 of file atomic.c.