table of contents
other versions
- wheezy 0.11.1-2
- jessie 0.11.1-2
- jessie-backports 1.0-1~bpo8+1
- testing 1.0.1-1
- unstable 1.0.1-1
| qbatomic.h(3) | libqb | qbatomic.h(3) |
NAME¶
qbatomic.h - Basic atomic integer and pointer operations.SYNOPSIS¶
#include <stdint.h>Defines¶
#define qb_atomic_int_get(atomic)
Functions¶
void qb_atomic_init (void)
Detailed Description¶
Basic atomic integer and pointer operations.Define Documentation¶
#define qb_atomic_int_dec_and_test(atomic) (qb_atomic_int_exchange_and_add ((atomic), -1) == 1)¶
Atomically decrements the integer pointed to by atomic by 1. Parameters:atomic a pointer to an integer
Returns:
QB_TRUE if the integer pointed to by atomic is
0 after decrementing it
#define qb_atomic_int_get(atomic) Value:¶
((void) sizeof (char* [sizeof (*(atomic)) == sizeof (int32_t) ? 1 : -1]), (qb_atomic_int_get) ((volatile int32_t QB_GNUC_MAY_ALIAS *) (volatile void *) (atomic)))
#define qb_atomic_int_inc(atomic) (qb_atomic_int_add ((atomic), 1))¶
Atomically increments the integer pointed to by atomic by 1. Parameters:atomic a pointer to an integer.
#define qb_atomic_int_set(atomic, newval) Value:¶
((void) sizeof (char* [sizeof (*(atomic)) == sizeof (int32_t) ? 1 : -1]), (qb_atomic_int_set) ((volatile int32_t QB_GNUC_MAY_ALIAS *) (volatile void *) (atomic), (newval)))
#define qb_atomic_pointer_get(atomic) Value:¶
((void) sizeof (char* [sizeof (*(atomic)) == sizeof (void*) ? 1 : -1]), (qb_atomic_pointer_get) ((volatile void* QB_GNUC_MAY_ALIAS *) (volatile void *) (atomic)))
#define qb_atomic_pointer_set(atomic, newval) Value:¶
((void) sizeof (char* [sizeof (*(atomic)) == sizeof (void*) ? 1 : -1]), (qb_atomic_pointer_set) ((volatile void* QB_GNUC_MAY_ALIAS *) (volatile void *) (atomic), (newval)))
Function Documentation¶
void qb_atomic_init (void)¶
void qb_atomic_int_add (volatile int32_t QB_GNUC_MAY_ALIAS *atomic, int32_tval)¶
Atomically adds val to the integer pointed to by atomic. Also acts as a memory barrier. Parameters:atomic a pointer to an integer
val the value to add to *atomic
int32_t qb_atomic_int_compare_and_exchange (volatile int32_t QB_GNUC_MAY_ALIAS *atomic, int32_toldval, int32_tnewval)¶
Compares oldval with the integer pointed to by atomic and if they are equal, atomically exchanges *atomic with newval. Also acts as a memory barrier. Parameters:atomic a pointer to an integer
oldval the assumed old value of *atomic
newval the new value of *atomic
Returns:
QB_TRUE, if *atomic was equal oldval. QB_FALSE
otherwise.
int32_t qb_atomic_int_exchange_and_add (volatile int32_t QB_GNUC_MAY_ALIAS *atomic, int32_tval)¶
Atomically adds val to the integer pointed to by atomic. It returns the value of *atomic just before the addition took place. Also acts as a memory barrier. Parameters:atomic a pointer to an integer
val the value to add to *atomic
Returns:
the value of *atomic before the
addition.
int32_t qb_atomic_int_get (volatile int32_t QB_GNUC_MAY_ALIAS *atomic)¶
Reads the value of the integer pointed to by atomic. Also acts as a memory barrier. Parameters:atomic a pointer to an integer
Returns:
the value of atomic
void qb_atomic_int_set (volatile int32_t QB_GNUC_MAY_ALIAS *atomic, int32_tnewval)¶
Sets the value of the integer pointed to by atomic. Also acts as a memory barrier. Parameters:atomic a pointer to an integer
newval the new value
int32_t qb_atomic_pointer_compare_and_exchange (volatile void * QB_GNUC_MAY_ALIAS *atomic, void *oldval, void *newval)¶
Compares oldval with the pointer pointed to by atomic and if they are equal, atomically exchanges *atomic with newval. Also acts as a memory barrier. Parameters:atomic a pointer to a void*
oldval the assumed old value of *atomic
newval the new value of *atomic
Returns:
QB_TRUE if atomic was equal oldval, else
QB_FALSE.
void* qb_atomic_pointer_get (volatile void *QB_GNUC_MAY_ALIAS *atomic)¶
Reads the value of the pointer pointed to by atomic. Also acts as a memory barrier. Parameters:atomic a pointer to a void*.
Returns:
the value to add to atomic.
void qb_atomic_pointer_set (volatile void *QB_GNUC_MAY_ALIAS *atomic, void *newval)¶
Sets the value of the pointer pointed to by atomic. Also acts as a memory barrier. Parameters:atomic a pointer to a void*
newval the new value
Author¶
Generated automatically by Doxygen for libqb from the source code.| Tue Apr 3 2012 | Version 0.11.1 |