sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Atomic

Description

Atomic operations.

IMPORTANT: If you are not an expert in concurrent lockless programming, you should not be using any functions in this file. You should be protecting your data structures with full mutexes instead.

Seriously, here be dragons!

You can find out a little more about lockless programming and the subtle issues that can arise here: https://learn.microsoft.com/en-us/windows/win32/dxtecharts/lockless-programming

There's also lots of good information here:

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.

All of the atomic operations that modify memory are full memory barriers. An atomic spinlock.

The atomic locks are efficient spinlocks using CPU instructions, but are vulnerable to starvation and can spin forever if a thread holding a lock has been terminated. For this reason you should minimize the code executed inside an atomic lock and never do expensive things like API or system calls while holding them.

They are also vulnerable to starvation if the thread holding the lock is lower priority than other threads and doesn't get scheduled. In general you should use mutexes instead, since they have better performance and contention behavior.

The atomic locks are not safe to lock recursively.

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

FFI conventions

Unsuffixed aliases are unsafe foreign imports; aliases suffixed Safe are safe. Functions whose callbacks fire during the call export only the Safe alias (the genuine unsafe import stays reachable under SDL3.Sys.Bindgen.Atomic.Unsafe); functions curated unsafe-only export only the unsuffixed one. Each alias's documentation records its flavor and rationale.

The C shims are functions this package defines in C over what the FFI cannot call directly (variadic functions, function-like macros), each named after what it wraps; the same flavor rules apply. Their raw imports live under SDL3.Sys.Bindgen.AtomicShims.

Full conventions: SDL3.Sys.

Synopsis

Documentation

Function aliases

tryLockSpinlock Source #

Arguments

:: Ptr SDL_SpinLock
lock
a pointer to a lock variable.
-> IO Bool 

Try to lock a spin lock by setting it to a non-zero value.

Please note that spinlocks are dangerous if you don't know what you're doing. Please be careful using any sort of spinlock!

Returns
true if the lock succeeded, false if the lock is already held.
Thread safety
It is safe to call this function from any thread.
See also
lockSpinlock, unlockSpinlock

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_TryLockSpinlock. The safe flavor is tryLockSpinlockSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_TryLockSpinlock, defined at SDL3/SDL_atomic.h 100:34

Since: 3.2.0

tryLockSpinlockSafe Source #

Arguments

:: Ptr SDL_SpinLock
lock
a pointer to a lock variable.
-> IO Bool 

Try to lock a spin lock by setting it to a non-zero value.

Please note that spinlocks are dangerous if you don't know what you're doing. Please be careful using any sort of spinlock!

Returns
true if the lock succeeded, false if the lock is already held.
Thread safety
It is safe to call this function from any thread.
See also
lockSpinlock, unlockSpinlock

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_TryLockSpinlock. The unsafe flavor is tryLockSpinlock .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_TryLockSpinlock, defined at SDL3/SDL_atomic.h 100:34

Since: 3.2.0

lockSpinlock Source #

Arguments

:: Ptr SDL_SpinLock
lock
a pointer to a lock variable.
-> IO () 

Lock a spin lock by setting it to a non-zero value.

Please note that spinlocks are dangerous if you don't know what you're doing. Please be careful using any sort of spinlock!

Thread safety
It is safe to call this function from any thread.
See also
tryLockSpinlock, unlockSpinlock

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_LockSpinlock. The safe flavor is lockSpinlockSafe .
C declaration
SDL_LockSpinlock, defined at SDL3/SDL_atomic.h 117:34

Since: 3.2.0

lockSpinlockSafe Source #

Arguments

:: Ptr SDL_SpinLock
lock
a pointer to a lock variable.
-> IO () 

Lock a spin lock by setting it to a non-zero value.

Please note that spinlocks are dangerous if you don't know what you're doing. Please be careful using any sort of spinlock!

Thread safety
It is safe to call this function from any thread.
See also
tryLockSpinlock, unlockSpinlock

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_LockSpinlock. The unsafe flavor is lockSpinlock .
C declaration
SDL_LockSpinlock, defined at SDL3/SDL_atomic.h 117:34

Since: 3.2.0

unlockSpinlock Source #

Arguments

:: Ptr SDL_SpinLock
lock
a pointer to a lock variable.
-> IO () 

Unlock a spin lock by setting it to 0.

Always returns immediately.

Please note that spinlocks are dangerous if you don't know what you're doing. Please be careful using any sort of spinlock!

Thread safety
It is safe to call this function from any thread.
See also
lockSpinlock, tryLockSpinlock

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_UnlockSpinlock. The safe flavor is unlockSpinlockSafe .
C declaration
SDL_UnlockSpinlock, defined at SDL3/SDL_atomic.h 136:34

Since: 3.2.0

unlockSpinlockSafe Source #

Arguments

:: Ptr SDL_SpinLock
lock
a pointer to a lock variable.
-> IO () 

Unlock a spin lock by setting it to 0.

Always returns immediately.

Please note that spinlocks are dangerous if you don't know what you're doing. Please be careful using any sort of spinlock!

Thread safety
It is safe to call this function from any thread.
See also
lockSpinlock, tryLockSpinlock

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_UnlockSpinlock. The unsafe flavor is unlockSpinlock .
C declaration
SDL_UnlockSpinlock, defined at SDL3/SDL_atomic.h 136:34

Since: 3.2.0

memoryBarrierReleaseFunction :: IO () Source #

Insert a memory release barrier (function version).

Please refer to SDL_MemoryBarrierRelease for details. This is a function version, which might be useful if you need to use this functionality from a scripting language, etc. Also, some of the macro versions call this function behind the scenes, where more heavy lifting can happen inside of SDL. Generally, though, an app written in C/C++/etc should use the macro version, as it will be more efficient.

Thread safety
Obviously this function is safe to use from any thread at any time, but if you find yourself needing this, you are probably dealing with some very sensitive code; be careful!
See also
SDL_MemoryBarrierRelease

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_MemoryBarrierReleaseFunction. The safe flavor is memoryBarrierReleaseFunctionSafe .
C declaration
SDL_MemoryBarrierReleaseFunction, defined at SDL3/SDL_atomic.h 195:34

Since: 3.2.0

memoryBarrierReleaseFunctionSafe :: IO () Source #

Insert a memory release barrier (function version).

Please refer to SDL_MemoryBarrierRelease for details. This is a function version, which might be useful if you need to use this functionality from a scripting language, etc. Also, some of the macro versions call this function behind the scenes, where more heavy lifting can happen inside of SDL. Generally, though, an app written in C/C++/etc should use the macro version, as it will be more efficient.

Thread safety
Obviously this function is safe to use from any thread at any time, but if you find yourself needing this, you are probably dealing with some very sensitive code; be careful!
See also
SDL_MemoryBarrierRelease

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_MemoryBarrierReleaseFunction. The unsafe flavor is memoryBarrierReleaseFunction .
C declaration
SDL_MemoryBarrierReleaseFunction, defined at SDL3/SDL_atomic.h 195:34

Since: 3.2.0

memoryBarrierAcquireFunction :: IO () Source #

Insert a memory acquire barrier (function version).

Please refer to SDL_MemoryBarrierRelease for details. This is a function version, which might be useful if you need to use this functionality from a scripting language, etc. Also, some of the macro versions call this function behind the scenes, where more heavy lifting can happen inside of SDL. Generally, though, an app written in C/C++/etc should use the macro version, as it will be more efficient.

Thread safety
Obviously this function is safe to use from any thread at any time, but if you find yourself needing this, you are probably dealing with some very sensitive code; be careful!
See also
SDL_MemoryBarrierAcquire

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_MemoryBarrierAcquireFunction. The safe flavor is memoryBarrierAcquireFunctionSafe .
C declaration
SDL_MemoryBarrierAcquireFunction, defined at SDL3/SDL_atomic.h 215:34

Since: 3.2.0

memoryBarrierAcquireFunctionSafe :: IO () Source #

Insert a memory acquire barrier (function version).

Please refer to SDL_MemoryBarrierRelease for details. This is a function version, which might be useful if you need to use this functionality from a scripting language, etc. Also, some of the macro versions call this function behind the scenes, where more heavy lifting can happen inside of SDL. Generally, though, an app written in C/C++/etc should use the macro version, as it will be more efficient.

Thread safety
Obviously this function is safe to use from any thread at any time, but if you find yourself needing this, you are probably dealing with some very sensitive code; be careful!
See also
SDL_MemoryBarrierAcquire

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_MemoryBarrierAcquireFunction. The unsafe flavor is memoryBarrierAcquireFunction .
C declaration
SDL_MemoryBarrierAcquireFunction, defined at SDL3/SDL_atomic.h 215:34

Since: 3.2.0

compareAndSwapAtomicInt Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt variable to be modified.
-> Int32
oldval
the old value.
-> Int32
newval
the new value.
-> IO Bool 

Set an atomic variable 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!

Returns
true if the atomic variable was set, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
getAtomicInt, setAtomicInt

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_CompareAndSwapAtomicInt. The safe flavor is compareAndSwapAtomicIntSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_CompareAndSwapAtomicInt, defined at SDL3/SDL_atomic.h 425:34

Since: 3.2.0

compareAndSwapAtomicIntSafe Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt variable to be modified.
-> Int32
oldval
the old value.
-> Int32
newval
the new value.
-> IO Bool 

Set an atomic variable 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!

Returns
true if the atomic variable was set, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
getAtomicInt, setAtomicInt

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_CompareAndSwapAtomicInt. The unsafe flavor is compareAndSwapAtomicInt .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_CompareAndSwapAtomicInt, defined at SDL3/SDL_atomic.h 425:34

Since: 3.2.0

setAtomicInt Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt variable to be modified.
-> Int32
v
the desired value.
-> IO Int32 

Set an atomic variable to a value.

This function also acts as a full memory barrier.

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

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
getAtomicInt

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_SetAtomicInt. The safe flavor is setAtomicIntSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetAtomicInt, defined at SDL3/SDL_atomic.h 445:33

Since: 3.2.0

setAtomicIntSafe Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt variable to be modified.
-> Int32
v
the desired value.
-> IO Int32 

Set an atomic variable to a value.

This function also acts as a full memory barrier.

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

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
getAtomicInt

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_SetAtomicInt. The unsafe flavor is setAtomicInt .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetAtomicInt, defined at SDL3/SDL_atomic.h 445:33

Since: 3.2.0

getAtomicInt Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt variable.
-> IO Int32 

Get the value of an atomic variable.

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

Returns
the current value of an atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
setAtomicInt

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetAtomicInt. The safe flavor is getAtomicIntSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetAtomicInt, defined at SDL3/SDL_atomic.h 462:33

Since: 3.2.0

getAtomicIntSafe Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt variable.
-> IO Int32 

Get the value of an atomic variable.

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

Returns
the current value of an atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
setAtomicInt

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetAtomicInt. The unsafe flavor is getAtomicInt .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetAtomicInt, defined at SDL3/SDL_atomic.h 462:33

Since: 3.2.0

addAtomicInt Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt variable to be modified.
-> Int32
v
the desired value to add.
-> IO Int32 

Add to an atomic variable.

This function also acts as a full memory barrier.

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

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
atomicDecRef, atomicIncRef

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_AddAtomicInt. The safe flavor is addAtomicIntSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_AddAtomicInt, defined at SDL3/SDL_atomic.h 483:33

Since: 3.2.0

addAtomicIntSafe Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt variable to be modified.
-> Int32
v
the desired value to add.
-> IO Int32 

Add to an atomic variable.

This function also acts as a full memory barrier.

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

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
atomicDecRef, atomicIncRef

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_AddAtomicInt. The unsafe flavor is addAtomicInt .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_AddAtomicInt, defined at SDL3/SDL_atomic.h 483:33

Since: 3.2.0

compareAndSwapAtomicU32 Source #

Arguments

:: Ptr SDL_AtomicU32
a
a pointer to an SDL_AtomicU32 variable to be modified.
-> Word32
oldval
the old value.
-> Word32
newval
the new value.
-> IO Bool 

Set an atomic variable 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!

Returns
true if the atomic variable was set, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
getAtomicU32, setAtomicU32

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_CompareAndSwapAtomicU32. The safe flavor is compareAndSwapAtomicU32Safe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_CompareAndSwapAtomicU32, defined at SDL3/SDL_atomic.h 570:34

Since: 3.2.0

compareAndSwapAtomicU32Safe Source #

Arguments

:: Ptr SDL_AtomicU32
a
a pointer to an SDL_AtomicU32 variable to be modified.
-> Word32
oldval
the old value.
-> Word32
newval
the new value.
-> IO Bool 

Set an atomic variable 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!

Returns
true if the atomic variable was set, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
getAtomicU32, setAtomicU32

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_CompareAndSwapAtomicU32. The unsafe flavor is compareAndSwapAtomicU32 .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_CompareAndSwapAtomicU32, defined at SDL3/SDL_atomic.h 570:34

Since: 3.2.0

setAtomicU32 Source #

Arguments

:: Ptr SDL_AtomicU32
a
a pointer to an SDL_AtomicU32 variable to be modified.
-> Word32
v
the desired value.
-> IO Word32 

Set an atomic variable to a value.

This function also acts as a full memory barrier.

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

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
getAtomicU32

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_SetAtomicU32. The safe flavor is setAtomicU32Safe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetAtomicU32, defined at SDL3/SDL_atomic.h 590:36

Since: 3.2.0

setAtomicU32Safe Source #

Arguments

:: Ptr SDL_AtomicU32
a
a pointer to an SDL_AtomicU32 variable to be modified.
-> Word32
v
the desired value.
-> IO Word32 

Set an atomic variable to a value.

This function also acts as a full memory barrier.

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

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
getAtomicU32

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_SetAtomicU32. The unsafe flavor is setAtomicU32 .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetAtomicU32, defined at SDL3/SDL_atomic.h 590:36

Since: 3.2.0

getAtomicU32 Source #

Arguments

:: Ptr SDL_AtomicU32
a
a pointer to an SDL_AtomicU32 variable.
-> IO Word32 

Get the value of an atomic variable.

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

Returns
the current value of an atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
setAtomicU32

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetAtomicU32. The safe flavor is getAtomicU32Safe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetAtomicU32, defined at SDL3/SDL_atomic.h 607:36

Since: 3.2.0

getAtomicU32Safe Source #

Arguments

:: Ptr SDL_AtomicU32
a
a pointer to an SDL_AtomicU32 variable.
-> IO Word32 

Get the value of an atomic variable.

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

Returns
the current value of an atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
setAtomicU32

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetAtomicU32. The unsafe flavor is getAtomicU32 .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetAtomicU32, defined at SDL3/SDL_atomic.h 607:36

Since: 3.2.0

addAtomicU32 Source #

Arguments

:: Ptr SDL_AtomicU32
a
a pointer to an SDL_AtomicU32 variable to be modified.
-> Int32
v
the desired value to add or subtract.
-> IO Word32 

Add to an atomic variable.

This function also acts as a full memory barrier.

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

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_AddAtomicU32. The safe flavor is addAtomicU32Safe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_AddAtomicU32, defined at SDL3/SDL_atomic.h 625:36

Since: 3.4.0

addAtomicU32Safe Source #

Arguments

:: Ptr SDL_AtomicU32
a
a pointer to an SDL_AtomicU32 variable to be modified.
-> Int32
v
the desired value to add or subtract.
-> IO Word32 

Add to an atomic variable.

This function also acts as a full memory barrier.

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

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_AddAtomicU32. The unsafe flavor is addAtomicU32 .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_AddAtomicU32, defined at SDL3/SDL_atomic.h 625:36

Since: 3.4.0

compareAndSwapAtomicPointer Source #

Arguments

:: Ptr (Ptr Void)
a
a pointer to a pointer.
-> Ptr Void
oldval
the old pointer value.
-> Ptr Void
newval
the new pointer value.
-> IO Bool 

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!

Returns
true if the pointer was set, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
compareAndSwapAtomicInt, getAtomicPointer, setAtomicPointer

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_CompareAndSwapAtomicPointer. The safe flavor is compareAndSwapAtomicPointerSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_CompareAndSwapAtomicPointer, defined at SDL3/SDL_atomic.h 646:34

Since: 3.2.0

compareAndSwapAtomicPointerSafe Source #

Arguments

:: Ptr (Ptr Void)
a
a pointer to a pointer.
-> Ptr Void
oldval
the old pointer value.
-> Ptr Void
newval
the new pointer value.
-> IO Bool 

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!

Returns
true if the pointer was set, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
compareAndSwapAtomicInt, getAtomicPointer, setAtomicPointer

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_CompareAndSwapAtomicPointer. The unsafe flavor is compareAndSwapAtomicPointer .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_CompareAndSwapAtomicPointer, defined at SDL3/SDL_atomic.h 646:34

Since: 3.2.0

setAtomicPointer Source #

Arguments

:: Ptr (Ptr Void)
a
a pointer to a pointer.
-> Ptr Void
v
the desired pointer value.
-> IO (Ptr Void) 

Set a pointer to a value atomically.

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

Returns
the previous value of the pointer.
Thread safety
It is safe to call this function from any thread.
See also
compareAndSwapAtomicPointer, getAtomicPointer

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_SetAtomicPointer. The safe flavor is setAtomicPointerSafe .
C declaration
SDL_SetAtomicPointer, defined at SDL3/SDL_atomic.h 665:36

Since: 3.2.0

setAtomicPointerSafe Source #

Arguments

:: Ptr (Ptr Void)
a
a pointer to a pointer.
-> Ptr Void
v
the desired pointer value.
-> IO (Ptr Void) 

Set a pointer to a value atomically.

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

Returns
the previous value of the pointer.
Thread safety
It is safe to call this function from any thread.
See also
compareAndSwapAtomicPointer, getAtomicPointer

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_SetAtomicPointer. The unsafe flavor is setAtomicPointer .
C declaration
SDL_SetAtomicPointer, defined at SDL3/SDL_atomic.h 665:36

Since: 3.2.0

getAtomicPointer Source #

Arguments

:: Ptr (Ptr Void)
a
a pointer to a pointer.
-> IO (Ptr Void) 

Get the value of a pointer atomically.

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

Returns
the current value of a pointer.
Thread safety
It is safe to call this function from any thread.
See also
compareAndSwapAtomicPointer, setAtomicPointer

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetAtomicPointer. The safe flavor is getAtomicPointerSafe .
C declaration
SDL_GetAtomicPointer, defined at SDL3/SDL_atomic.h 683:36

Since: 3.2.0

getAtomicPointerSafe Source #

Arguments

:: Ptr (Ptr Void)
a
a pointer to a pointer.
-> IO (Ptr Void) 

Get the value of a pointer atomically.

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

Returns
the current value of a pointer.
Thread safety
It is safe to call this function from any thread.
See also
compareAndSwapAtomicPointer, setAtomicPointer

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetAtomicPointer. The unsafe flavor is getAtomicPointer .
C declaration
SDL_GetAtomicPointer, defined at SDL3/SDL_atomic.h 683:36

Since: 3.2.0

C shims

atomicIncRef Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt to increment.
-> IO Int32 

Increment an atomic variable used as a reference count.

The SDL_AtomicIncRef macro as a function.

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
atomicDecRef

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_AtomicIncRef. The safe flavor is atomicIncRefSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_AtomicIncRef, defined at sdl3-bindgen-sys/SDL_atomic_shims.h 38:23

Since: 3.2.0

atomicIncRefSafe Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt to increment.
-> IO Int32 

Increment an atomic variable used as a reference count.

The SDL_AtomicIncRef macro as a function.

Returns
the previous value of the atomic variable.
Thread safety
It is safe to call this function from any thread.
See also
atomicDecRef

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of lithon_SDL_AtomicIncRef. The unsafe flavor is atomicIncRef .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_AtomicIncRef, defined at sdl3-bindgen-sys/SDL_atomic_shims.h 38:23

Since: 3.2.0

atomicDecRef Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt to decrement.
-> IO Bool 

Decrement an atomic variable used as a reference count.

The SDL_AtomicDecRef macro as a function.

Returns
true if the variable reached zero after decrementing, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
atomicIncRef

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_AtomicDecRef. The safe flavor is atomicDecRefSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_AtomicDecRef, defined at sdl3-bindgen-sys/SDL_atomic_shims.h 58:24

Since: 3.2.0

atomicDecRefSafe Source #

Arguments

:: Ptr SDL_AtomicInt
a
a pointer to an SDL_AtomicInt to decrement.
-> IO Bool 

Decrement an atomic variable used as a reference count.

The SDL_AtomicDecRef macro as a function.

Returns
true if the variable reached zero after decrementing, false otherwise.
Thread safety
It is safe to call this function from any thread.
See also
atomicIncRef

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of lithon_SDL_AtomicDecRef. The unsafe flavor is atomicDecRef .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_AtomicDecRef, defined at sdl3-bindgen-sys/SDL_atomic_shims.h 58:24

Since: 3.2.0