/Users/hercules/trunk/SDL/include/SDL_atomic.h File Reference

#include "SDL_stdinc.h"
#include "SDL_platform.h"
#include "begin_code.h"
#include "close_code.h"

Go to the source code of this file.

Typedefs

typedef volatile Uint32 SDL_SpinLock

Functions

DECLSPEC void SDLCALL SDL_AtomicLock (SDL_SpinLock *lock)
 Lock a spin lock by setting it to a none zero value.
DECLSPEC void SDLCALL SDL_AtomicUnlock (SDL_SpinLock *lock)
 Unlock a spin lock by setting it to 0. Always returns immediately.
DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet32 (volatile Uint32 *ptr)
 Check to see if *ptr == 0 and set it to 1.
DECLSPEC void SDLCALL SDL_AtomicClear32 (volatile Uint32 *ptr)
 set the value pointed to by ptr to be zero.
DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenIncrement32 (volatile Uint32 *ptr)
 fetch the current value of *ptr and then increment that value in place.
DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenDecrement32 (volatile Uint32 *ptr)
 fetch *ptr and then decrement the value in place.
DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenAdd32 (volatile Uint32 *ptr, Uint32 value)
 fetch the current value at ptr and then add value to *ptr.
DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenSubtract32 (volatile Uint32 *ptr, Uint32 value)
 Fetch *ptr and then subtract value from it.
DECLSPEC Uint32 SDLCALL SDL_AtomicIncrementThenFetch32 (volatile Uint32 *ptr)
 Add one to the data pointed to by ptr and return that value.
DECLSPEC Uint32 SDLCALL SDL_AtomicDecrementThenFetch32 (volatile Uint32 *ptr)
 Subtract one from data pointed to by ptr and return the new value.
DECLSPEC Uint32 SDLCALL SDL_AtomicAddThenFetch32 (volatile Uint32 *ptr, Uint32 value)
 Add value to the data pointed to by ptr and return result.
DECLSPEC Uint32 SDLCALL SDL_AtomicSubtractThenFetch32 (volatile Uint32 *ptr, Uint32 value)
 Subtract value from the data pointed to by ptr and return the result.
DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet64 (volatile Uint64 *ptr)
DECLSPEC void SDLCALL SDL_AtomicClear64 (volatile Uint64 *ptr)
DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenIncrement64 (volatile Uint64 *ptr)
DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenDecrement64 (volatile Uint64 *ptr)
DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenAdd64 (volatile Uint64 *ptr, Uint64 value)
DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenSubtract64 (volatile Uint64 *ptr, Uint64 value)
DECLSPEC Uint64 SDLCALL SDL_AtomicIncrementThenFetch64 (volatile Uint64 *ptr)
DECLSPEC Uint64 SDLCALL SDL_AtomicDecrementThenFetch64 (volatile Uint64 *ptr)
DECLSPEC Uint64 SDLCALL SDL_AtomicAddThenFetch64 (volatile Uint64 *ptr, Uint64 value)
DECLSPEC Uint64 SDLCALL SDL_AtomicSubtractThenFetch64 (volatile Uint64 *ptr, Uint64 value)


Detailed Description

Atomic operations.

Typedef Documentation

typedef volatile Uint32 SDL_SpinLock

These operations may, or may not, actually be implemented using processor specific atomic operations. When possible they are implemented as true processor specific atomic operations. When that is not possible the are implemented using locks that *do* use the available atomic operations.

At the very minimum spin locks must be implemented. Without spin locks it is not possible (AFAICT) to emulate the rest of the atomic operations. SDL AtomicLock.

The spin lock functions and type are required and can not be emulated because they are used in the emulation code.


Function Documentation

Uint32 SDL_AtomicAddThenFetch32 ( volatile Uint32 ptr,
Uint32  value 
)

Add value to the data pointed to by ptr and return result.

Returns:
The sum of *ptr and value.
Parameters:
ptr The address of the data to be modified.
value The value to be added.

void SDL_AtomicClear32 ( volatile Uint32 ptr  ) 

set the value pointed to by ptr to be zero.

Parameters:
ptr address of the value to be set to zero

Uint32 SDL_AtomicDecrementThenFetch32 ( volatile Uint32 ptr  ) 

Subtract one from data pointed to by ptr and return the new value.

Returns:
The decremented value.
Parameters:
ptr The address of the data to decrement.

Uint32 SDL_AtomicFetchThenAdd32 ( volatile Uint32 ptr,
Uint32  value 
)

fetch the current value at ptr and then add value to *ptr.

Returns:
*ptr before the addition took place.
Parameters:
ptr the address of data we are changing.
value the value to add to *ptr.

Uint32 SDL_AtomicFetchThenDecrement32 ( volatile Uint32 ptr  ) 

fetch *ptr and then decrement the value in place.

Returns:
the value before it was decremented.
Parameters:
ptr address of the value to fetch and drement

Uint32 SDL_AtomicFetchThenIncrement32 ( volatile Uint32 ptr  ) 

fetch the current value of *ptr and then increment that value in place.

Returns:
the value before it was incremented.
Parameters:
ptr address of the value to fetch and increment

Uint32 SDL_AtomicFetchThenSubtract32 ( volatile Uint32 ptr,
Uint32  value 
)

Fetch *ptr and then subtract value from it.

Returns:
*ptr before the subtraction took place.
Parameters:
ptr the address of the data being changed.
value the value to subtract from *ptr.

Uint32 SDL_AtomicIncrementThenFetch32 ( volatile Uint32 ptr  ) 

Add one to the data pointed to by ptr and return that value.

Returns:
the incremented value.
Parameters:
ptr address of the data to increment.

void SDL_AtomicLock ( SDL_SpinLock lock  ) 

Lock a spin lock by setting it to a none zero value.

Parameters:
lock points to the lock.

Uint32 SDL_AtomicSubtractThenFetch32 ( volatile Uint32 ptr,
Uint32  value 
)

Subtract value from the data pointed to by ptr and return the result.

Returns:
the difference between *ptr and value.
Parameters:
ptr The address of the data to be modified.
value The value to be subtracted.

SDL_bool SDL_AtomicTestThenSet32 ( volatile Uint32 ptr  ) 

Check to see if *ptr == 0 and set it to 1.

Returns:
SDL_True if the value pointed to by ptr was zero and SDL_False if it was not zero
Parameters:
ptr points to the value to be tested and set.

void SDL_AtomicUnlock ( SDL_SpinLock lock  ) 

Unlock a spin lock by setting it to 0. Always returns immediately.

Parameters:
lock points to the lock.


Generated on Mon Sep 21 21:32:25 2009 for Simple DirectMedia Layer by  doxygen 1.5.8