Path: blob/master/thirdparty/sdl/include/SDL3/SDL_atomic.h
9912 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021/**22* # CategoryAtomic23*24* Atomic operations.25*26* IMPORTANT: If you are not an expert in concurrent lockless programming, you27* should not be using any functions in this file. You should be protecting28* your data structures with full mutexes instead.29*30* ***Seriously, here be dragons!***31*32* You can find out a little more about lockless programming and the subtle33* issues that can arise here:34* https://learn.microsoft.com/en-us/windows/win32/dxtecharts/lockless-programming35*36* There's also lots of good information here:37*38* - https://www.1024cores.net/home/lock-free-algorithms39* - https://preshing.com/40*41* These operations may or may not actually be implemented using processor42* specific atomic operations. When possible they are implemented as true43* processor specific atomic operations. When that is not possible the are44* implemented using locks that *do* use the available atomic operations.45*46* All of the atomic operations that modify memory are full memory barriers.47*/4849#ifndef SDL_atomic_h_50#define SDL_atomic_h_5152#include <SDL3/SDL_stdinc.h>53#include <SDL3/SDL_platform_defines.h>5455#include <SDL3/SDL_begin_code.h>5657/* Set up for C function definitions, even when using C++ */58#ifdef __cplusplus59extern "C" {60#endif6162/**63* An atomic spinlock.64*65* The atomic locks are efficient spinlocks using CPU instructions, but are66* vulnerable to starvation and can spin forever if a thread holding a lock67* has been terminated. For this reason you should minimize the code executed68* inside an atomic lock and never do expensive things like API or system69* calls while holding them.70*71* They are also vulnerable to starvation if the thread holding the lock is72* lower priority than other threads and doesn't get scheduled. In general you73* should use mutexes instead, since they have better performance and74* contention behavior.75*76* The atomic locks are not safe to lock recursively.77*78* Porting Note: The spin lock functions and type are required and can not be79* emulated because they are used in the atomic emulation code.80*/81typedef int SDL_SpinLock;8283/**84* Try to lock a spin lock by setting it to a non-zero value.85*86* ***Please note that spinlocks are dangerous if you don't know what you're87* doing. Please be careful using any sort of spinlock!***88*89* \param lock a pointer to a lock variable.90* \returns true if the lock succeeded, false if the lock is already held.91*92* \threadsafety It is safe to call this function from any thread.93*94* \since This function is available since SDL 3.2.0.95*96* \sa SDL_LockSpinlock97* \sa SDL_UnlockSpinlock98*/99extern SDL_DECLSPEC bool SDLCALL SDL_TryLockSpinlock(SDL_SpinLock *lock);100101/**102* Lock a spin lock by setting it to a non-zero value.103*104* ***Please note that spinlocks are dangerous if you don't know what you're105* doing. Please be careful using any sort of spinlock!***106*107* \param lock a pointer to a lock variable.108*109* \threadsafety It is safe to call this function from any thread.110*111* \since This function is available since SDL 3.2.0.112*113* \sa SDL_TryLockSpinlock114* \sa SDL_UnlockSpinlock115*/116extern SDL_DECLSPEC void SDLCALL SDL_LockSpinlock(SDL_SpinLock *lock);117118/**119* Unlock a spin lock by setting it to 0.120*121* Always returns immediately.122*123* ***Please note that spinlocks are dangerous if you don't know what you're124* doing. Please be careful using any sort of spinlock!***125*126* \param lock a pointer to a lock variable.127*128* \threadsafety It is safe to call this function from any thread.129*130* \since This function is available since SDL 3.2.0.131*132* \sa SDL_LockSpinlock133* \sa SDL_TryLockSpinlock134*/135extern SDL_DECLSPEC void SDLCALL SDL_UnlockSpinlock(SDL_SpinLock *lock);136137138#ifdef SDL_WIKI_DOCUMENTATION_SECTION139140/**141* Mark a compiler barrier.142*143* A compiler barrier prevents the compiler from reordering reads and writes144* to globally visible variables across the call.145*146* This macro only prevents the compiler from reordering reads and writes, it147* does not prevent the CPU from reordering reads and writes. However, all of148* the atomic operations that modify memory are full memory barriers.149*150* \threadsafety Obviously this macro is safe to use from any thread at any151* time, but if you find yourself needing this, you are probably152* dealing with some very sensitive code; be careful!153*154* \since This macro is available since SDL 3.2.0.155*/156#define SDL_CompilerBarrier() DoCompilerSpecificReadWriteBarrier()157158#elif defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__)159void _ReadWriteBarrier(void);160#pragma intrinsic(_ReadWriteBarrier)161#define SDL_CompilerBarrier() _ReadWriteBarrier()162#elif (defined(__GNUC__) && !defined(SDL_PLATFORM_EMSCRIPTEN)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))163/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */164#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory")165#elif defined(__WATCOMC__)166extern __inline void SDL_CompilerBarrier(void);167#pragma aux SDL_CompilerBarrier = "" parm [] modify exact [];168#else169#define SDL_CompilerBarrier() \170{ SDL_SpinLock _tmp = 0; SDL_LockSpinlock(&_tmp); SDL_UnlockSpinlock(&_tmp); }171#endif172173/**174* Insert a memory release barrier (function version).175*176* Please refer to SDL_MemoryBarrierRelease for details. This is a function177* version, which might be useful if you need to use this functionality from a178* scripting language, etc. Also, some of the macro versions call this179* function behind the scenes, where more heavy lifting can happen inside of180* SDL. Generally, though, an app written in C/C++/etc should use the macro181* version, as it will be more efficient.182*183* \threadsafety Obviously this function is safe to use from any thread at any184* time, but if you find yourself needing this, you are probably185* dealing with some very sensitive code; be careful!186*187* \since This function is available since SDL 3.2.0.188*189* \sa SDL_MemoryBarrierRelease190*/191extern SDL_DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void);192193/**194* Insert a memory acquire barrier (function version).195*196* Please refer to SDL_MemoryBarrierRelease for details. This is a function197* version, which might be useful if you need to use this functionality from a198* scripting language, etc. Also, some of the macro versions call this199* function behind the scenes, where more heavy lifting can happen inside of200* SDL. Generally, though, an app written in C/C++/etc should use the macro201* version, as it will be more efficient.202*203* \threadsafety Obviously this function is safe to use from any thread at any204* time, but if you find yourself needing this, you are probably205* dealing with some very sensitive code; be careful!206*207* \since This function is available since SDL 3.2.0.208*209* \sa SDL_MemoryBarrierAcquire210*/211extern SDL_DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void);212213214#ifdef SDL_WIKI_DOCUMENTATION_SECTION215216/**217* Insert a memory release barrier (macro version).218*219* Memory barriers are designed to prevent reads and writes from being220* reordered by the compiler and being seen out of order on multi-core CPUs.221*222* A typical pattern would be for thread A to write some data and a flag, and223* for thread B to read the flag and get the data. In this case you would224* insert a release barrier between writing the data and the flag,225* guaranteeing that the data write completes no later than the flag is226* written, and you would insert an acquire barrier between reading the flag227* and reading the data, to ensure that all the reads associated with the flag228* have completed.229*230* In this pattern you should always see a release barrier paired with an231* acquire barrier and you should gate the data reads/writes with a single232* flag variable.233*234* For more information on these semantics, take a look at the blog post:235* http://preshing.com/20120913/acquire-and-release-semantics236*237* This is the macro version of this functionality; if possible, SDL will use238* compiler intrinsics or inline assembly, but some platforms might need to239* call the function version of this, SDL_MemoryBarrierReleaseFunction to do240* the heavy lifting. Apps that can use the macro should favor it over the241* function.242*243* \threadsafety Obviously this macro is safe to use from any thread at any244* time, but if you find yourself needing this, you are probably245* dealing with some very sensitive code; be careful!246*247* \since This macro is available since SDL 3.2.0.248*249* \sa SDL_MemoryBarrierAcquire250* \sa SDL_MemoryBarrierReleaseFunction251*/252#define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction()253254/**255* Insert a memory acquire barrier (macro version).256*257* Please see SDL_MemoryBarrierRelease for the details on what memory barriers258* are and when to use them.259*260* This is the macro version of this functionality; if possible, SDL will use261* compiler intrinsics or inline assembly, but some platforms might need to262* call the function version of this, SDL_MemoryBarrierAcquireFunction, to do263* the heavy lifting. Apps that can use the macro should favor it over the264* function.265*266* \threadsafety Obviously this macro is safe to use from any thread at any267* time, but if you find yourself needing this, you are probably268* dealing with some very sensitive code; be careful!269*270* \since This macro is available since SDL 3.2.0.271*272* \sa SDL_MemoryBarrierRelease273* \sa SDL_MemoryBarrierAcquireFunction274*/275#define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction()276277#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))278#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory")279#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory")280#elif defined(__GNUC__) && defined(__aarch64__)281#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory")282#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory")283#elif defined(__GNUC__) && defined(__arm__)284#if 0 /* defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) */285/* Information from:286https://chromium.googlesource.com/chromium/chromium/+/trunk/base/atomicops_internals_arm_gcc.h#19287288The Linux kernel provides a helper function which provides the right code for a memory barrier,289hard-coded at address 0xffff0fa0290*/291typedef void (*SDL_KernelMemoryBarrierFunc)();292#define SDL_MemoryBarrierRelease() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)()293#define SDL_MemoryBarrierAcquire() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)()294#else295#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__)296#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory")297#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory")298#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__)299#ifdef __thumb__300/* The mcr instruction isn't available in thumb mode, use real functions */301#define SDL_MEMORY_BARRIER_USES_FUNCTION302#define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction()303#define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction()304#else305#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory")306#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory")307#endif /* __thumb__ */308#else309#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory")310#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory")311#endif /* SDL_PLATFORM_LINUX || SDL_PLATFORM_ANDROID */312#endif /* __GNUC__ && __arm__ */313#else314#if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))315/* This is correct for all CPUs on Solaris when using Solaris Studio 12.1+. */316#include <mbarrier.h>317#define SDL_MemoryBarrierRelease() __machine_rel_barrier()318#define SDL_MemoryBarrierAcquire() __machine_acq_barrier()319#else320/* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */321#define SDL_MemoryBarrierRelease() SDL_CompilerBarrier()322#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier()323#endif324#endif325326/* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */327#ifdef SDL_WIKI_DOCUMENTATION_SECTION328329/**330* A macro to insert a CPU-specific "pause" instruction into the program.331*332* This can be useful in busy-wait loops, as it serves as a hint to the CPU as333* to the program's intent; some CPUs can use this to do more efficient334* processing. On some platforms, this doesn't do anything, so using this335* macro might just be a harmless no-op.336*337* Note that if you are busy-waiting, there are often more-efficient338* approaches with other synchronization primitives: mutexes, semaphores,339* condition variables, etc.340*341* \threadsafety This macro is safe to use from any thread.342*343* \since This macro is available since SDL 3.2.0.344*/345#define SDL_CPUPauseInstruction() DoACPUPauseInACompilerAndArchitectureSpecificWay346347#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))348#define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */349#elif (defined(__arm__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__aarch64__)350#define SDL_CPUPauseInstruction() __asm__ __volatile__("yield" ::: "memory")351#elif (defined(__powerpc__) || defined(__powerpc64__))352#define SDL_CPUPauseInstruction() __asm__ __volatile__("or 27,27,27");353#elif (defined(__riscv) && __riscv_xlen == 64)354#define SDL_CPUPauseInstruction() __asm__ __volatile__(".insn i 0x0F, 0, x0, x0, 0x010");355#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))356#define SDL_CPUPauseInstruction() _mm_pause() /* this is actually "rep nop" and not a SIMD instruction. No inline asm in MSVC x86-64! */357#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))358#define SDL_CPUPauseInstruction() __yield()359#elif defined(__WATCOMC__) && defined(__386__)360extern __inline void SDL_CPUPauseInstruction(void);361#pragma aux SDL_CPUPauseInstruction = ".686p" ".xmm2" "pause"362#else363#define SDL_CPUPauseInstruction()364#endif365366367/**368* A type representing an atomic integer value.369*370* This can be used to manage a value that is synchronized across multiple371* CPUs without a race condition; when an app sets a value with372* SDL_SetAtomicInt all other threads, regardless of the CPU it is running on,373* will see that value when retrieved with SDL_GetAtomicInt, regardless of CPU374* caches, etc.375*376* This is also useful for atomic compare-and-swap operations: a thread can377* change the value as long as its current value matches expectations. When378* done in a loop, one can guarantee data consistency across threads without a379* lock (but the usual warnings apply: if you don't know what you're doing, or380* you don't do it carefully, you can confidently cause any number of381* disasters with this, so in most cases, you _should_ use a mutex instead of382* this!).383*384* This is a struct so people don't accidentally use numeric operations on it385* directly. You have to use SDL atomic functions.386*387* \since This struct is available since SDL 3.2.0.388*389* \sa SDL_CompareAndSwapAtomicInt390* \sa SDL_GetAtomicInt391* \sa SDL_SetAtomicInt392* \sa SDL_AddAtomicInt393*/394typedef struct SDL_AtomicInt { int value; } SDL_AtomicInt;395396/**397* Set an atomic variable to a new value if it is currently an old value.398*399* ***Note: If you don't know what this function is for, you shouldn't use400* it!***401*402* \param a a pointer to an SDL_AtomicInt variable to be modified.403* \param oldval the old value.404* \param newval the new value.405* \returns true if the atomic variable was set, false otherwise.406*407* \threadsafety It is safe to call this function from any thread.408*409* \since This function is available since SDL 3.2.0.410*411* \sa SDL_GetAtomicInt412* \sa SDL_SetAtomicInt413*/414extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicInt(SDL_AtomicInt *a, int oldval, int newval);415416/**417* Set an atomic variable to a value.418*419* This function also acts as a full memory barrier.420*421* ***Note: If you don't know what this function is for, you shouldn't use422* it!***423*424* \param a a pointer to an SDL_AtomicInt variable to be modified.425* \param v the desired value.426* \returns the previous value of the atomic variable.427*428* \threadsafety It is safe to call this function from any thread.429*430* \since This function is available since SDL 3.2.0.431*432* \sa SDL_GetAtomicInt433*/434extern SDL_DECLSPEC int SDLCALL SDL_SetAtomicInt(SDL_AtomicInt *a, int v);435436/**437* Get the value of an atomic variable.438*439* ***Note: If you don't know what this function is for, you shouldn't use440* it!***441*442* \param a a pointer to an SDL_AtomicInt variable.443* \returns the current value of an atomic variable.444*445* \threadsafety It is safe to call this function from any thread.446*447* \since This function is available since SDL 3.2.0.448*449* \sa SDL_SetAtomicInt450*/451extern SDL_DECLSPEC int SDLCALL SDL_GetAtomicInt(SDL_AtomicInt *a);452453/**454* Add to an atomic variable.455*456* This function also acts as a full memory barrier.457*458* ***Note: If you don't know what this function is for, you shouldn't use459* it!***460*461* \param a a pointer to an SDL_AtomicInt variable to be modified.462* \param v the desired value to add.463* \returns the previous value of the atomic variable.464*465* \threadsafety It is safe to call this function from any thread.466*467* \since This function is available since SDL 3.2.0.468*469* \sa SDL_AtomicDecRef470* \sa SDL_AtomicIncRef471*/472extern SDL_DECLSPEC int SDLCALL SDL_AddAtomicInt(SDL_AtomicInt *a, int v);473474#ifndef SDL_AtomicIncRef475476/**477* Increment an atomic variable used as a reference count.478*479* ***Note: If you don't know what this macro is for, you shouldn't use it!***480*481* \param a a pointer to an SDL_AtomicInt to increment.482* \returns the previous value of the atomic variable.483*484* \threadsafety It is safe to call this macro from any thread.485*486* \since This macro is available since SDL 3.2.0.487*488* \sa SDL_AtomicDecRef489*/490#define SDL_AtomicIncRef(a) SDL_AddAtomicInt(a, 1)491#endif492493#ifndef SDL_AtomicDecRef494495/**496* Decrement an atomic variable used as a reference count.497*498* ***Note: If you don't know what this macro is for, you shouldn't use it!***499*500* \param a a pointer to an SDL_AtomicInt to decrement.501* \returns true if the variable reached zero after decrementing, false502* otherwise.503*504* \threadsafety It is safe to call this macro from any thread.505*506* \since This macro is available since SDL 3.2.0.507*508* \sa SDL_AtomicIncRef509*/510#define SDL_AtomicDecRef(a) (SDL_AddAtomicInt(a, -1) == 1)511#endif512513/**514* A type representing an atomic unsigned 32-bit value.515*516* This can be used to manage a value that is synchronized across multiple517* CPUs without a race condition; when an app sets a value with518* SDL_SetAtomicU32 all other threads, regardless of the CPU it is running on,519* will see that value when retrieved with SDL_GetAtomicU32, regardless of CPU520* caches, etc.521*522* This is also useful for atomic compare-and-swap operations: a thread can523* change the value as long as its current value matches expectations. When524* done in a loop, one can guarantee data consistency across threads without a525* lock (but the usual warnings apply: if you don't know what you're doing, or526* you don't do it carefully, you can confidently cause any number of527* disasters with this, so in most cases, you _should_ use a mutex instead of528* this!).529*530* This is a struct so people don't accidentally use numeric operations on it531* directly. You have to use SDL atomic functions.532*533* \since This struct is available since SDL 3.2.0.534*535* \sa SDL_CompareAndSwapAtomicU32536* \sa SDL_GetAtomicU32537* \sa SDL_SetAtomicU32538*/539typedef struct SDL_AtomicU32 { Uint32 value; } SDL_AtomicU32;540541/**542* Set an atomic variable to a new value if it is currently an old value.543*544* ***Note: If you don't know what this function is for, you shouldn't use545* it!***546*547* \param a a pointer to an SDL_AtomicU32 variable to be modified.548* \param oldval the old value.549* \param newval the new value.550* \returns true if the atomic variable was set, false otherwise.551*552* \threadsafety It is safe to call this function from any thread.553*554* \since This function is available since SDL 3.2.0.555*556* \sa SDL_GetAtomicU32557* \sa SDL_SetAtomicU32558*/559extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicU32(SDL_AtomicU32 *a, Uint32 oldval, Uint32 newval);560561/**562* Set an atomic variable to a value.563*564* This function also acts as a full memory barrier.565*566* ***Note: If you don't know what this function is for, you shouldn't use567* it!***568*569* \param a a pointer to an SDL_AtomicU32 variable to be modified.570* \param v the desired value.571* \returns the previous value of the atomic variable.572*573* \threadsafety It is safe to call this function from any thread.574*575* \since This function is available since SDL 3.2.0.576*577* \sa SDL_GetAtomicU32578*/579extern SDL_DECLSPEC Uint32 SDLCALL SDL_SetAtomicU32(SDL_AtomicU32 *a, Uint32 v);580581/**582* Get the value of an atomic variable.583*584* ***Note: If you don't know what this function is for, you shouldn't use585* it!***586*587* \param a a pointer to an SDL_AtomicU32 variable.588* \returns the current value of an atomic variable.589*590* \threadsafety It is safe to call this function from any thread.591*592* \since This function is available since SDL 3.2.0.593*594* \sa SDL_SetAtomicU32595*/596extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAtomicU32(SDL_AtomicU32 *a);597598/**599* Set a pointer to a new value if it is currently an old value.600*601* ***Note: If you don't know what this function is for, you shouldn't use602* it!***603*604* \param a a pointer to a pointer.605* \param oldval the old pointer value.606* \param newval the new pointer value.607* \returns true if the pointer was set, false otherwise.608*609* \threadsafety It is safe to call this function from any thread.610*611* \since This function is available since SDL 3.2.0.612*613* \sa SDL_CompareAndSwapAtomicInt614* \sa SDL_GetAtomicPointer615* \sa SDL_SetAtomicPointer616*/617extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicPointer(void **a, void *oldval, void *newval);618619/**620* Set a pointer to a value atomically.621*622* ***Note: If you don't know what this function is for, you shouldn't use623* it!***624*625* \param a a pointer to a pointer.626* \param v the desired pointer value.627* \returns the previous value of the pointer.628*629* \threadsafety It is safe to call this function from any thread.630*631* \since This function is available since SDL 3.2.0.632*633* \sa SDL_CompareAndSwapAtomicPointer634* \sa SDL_GetAtomicPointer635*/636extern SDL_DECLSPEC void * SDLCALL SDL_SetAtomicPointer(void **a, void *v);637638/**639* Get the value of a pointer atomically.640*641* ***Note: If you don't know what this function is for, you shouldn't use642* it!***643*644* \param a a pointer to a pointer.645* \returns the current value of a pointer.646*647* \threadsafety It is safe to call this function from any thread.648*649* \since This function is available since SDL 3.2.0.650*651* \sa SDL_CompareAndSwapAtomicPointer652* \sa SDL_SetAtomicPointer653*/654extern SDL_DECLSPEC void * SDLCALL SDL_GetAtomicPointer(void **a);655656/* Ends C function definitions when using C++ */657#ifdef __cplusplus658}659#endif660661#include <SDL3/SDL_close_code.h>662663#endif /* SDL_atomic_h_ */664665666