00001 /* 00002 SDL - Simple DirectMedia Layer 00003 Copyright (C) 1997-2006 Sam Lantinga 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 Sam Lantinga 00020 slouken@libsdl.org 00021 00022 Contributed by Bob Pendleton, bob@pendleton.com 00023 */ 00024 00031 #ifndef _SDL_atomic_h_ 00032 #define _SDL_atomic_h_ 00033 00034 #include "SDL_stdinc.h" 00035 #include "SDL_platform.h" 00036 00037 #include "begin_code.h" 00038 00039 /* Set up for C function definitions, even when using C++ */ 00040 #ifdef __cplusplus 00041 /* *INDENT-OFF* */ 00042 extern "C" { 00043 /* *INDENT-ON* */ 00044 #endif 00045 00058 /* Function prototypes */ 00059 00067 typedef volatile Uint32 SDL_SpinLock; 00068 00077 extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); 00078 00087 extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); 00088 00089 /* 32 bit atomic operations */ 00090 00102 extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet32(volatile Uint32 * ptr); 00103 00112 extern DECLSPEC void SDLCALL SDL_AtomicClear32(volatile Uint32 * ptr); 00113 00125 extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr); 00126 00137 extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr); 00138 00150 extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value); 00151 00163 extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value); 00164 00175 extern DECLSPEC Uint32 SDLCALL SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr); 00176 00187 extern DECLSPEC Uint32 SDLCALL SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr); 00188 00200 extern DECLSPEC Uint32 SDLCALL SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value); 00201 00213 extern DECLSPEC Uint32 SDLCALL SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value); 00214 00215 /* 64 bit atomic operations */ 00216 #ifdef SDL_HAS_64BIT_TYPE 00217 00218 extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet64(volatile Uint64 * ptr); 00219 extern DECLSPEC void SDLCALL SDL_AtomicClear64(volatile Uint64 * ptr); 00220 extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr); 00221 extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr); 00222 extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value); 00223 extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value); 00224 extern DECLSPEC Uint64 SDLCALL SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr); 00225 extern DECLSPEC Uint64 SDLCALL SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr); 00226 extern DECLSPEC Uint64 SDLCALL SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value); 00227 extern DECLSPEC Uint64 SDLCALL SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value); 00228 #endif /* SDL_HAS_64BIT_TYPE */ 00229 00230 /* Ends C function definitions when using C++ */ 00231 #ifdef __cplusplus 00232 /* *INDENT-OFF* */ 00233 } 00234 /* *INDENT-ON* */ 00235 #endif 00236 00237 #include "close_code.h" 00238 00239 #endif /* _SDL_atomic_h_ */ 00240 00241 /* vi: set ts=4 sw=4 expandtab: */