| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
SDL3.Sys.Atomic
Contents
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
- module SDL3.Sys.Bindgen.Atomic
- tryLockSpinlock :: Ptr SDL_SpinLock -> IO Bool
- tryLockSpinlockSafe :: Ptr SDL_SpinLock -> IO Bool
- lockSpinlock :: Ptr SDL_SpinLock -> IO ()
- lockSpinlockSafe :: Ptr SDL_SpinLock -> IO ()
- unlockSpinlock :: Ptr SDL_SpinLock -> IO ()
- unlockSpinlockSafe :: Ptr SDL_SpinLock -> IO ()
- memoryBarrierReleaseFunction :: IO ()
- memoryBarrierReleaseFunctionSafe :: IO ()
- memoryBarrierAcquireFunction :: IO ()
- memoryBarrierAcquireFunctionSafe :: IO ()
- compareAndSwapAtomicInt :: Ptr SDL_AtomicInt -> Int32 -> Int32 -> IO Bool
- compareAndSwapAtomicIntSafe :: Ptr SDL_AtomicInt -> Int32 -> Int32 -> IO Bool
- setAtomicInt :: Ptr SDL_AtomicInt -> Int32 -> IO Int32
- setAtomicIntSafe :: Ptr SDL_AtomicInt -> Int32 -> IO Int32
- getAtomicInt :: Ptr SDL_AtomicInt -> IO Int32
- getAtomicIntSafe :: Ptr SDL_AtomicInt -> IO Int32
- addAtomicInt :: Ptr SDL_AtomicInt -> Int32 -> IO Int32
- addAtomicIntSafe :: Ptr SDL_AtomicInt -> Int32 -> IO Int32
- compareAndSwapAtomicU32 :: Ptr SDL_AtomicU32 -> Word32 -> Word32 -> IO Bool
- compareAndSwapAtomicU32Safe :: Ptr SDL_AtomicU32 -> Word32 -> Word32 -> IO Bool
- setAtomicU32 :: Ptr SDL_AtomicU32 -> Word32 -> IO Word32
- setAtomicU32Safe :: Ptr SDL_AtomicU32 -> Word32 -> IO Word32
- getAtomicU32 :: Ptr SDL_AtomicU32 -> IO Word32
- getAtomicU32Safe :: Ptr SDL_AtomicU32 -> IO Word32
- addAtomicU32 :: Ptr SDL_AtomicU32 -> Int32 -> IO Word32
- addAtomicU32Safe :: Ptr SDL_AtomicU32 -> Int32 -> IO Word32
- compareAndSwapAtomicPointer :: Ptr (Ptr Void) -> Ptr Void -> Ptr Void -> IO Bool
- compareAndSwapAtomicPointerSafe :: Ptr (Ptr Void) -> Ptr Void -> Ptr Void -> IO Bool
- setAtomicPointer :: Ptr (Ptr Void) -> Ptr Void -> IO (Ptr Void)
- setAtomicPointerSafe :: Ptr (Ptr Void) -> Ptr Void -> IO (Ptr Void)
- getAtomicPointer :: Ptr (Ptr Void) -> IO (Ptr Void)
- getAtomicPointerSafe :: Ptr (Ptr Void) -> IO (Ptr Void)
- atomicIncRef :: Ptr SDL_AtomicInt -> IO Int32
- atomicIncRefSafe :: Ptr SDL_AtomicInt -> IO Int32
- atomicDecRef :: Ptr SDL_AtomicInt -> IO Bool
- atomicDecRefSafe :: Ptr SDL_AtomicInt -> IO Bool
Documentation
module SDL3.Sys.Bindgen.Atomic
Function aliases
Arguments
| :: Ptr SDL_SpinLock |
|
| -> 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
- FFI safety
- Unsafe foreign import of
SDL_TryLockSpinlock. The safe flavor istryLockSpinlockSafe. - 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 atSDL3/SDL_atomic.h 100:34
Since: 3.2.0
Arguments
| :: Ptr SDL_SpinLock |
|
| -> 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
- FFI safety
- Safe foreign import of
SDL_TryLockSpinlock. The unsafe flavor istryLockSpinlock. - 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 atSDL3/SDL_atomic.h 100:34
Since: 3.2.0
Arguments
| :: Ptr SDL_SpinLock |
|
| -> 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
- FFI safety
- Unsafe foreign import of
SDL_LockSpinlock. The safe flavor islockSpinlockSafe. - C declaration
SDL_LockSpinlock, defined atSDL3/SDL_atomic.h 117:34
Since: 3.2.0
Arguments
| :: Ptr SDL_SpinLock |
|
| -> 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
- FFI safety
- Safe foreign import of
SDL_LockSpinlock. The unsafe flavor islockSpinlock. - C declaration
SDL_LockSpinlock, defined atSDL3/SDL_atomic.h 117:34
Since: 3.2.0
Arguments
| :: Ptr SDL_SpinLock |
|
| -> 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
- FFI safety
- Unsafe foreign import of
SDL_UnlockSpinlock. The safe flavor isunlockSpinlockSafe. - C declaration
SDL_UnlockSpinlock, defined atSDL3/SDL_atomic.h 136:34
Since: 3.2.0
Arguments
| :: Ptr SDL_SpinLock |
|
| -> 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
- FFI safety
- Safe foreign import of
SDL_UnlockSpinlock. The unsafe flavor isunlockSpinlock. - C declaration
SDL_UnlockSpinlock, defined atSDL3/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
- FFI safety
- Unsafe foreign import of
SDL_MemoryBarrierReleaseFunction. The safe flavor ismemoryBarrierReleaseFunctionSafe. - C declaration
SDL_MemoryBarrierReleaseFunction, defined atSDL3/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
- FFI safety
- Safe foreign import of
SDL_MemoryBarrierReleaseFunction. The unsafe flavor ismemoryBarrierReleaseFunction. - C declaration
SDL_MemoryBarrierReleaseFunction, defined atSDL3/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
- FFI safety
- Unsafe foreign import of
SDL_MemoryBarrierAcquireFunction. The safe flavor ismemoryBarrierAcquireFunctionSafe. - C declaration
SDL_MemoryBarrierAcquireFunction, defined atSDL3/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
- FFI safety
- Safe foreign import of
SDL_MemoryBarrierAcquireFunction. The unsafe flavor ismemoryBarrierAcquireFunction. - C declaration
SDL_MemoryBarrierAcquireFunction, defined atSDL3/SDL_atomic.h 215:34
Since: 3.2.0
compareAndSwapAtomicInt Source #
Arguments
| :: Ptr SDL_AtomicInt |
|
| -> Int32 |
|
| -> Int32 |
|
| -> 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
- FFI safety
- Unsafe foreign import of
SDL_CompareAndSwapAtomicInt. The safe flavor iscompareAndSwapAtomicIntSafe. - 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 atSDL3/SDL_atomic.h 425:34
Since: 3.2.0
compareAndSwapAtomicIntSafe Source #
Arguments
| :: Ptr SDL_AtomicInt |
|
| -> Int32 |
|
| -> Int32 |
|
| -> 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
- FFI safety
- Safe foreign import of
SDL_CompareAndSwapAtomicInt. The unsafe flavor iscompareAndSwapAtomicInt. - 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 atSDL3/SDL_atomic.h 425:34
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicInt |
|
| -> Int32 |
|
| -> 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
- FFI safety
- Unsafe foreign import of
SDL_SetAtomicInt. The safe flavor issetAtomicIntSafe. - 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 atSDL3/SDL_atomic.h 445:33
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicInt |
|
| -> Int32 |
|
| -> 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
- FFI safety
- Safe foreign import of
SDL_SetAtomicInt. The unsafe flavor issetAtomicInt. - 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 atSDL3/SDL_atomic.h 445:33
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicInt |
|
| -> 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
- FFI safety
- Unsafe foreign import of
SDL_GetAtomicInt. The safe flavor isgetAtomicIntSafe. - 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 atSDL3/SDL_atomic.h 462:33
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicInt |
|
| -> 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
- FFI safety
- Safe foreign import of
SDL_GetAtomicInt. The unsafe flavor isgetAtomicInt. - 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 atSDL3/SDL_atomic.h 462:33
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicInt |
|
| -> Int32 |
|
| -> 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
,atomicDecRefatomicIncRef
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_AddAtomicInt. The safe flavor isaddAtomicIntSafe. - 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 atSDL3/SDL_atomic.h 483:33
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicInt |
|
| -> Int32 |
|
| -> 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
,atomicDecRefatomicIncRef
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_AddAtomicInt. The unsafe flavor isaddAtomicInt. - 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 atSDL3/SDL_atomic.h 483:33
Since: 3.2.0
compareAndSwapAtomicU32 Source #
Arguments
| :: Ptr SDL_AtomicU32 |
|
| -> Word32 |
|
| -> Word32 |
|
| -> 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
- FFI safety
- Unsafe foreign import of
SDL_CompareAndSwapAtomicU32. The safe flavor iscompareAndSwapAtomicU32Safe. - 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 atSDL3/SDL_atomic.h 570:34
Since: 3.2.0
compareAndSwapAtomicU32Safe Source #
Arguments
| :: Ptr SDL_AtomicU32 |
|
| -> Word32 |
|
| -> Word32 |
|
| -> 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
- FFI safety
- Safe foreign import of
SDL_CompareAndSwapAtomicU32. The unsafe flavor iscompareAndSwapAtomicU32. - 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 atSDL3/SDL_atomic.h 570:34
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicU32 |
|
| -> Word32 |
|
| -> 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
- FFI safety
- Unsafe foreign import of
SDL_SetAtomicU32. The safe flavor issetAtomicU32Safe. - 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 atSDL3/SDL_atomic.h 590:36
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicU32 |
|
| -> Word32 |
|
| -> 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
- FFI safety
- Safe foreign import of
SDL_SetAtomicU32. The unsafe flavor issetAtomicU32. - 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 atSDL3/SDL_atomic.h 590:36
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicU32 |
|
| -> 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
- FFI safety
- Unsafe foreign import of
SDL_GetAtomicU32. The safe flavor isgetAtomicU32Safe. - 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 atSDL3/SDL_atomic.h 607:36
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicU32 |
|
| -> 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
- FFI safety
- Safe foreign import of
SDL_GetAtomicU32. The unsafe flavor isgetAtomicU32. - 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 atSDL3/SDL_atomic.h 607:36
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicU32 |
|
| -> Int32 |
|
| -> 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
- FFI safety
- Unsafe foreign import of
SDL_AddAtomicU32. The safe flavor isaddAtomicU32Safe. - 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 atSDL3/SDL_atomic.h 625:36
Since: 3.4.0
Arguments
| :: Ptr SDL_AtomicU32 |
|
| -> Int32 |
|
| -> 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
- FFI safety
- Safe foreign import of
SDL_AddAtomicU32. The unsafe flavor isaddAtomicU32. - 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 atSDL3/SDL_atomic.h 625:36
Since: 3.4.0
compareAndSwapAtomicPointer Source #
Arguments
| :: Ptr (Ptr Void) |
|
| -> Ptr Void |
|
| -> Ptr Void |
|
| -> 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
- FFI safety
- Unsafe foreign import of
SDL_CompareAndSwapAtomicPointer. The safe flavor iscompareAndSwapAtomicPointerSafe. - 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 atSDL3/SDL_atomic.h 646:34
Since: 3.2.0
compareAndSwapAtomicPointerSafe Source #
Arguments
| :: Ptr (Ptr Void) |
|
| -> Ptr Void |
|
| -> Ptr Void |
|
| -> 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
- FFI safety
- Safe foreign import of
SDL_CompareAndSwapAtomicPointer. The unsafe flavor iscompareAndSwapAtomicPointer. - 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 atSDL3/SDL_atomic.h 646:34
Since: 3.2.0
Arguments
| :: Ptr (Ptr Void) |
|
| -> Ptr Void |
|
| -> 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
- FFI safety
- Unsafe foreign import of
SDL_SetAtomicPointer. The safe flavor issetAtomicPointerSafe. - C declaration
SDL_SetAtomicPointer, defined atSDL3/SDL_atomic.h 665:36
Since: 3.2.0
Arguments
| :: Ptr (Ptr Void) |
|
| -> Ptr Void |
|
| -> 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
- FFI safety
- Safe foreign import of
SDL_SetAtomicPointer. The unsafe flavor issetAtomicPointer. - C declaration
SDL_SetAtomicPointer, defined atSDL3/SDL_atomic.h 665:36
Since: 3.2.0
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
- FFI safety
- Unsafe foreign import of
SDL_GetAtomicPointer. The safe flavor isgetAtomicPointerSafe. - C declaration
SDL_GetAtomicPointer, defined atSDL3/SDL_atomic.h 683:36
Since: 3.2.0
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
- FFI safety
- Safe foreign import of
SDL_GetAtomicPointer. The unsafe flavor isgetAtomicPointer. - C declaration
SDL_GetAtomicPointer, defined atSDL3/SDL_atomic.h 683:36
Since: 3.2.0
C shims
Arguments
| :: Ptr SDL_AtomicInt |
|
| -> 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
- FFI safety
- Unsafe foreign import of
lithon_SDL_AtomicIncRef. The safe flavor isatomicIncRefSafe. - 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 atsdl3-bindgen-sys/SDL_atomic_shims.h 38:23
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicInt |
|
| -> 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
- FFI safety
- Safe foreign import of
lithon_SDL_AtomicIncRef. The unsafe flavor isatomicIncRef. - 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 atsdl3-bindgen-sys/SDL_atomic_shims.h 38:23
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicInt |
|
| -> 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
- FFI safety
- Unsafe foreign import of
lithon_SDL_AtomicDecRef. The safe flavor isatomicDecRefSafe. - 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 atsdl3-bindgen-sys/SDL_atomic_shims.h 58:24
Since: 3.2.0
Arguments
| :: Ptr SDL_AtomicInt |
|
| -> 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
- FFI safety
- Safe foreign import of
lithon_SDL_AtomicDecRef. The unsafe flavor isatomicDecRef. - 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 atsdl3-bindgen-sys/SDL_atomic_shims.h 58:24
Since: 3.2.0