psl1ght
A free SDK for Sony's PS3 console
Data Structures | Macros | Functions
atomic.h File Reference

Atomic Operations. More...

#include <ppu-types.h>

Go to the source code of this file.

Data Structures

struct  atomic_t
 
struct  atomic64_t
 

Macros

#define sysAtomicAddNegative(a, v)   (sysAtomicAddReturn((a), (v)) < 0)
 
#define sysAtomicIncAndTest(v)   (sysAtomicIncReturn(v) == 0)
 
#define xchg(ptr, x)
 
#define cmpxchg(ptr, o, n)
 
#define sysAtomicCompareAndSwap(v, o, n)   (cmpxchg(&((v)->counter), (o), (n)))
 
#define sysAtomicSwap(v, new)   (xchg(&((v)->counter), new))
 
#define sysAtomicIncNotZero(v)   sysAtomicAddUnless((v), 1, 0)
 
#define sysAtomicSubAndTest(a, v)   (sysAtomicSubReturn((a), (v)) == 0)
 
#define sysAtomicDecAndTest(v)   (sysAtomicDecReturn((v)) == 0)
 
#define sysAtomic64AddNegative(a, v)   (sysAtomic64AddReturn((a), (v)) < 0)
 
#define sysAtomic64IncAndTest(v)   (sysAtomic64IncReturn(v) == 0)
 
#define sysAtomic64SubAndTest(a, v)   (sysAtomic64SubReturn((a), (v)) == 0)
 
#define sysAtomic64DecAndTest(v)   (sysAtomic64DecReturn((v)) == 0)
 
#define sysAtomic64CompareAndSwap(v, o, n)   (cmpxchg(&((v)->counter), (o), (n)))
 
#define sysAtomic64Swap(v, new)   (xchg(&((v)->counter), new))
 
#define sysAtomic64IncNotZero(v)   sysAtomic64AddUnless((v), 1, 0)
 

Functions

static u32 sysAtomicRead (const atomic_t *v)
 
static void sysAtomicSet (atomic_t *v, int i)
 
static void sysAtomicAdd (u32 a, atomic_t *v)
 
static u32 sysAtomicAddReturn (u32 a, atomic_t *v)
 
static void sysAtomicSub (u32 a, atomic_t *v)
 
static u32 sysAtomicSubReturn (u32 a, atomic_t *v)
 
static void sysAtomicInc (atomic_t *v)
 
static u32 sysAtomicIncReturn (atomic_t *v)
 
static void sysAtomicDec (atomic_t *v)
 
static u32 sysAtomicDecReturn (atomic_t *v)
 
static u32 __xchg_u32 (volatile void *p, u32 val)
 
static u32 __xchg_u64 (volatile void *p, u32 val)
 
void __xchg_called_with_bad_pointer (void)
 
static u32 __xchg (volatile void *ptr, u32 x, unsigned int size)
 
static u64 __cmpxchg_u32 (volatile unsigned int *p, u64 old, u64 new)
 
static u64 __cmpxchg_u64 (volatile u64 *p, u64 old, u64 new)
 
void __cmpxchg_called_with_bad_pointer (void)
 
static u64 __cmpxchg (volatile void *ptr, u64 old, u64 new, unsigned int size)
 
static u32 sysAtomicAddUnless (atomic_t *v, u32 a, int u)
 
static u32 sysAtomicDecIfPositive (atomic_t *v)
 
static u64 sysAtomic64Read (const atomic64_t *v)
 
static void sysAtomic64Set (atomic64_t *v, u64 i)
 
static void sysAtomic64Add (u64 a, atomic64_t *v)
 
static u64 sysAtomic64AddReturn (u64 a, atomic64_t *v)
 
static void sysAtomic64Sub (u64 a, atomic64_t *v)
 
static u64 sysAtomic64SubReturn (u64 a, atomic64_t *v)
 
static void sysAtomic64Inc (atomic64_t *v)
 
static u64 sysAtomic64IncReturn (atomic64_t *v)
 
static void sysAtomic64Dec (atomic64_t *v)
 
static u64 sysAtomic64DecReturn (atomic64_t *v)
 
static u64 sysAtomic64DecIfPositive (atomic64_t *v)
 
static u32 sysAtomic64AddUnless (atomic64_t *v, u64 a, u64 u)
 

Detailed Description

Atomic Operations.

Macro Definition Documentation

◆ cmpxchg

#define cmpxchg (   ptr,
  o,
 
)
Value:
({ \
__typeof__(*(ptr)) _o_ = (o); \
__typeof__(*(ptr)) _n_ = (n); \
(__typeof__(*(ptr))) __cmpxchg((ptr), (u64)_o_, \
(u64)_n_, sizeof(*(ptr))); \
})

◆ xchg

#define xchg (   ptr,
 
)
Value:
({ \
__typeof__(*(ptr)) _x_ = (x); \
(__typeof__(*(ptr))) __xchg((ptr), (u32)_x_, sizeof(*(ptr))); \
})

Function Documentation

◆ sysAtomic64AddUnless()

static u32 sysAtomic64AddUnless ( atomic64_t v,
u64  a,
u64  u 
)
inlinestatic

atomic64_add_unless - add unless the number is a given value @v: pointer of type atomic64_t : the amount to add to v... @u: ...unless v is equal to u.

Atomically adds to @v, so u64 as it was not @u. Returns non-zero if @v was not @u, and zero otherwise.

◆ sysAtomicAddUnless()

static u32 sysAtomicAddUnless ( atomic_t v,
u32  a,
int  u 
)
inlinestatic

atomic_add_unless - add unless the number is a given value @v: pointer of type atomic_t : the amount to add to v... @u: ...unless v is equal to u.

Atomically adds to @v, so long as it was not @u. Returns non-zero if @v was not @u, and zero otherwise.