sdlCompareAndSwapAtomicPointer function

bool sdlCompareAndSwapAtomicPointer(
  1. Pointer<Pointer<NativeType>> a,
  2. Pointer<NativeType> oldval,
  3. Pointer<NativeType> newval
)

Set a pointer to a new value if it is currently an old value.

Note: If you don't know what this function is for, you shouldn't use it!

\param a a pointer to a pointer. \param oldval the old pointer value. \param newval the new pointer value. \returns true if the pointer was set, false otherwise.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL 3.1.3.

\sa SDL_CompareAndSwapAtomicInt \sa SDL_GetAtomicPointer \sa SDL_SetAtomicPointer

extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicPointer(void **a, void *oldval, void *newval)

Implementation

bool sdlCompareAndSwapAtomicPointer(Pointer<Pointer<NativeType>> a,
    Pointer<NativeType> oldval, Pointer<NativeType> newval) {
  final sdlCompareAndSwapAtomicPointerLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Pointer<Pointer<NativeType>> a, Pointer<NativeType> oldval,
          Pointer<NativeType> newval),
      int Function(Pointer<Pointer<NativeType>> a, Pointer<NativeType> oldval,
          Pointer<NativeType> newval)>('SDL_CompareAndSwapAtomicPointer');
  return sdlCompareAndSwapAtomicPointerLookupFunction(a, oldval, newval) == 1;
}