-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79d4ff4
commit b6ce538
Showing
19 changed files
with
542 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
###### (This is the documentation for SDL3, which is under heavy development and the API is changing! [SDL2](https://wiki.libsdl.org/SDL2/) is the current stable version!) | ||
# SDL_AddAtomicInt | ||
|
||
Add to an atomic variable. | ||
|
||
## Header File | ||
|
||
Defined in [<SDL3/SDL_atomic.h>](https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_atomic.h) | ||
|
||
## Syntax | ||
|
||
```c | ||
int SDL_AddAtomicInt(SDL_AtomicInt *a, int v); | ||
``` | ||
## Function Parameters | ||
| | | | | ||
| -------------------------------- | ----- | ----------------------------------------------------------------------- | | ||
| [SDL_AtomicInt](SDL_AtomicInt) * | **a** | a pointer to an [SDL_AtomicInt](SDL_AtomicInt) variable to be modified. | | ||
| int | **v** | the desired value to add. | | ||
## Return Value | ||
(int) Returns the previous value of the atomic variable. | ||
## Remarks | ||
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!*** | ||
## Thread Safety | ||
It is safe to call this function from any thread. | ||
## Version | ||
This function is available since SDL 3.0.0. | ||
## See Also | ||
- [SDL_AtomicDecRef](SDL_AtomicDecRef) | ||
- [SDL_AtomicIncRef](SDL_AtomicIncRef) | ||
---- | ||
[CategoryAPI](CategoryAPI), [CategoryAPIFunction](CategoryAPIFunction), [CategoryAtomic](CategoryAtomic) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
###### (This is the documentation for SDL3, which is under heavy development and the API is changing! [SDL2](https://wiki.libsdl.org/SDL2/) is the current stable version!) | ||
# SDL_AtomicU32 | ||
|
||
A type representing an atomic unsigned 32-bit value. | ||
|
||
## Header File | ||
|
||
Defined in [<SDL3/SDL_atomic.h>](https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_atomic.h) | ||
|
||
## Syntax | ||
|
||
```c | ||
typedef struct SDL_AtomicU32 { Uint32 value; } SDL_AtomicU32; | ||
``` | ||
## Remarks | ||
This can be used to manage a value that is synchronized across multiple | ||
CPUs without a race condition; when an app sets a value with | ||
[SDL_SetAtomicU32](SDL_SetAtomicU32) all other threads, regardless of the | ||
CPU it is running on, will see that value when retrieved with | ||
[SDL_GetAtomicU32](SDL_GetAtomicU32), regardless of CPU caches, etc. | ||
This is also useful for atomic compare-and-swap operations: a thread can | ||
change the value as long as its current value matches expectations. When | ||
done in a loop, one can guarantee data consistency across threads without a | ||
lock (but the usual warnings apply: if you don't know what you're doing, or | ||
you don't do it carefully, you can confidently cause any number of | ||
disasters with this, so in most cases, you _should_ use a mutex instead of | ||
this!). | ||
This is a struct so people don't accidentally use numeric operations on it | ||
directly. You have to use SDL atomic functions. | ||
## Version | ||
This struct is available since SDL 3.0.0. | ||
## See Also | ||
- [SDL_CompareAndSwapAtomicU32](SDL_CompareAndSwapAtomicU32) | ||
- [SDL_GetAtomicU32](SDL_GetAtomicU32) | ||
- [SDL_SetAtomicU32](SDL_SetAtomicU32) | ||
- [SDL_AddAtomicU32](SDL_AddAtomicU32) | ||
---- | ||
[CategoryAPI](CategoryAPI), [CategoryAPIStruct](CategoryAPIStruct), [CategoryAtomic](CategoryAtomic) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
###### (This is the documentation for SDL3, which is under heavy development and the API is changing! [SDL2](https://wiki.libsdl.org/SDL2/) is the current stable version!) | ||
# SDL_CompareAndSwapAtomicInt | ||
|
||
Set an atomic variable to a new value if it is currently an old value. | ||
|
||
## Header File | ||
|
||
Defined in [<SDL3/SDL_atomic.h>](https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_atomic.h) | ||
|
||
## Syntax | ||
|
||
```c | ||
SDL_bool SDL_CompareAndSwapAtomicInt(SDL_AtomicInt *a, int oldval, int newval); | ||
``` | ||
## Function Parameters | ||
| | | | | ||
| -------------------------------- | ---------- | ----------------------------------------------------------------------- | | ||
| [SDL_AtomicInt](SDL_AtomicInt) * | **a** | a pointer to an [SDL_AtomicInt](SDL_AtomicInt) variable to be modified. | | ||
| int | **oldval** | the old value. | | ||
| int | **newval** | the new value. | | ||
## Return Value | ||
([SDL_bool](SDL_bool)) Returns [SDL_TRUE](SDL_TRUE) if the atomic variable | ||
was set, [SDL_FALSE](SDL_FALSE) otherwise. | ||
## Remarks | ||
***Note: If you don't know what this function is for, you shouldn't use | ||
it!*** | ||
## Thread Safety | ||
It is safe to call this function from any thread. | ||
## Version | ||
This function is available since SDL 3.0.0. | ||
## See Also | ||
- [SDL_GetAtomicInt](SDL_GetAtomicInt) | ||
- [SDL_SetAtomicInt](SDL_SetAtomicInt) | ||
---- | ||
[CategoryAPI](CategoryAPI), [CategoryAPIFunction](CategoryAPIFunction), [CategoryAtomic](CategoryAtomic) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
###### (This is the documentation for SDL3, which is under heavy development and the API is changing! [SDL2](https://wiki.libsdl.org/SDL2/) is the current stable version!) | ||
# SDL_CompareAndSwapAtomicPointer | ||
|
||
Set a pointer to a new value if it is currently an old value. | ||
|
||
## Header File | ||
|
||
Defined in [<SDL3/SDL_atomic.h>](https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_atomic.h) | ||
|
||
## Syntax | ||
|
||
```c | ||
SDL_bool SDL_CompareAndSwapAtomicPointer(void **a, void *oldval, void *newval); | ||
``` | ||
## Function Parameters | ||
| | | | | ||
| ------- | ---------- | ----------------------- | | ||
| void ** | **a** | a pointer to a pointer. | | ||
| void * | **oldval** | the old pointer value. | | ||
| void * | **newval** | the new pointer value. | | ||
## Return Value | ||
([SDL_bool](SDL_bool)) Returns [SDL_TRUE](SDL_TRUE) if the pointer was set, | ||
[SDL_FALSE](SDL_FALSE) otherwise. | ||
## Remarks | ||
***Note: If you don't know what this function is for, you shouldn't use | ||
it!*** | ||
## Thread Safety | ||
It is safe to call this function from any thread. | ||
## Version | ||
This function is available since SDL 3.0.0. | ||
## See Also | ||
- [SDL_CompareAndSwapAtomicInt](SDL_CompareAndSwapAtomicInt) | ||
- [SDL_GetAtomicPointer](SDL_GetAtomicPointer) | ||
- [SDL_SetAtomicPointer](SDL_SetAtomicPointer) | ||
---- | ||
[CategoryAPI](CategoryAPI), [CategoryAPIFunction](CategoryAPIFunction), [CategoryAtomic](CategoryAtomic) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
###### (This is the documentation for SDL3, which is under heavy development and the API is changing! [SDL2](https://wiki.libsdl.org/SDL2/) is the current stable version!) | ||
# SDL_CompareAndSwapAtomicU32 | ||
|
||
Set an atomic variable to a new value if it is currently an old value. | ||
|
||
## Header File | ||
|
||
Defined in [<SDL3/SDL_atomic.h>](https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_atomic.h) | ||
|
||
## Syntax | ||
|
||
```c | ||
SDL_bool SDL_CompareAndSwapAtomicU32(SDL_AtomicU32 *a, Uint32 oldval, Uint32 newval); | ||
``` | ||
## Function Parameters | ||
| | | | | ||
| -------------------------------- | ---------- | ----------------------------------------------------------------------- | | ||
| [SDL_AtomicU32](SDL_AtomicU32) * | **a** | a pointer to an [SDL_AtomicU32](SDL_AtomicU32) variable to be modified. | | ||
| Uint32 | **oldval** | the old value. | | ||
| Uint32 | **newval** | the new value. | | ||
## Return Value | ||
([SDL_bool](SDL_bool)) Returns [SDL_TRUE](SDL_TRUE) if the atomic variable | ||
was set, [SDL_FALSE](SDL_FALSE) otherwise. | ||
## Remarks | ||
***Note: If you don't know what this function is for, you shouldn't use | ||
it!*** | ||
## Thread Safety | ||
It is safe to call this function from any thread. | ||
## Version | ||
This function is available since SDL 3.0.0. | ||
## See Also | ||
- [SDL_GetAtomicU32](SDL_GetAtomicU32) | ||
- [SDL_SetAtomicU32](SDL_SetAtomicU32) | ||
---- | ||
[CategoryAPI](CategoryAPI), [CategoryAPIFunction](CategoryAPIFunction), [CategoryAtomic](CategoryAtomic) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
###### (This is the documentation for SDL3, which is under heavy development and the API is changing! [SDL2](https://wiki.libsdl.org/SDL2/) is the current stable version!) | ||
# SDL_GetAtomicInt | ||
|
||
Get the value of an atomic variable. | ||
|
||
## Header File | ||
|
||
Defined in [<SDL3/SDL_atomic.h>](https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_atomic.h) | ||
|
||
## Syntax | ||
|
||
```c | ||
int SDL_GetAtomicInt(SDL_AtomicInt *a); | ||
``` | ||
## Function Parameters | ||
| | | | | ||
| -------------------------------- | ----- | -------------------------------------------------------- | | ||
| [SDL_AtomicInt](SDL_AtomicInt) * | **a** | a pointer to an [SDL_AtomicInt](SDL_AtomicInt) variable. | | ||
## Return Value | ||
(int) Returns the current value of an atomic variable. | ||
## Remarks | ||
***Note: If you don't know what this function is for, you shouldn't use | ||
it!*** | ||
## Thread Safety | ||
It is safe to call this function from any thread. | ||
## Version | ||
This function is available since SDL 3.0.0. | ||
## See Also | ||
- [SDL_SetAtomicInt](SDL_SetAtomicInt) | ||
---- | ||
[CategoryAPI](CategoryAPI), [CategoryAPIFunction](CategoryAPIFunction), [CategoryAtomic](CategoryAtomic) | ||
Oops, something went wrong.