sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Bindgen.Stdinc.FunPtr

Synopsis

Documentation

sDL_malloc :: FunPtr (CSize -> IO (Ptr Void)) Source #

Allocate uninitialized memory.

The allocated memory returned by this function must be freed with SDL_free().

If size is 0, it will be set to 1.

If the allocation is successful, the returned pointer is guaranteed to be aligned to either the fundamental alignment (alignof(max_align_t) in C11 and later) or 2 * sizeof(void *), whichever is smaller. Use SDL_aligned_alloc() if you need to allocate memory aligned to an alignment greater than this guarantee.

size
the size to allocate.
Returns
a pointer to the allocated memory, or NULL if allocation failed.
Thread safety
It is safe to call this function from any thread.
See also
sDL_free, SDL_calloc, SDL_realloc, sDL_aligned_alloc
C declaration
SDL_malloc, defined at SDL3/SDL_stdinc.h 1342:47

Since: 3.2.0

sDL_calloc :: FunPtr (CSize -> CSize -> IO (Ptr Void)) Source #

C declaration
SDL_calloc, defined at SDL3/SDL_stdinc.h 1367:69

sDL_realloc :: FunPtr (Ptr Void -> CSize -> IO (Ptr Void)) Source #

C declaration
SDL_realloc, defined at SDL3/SDL_stdinc.h 1407:54

sDL_free :: FunPtr (Ptr Void -> IO ()) Source #

Free allocated memory.

The pointer is no longer valid after this call and cannot be dereferenced anymore.

If mem is NULL, this function does nothing.

mem
a pointer to allocated memory, or NULL.
Thread safety
It is safe to call this function from any thread.
See also
sDL_malloc, SDL_calloc, SDL_realloc
C declaration
SDL_free, defined at SDL3/SDL_stdinc.h 1427:34

Since: 3.2.0

sDL_GetOriginalMemoryFunctions :: FunPtr (Ptr SDL_malloc_func -> Ptr SDL_calloc_func -> Ptr SDL_realloc_func -> Ptr SDL_free_func -> IO ()) Source #

Get the original set of SDL memory functions.

This is what SDL_malloc and friends will use by default, if there has been no call to SDL_SetMemoryFunctions. This is not necessarily using the C runtime's malloc functions behind the scenes! Different platforms and build configurations might do any number of unexpected things.

malloc_func
filled with malloc function.
calloc_func
filled with calloc function.
realloc_func
filled with realloc function.
free_func
filled with free function.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_GetOriginalMemoryFunctions, defined at SDL3/SDL_stdinc.h 1525:34

Since: 3.2.0

sDL_GetMemoryFunctions :: FunPtr (Ptr SDL_malloc_func -> Ptr SDL_calloc_func -> Ptr SDL_realloc_func -> Ptr SDL_free_func -> IO ()) Source #

Get the current set of SDL memory functions.

malloc_func
filled with malloc function.
calloc_func
filled with calloc function.
realloc_func
filled with realloc function.
free_func
filled with free function.
Thread safety
This does not hold a lock, so do not call this in the unlikely event of a background thread calling SDL_SetMemoryFunctions simultaneously.
See also
sDL_SetMemoryFunctions, sDL_GetOriginalMemoryFunctions
C declaration
SDL_GetMemoryFunctions, defined at SDL3/SDL_stdinc.h 1547:34

Since: 3.2.0

sDL_SetMemoryFunctions :: FunPtr (SDL_malloc_func -> SDL_calloc_func -> SDL_realloc_func -> SDL_free_func -> IO CBool) Source #

Replace SDL's memory allocation functions with a custom set.

It is not safe to call this function once any allocations have been made, as future calls to SDL_free will use the new allocator, even if they came from an SDL_malloc made with the old one!

If used, usually this needs to be the first call made into the SDL library, if not the very first thing done at program startup time.

malloc_func
custom malloc function.
calloc_func
custom calloc function.
realloc_func
custom realloc function.
free_func
custom free function.
Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread, but one should not replace the memory functions once any allocations are made!
See also
sDL_GetMemoryFunctions, sDL_GetOriginalMemoryFunctions
C declaration
SDL_SetMemoryFunctions, defined at SDL3/SDL_stdinc.h 1578:34

Since: 3.2.0

sDL_aligned_alloc :: FunPtr (CSize -> CSize -> IO (Ptr Void)) Source #

Allocate memory aligned to a specific alignment.

The memory returned by this function must be freed with SDL_aligned_free(), not SDL_free().

If alignment is less than the size of void *, it will be increased to match that.

The returned memory address will be a multiple of the alignment value, and the size of the memory allocated will be a multiple of the alignment value.

alignment
the alignment of the memory.
size
the size to allocate.
Returns
a pointer to the aligned memory, or NULL if allocation failed.
Thread safety
It is safe to call this function from any thread.
See also
sDL_aligned_free
C declaration
SDL_aligned_alloc, defined at SDL3/SDL_stdinc.h 1605:47

Since: 3.2.0

sDL_aligned_free :: FunPtr (Ptr Void -> IO ()) Source #

Free memory allocated by SDL_aligned_alloc().

The pointer is no longer valid after this call and cannot be dereferenced anymore.

If mem is NULL, this function does nothing.

mem
a pointer previously returned by SDL_aligned_alloc(), or NULL.
Thread safety
It is safe to call this function from any thread.
See also
sDL_aligned_alloc
C declaration
SDL_aligned_free, defined at SDL3/SDL_stdinc.h 1623:34

Since: 3.2.0

sDL_GetNumAllocations :: FunPtr (IO CInt) Source #

Get the number of outstanding (unfreed) allocations.

Returns
the number of allocations or -1 if allocation counting is disabled.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_GetNumAllocations, defined at SDL3/SDL_stdinc.h 1635:33

Since: 3.2.0

sDL_GetEnvironment :: FunPtr (IO (Ptr SDL_Environment)) Source #

Get the process environment.

This is initialized at application start and is not affected by setenv() and unsetenv() calls after that point. Use SDL_SetEnvironmentVariable() and SDL_UnsetEnvironmentVariable() if you want to modify this environment, or SDL_setenv_unsafe() or SDL_unsetenv_unsafe() if you want changes to persist in the C runtime environment after SDL_Quit().

Returns
a pointer to the environment for the process or NULL on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetEnvironmentVariable, sDL_GetEnvironmentVariables, sDL_SetEnvironmentVariable, sDL_UnsetEnvironmentVariable
C declaration
SDL_GetEnvironment, defined at SDL3/SDL_stdinc.h 1673:47

Since: 3.2.0

sDL_CreateEnvironment :: FunPtr (CBool -> IO (Ptr SDL_Environment)) Source #

Create a set of environment variables

populated
true to initialize it from the C runtime environment, false to create an empty environment.
Returns
a pointer to the new environment or NULL on failure; call SDL_GetError() for more information.
Thread safety
If populated is false, it is safe to call this function from any thread, otherwise it is safe if no other threads are calling setenv() or unsetenv()
See also
sDL_GetEnvironmentVariable, sDL_GetEnvironmentVariables, sDL_SetEnvironmentVariable, sDL_UnsetEnvironmentVariable, sDL_DestroyEnvironment
C declaration
SDL_CreateEnvironment, defined at SDL3/SDL_stdinc.h 1695:47

Since: 3.2.0

sDL_GetEnvironmentVariable :: FunPtr (Ptr SDL_Environment -> PtrConst CChar -> IO (PtrConst CChar)) Source #

Get the value of a variable in the environment.

env
the environment to query.
name
the name of the variable to get.
Returns
a pointer to the value of the variable or NULL if it can't be found.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetEnvironment, sDL_CreateEnvironment, sDL_GetEnvironmentVariables, sDL_SetEnvironmentVariable, sDL_UnsetEnvironmentVariable
C declaration
SDL_GetEnvironmentVariable, defined at SDL3/SDL_stdinc.h 1715:42

Since: 3.2.0

sDL_GetEnvironmentVariables :: FunPtr (Ptr SDL_Environment -> IO (Ptr (Ptr CChar))) Source #

Get all variables in the environment.

env
the environment to query.
Returns
a NULL terminated array of pointers to environment variables in the form "variable=value" or NULL on failure; call SDL_GetError() for more information. This is a single allocation that should be freed with SDL_free() when it is no longer needed.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetEnvironment, sDL_CreateEnvironment, sDL_GetEnvironmentVariables, sDL_SetEnvironmentVariable, sDL_UnsetEnvironmentVariable
C declaration
SDL_GetEnvironmentVariables, defined at SDL3/SDL_stdinc.h 1736:37

Since: 3.2.0

sDL_SetEnvironmentVariable :: FunPtr (Ptr SDL_Environment -> PtrConst CChar -> PtrConst CChar -> CBool -> IO CBool) Source #

Set the value of a variable in the environment.

env
the environment to modify.
name
the name of the variable to set.
value
the value of the variable to set.
overwrite
true to overwrite the variable if it exists, false to return success without setting the variable if it already exists.
Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetEnvironment, sDL_CreateEnvironment, sDL_GetEnvironmentVariable, sDL_GetEnvironmentVariables, sDL_UnsetEnvironmentVariable
C declaration
SDL_SetEnvironmentVariable, defined at SDL3/SDL_stdinc.h 1760:34

Since: 3.2.0

sDL_UnsetEnvironmentVariable :: FunPtr (Ptr SDL_Environment -> PtrConst CChar -> IO CBool) Source #

Clear a variable from the environment.

env
the environment to modify.
name
the name of the variable to unset.
Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetEnvironment, sDL_CreateEnvironment, sDL_GetEnvironmentVariable, sDL_GetEnvironmentVariables, sDL_SetEnvironmentVariable, sDL_UnsetEnvironmentVariable
C declaration
SDL_UnsetEnvironmentVariable, defined at SDL3/SDL_stdinc.h 1781:34

Since: 3.2.0

sDL_DestroyEnvironment :: FunPtr (Ptr SDL_Environment -> IO ()) Source #

Destroy a set of environment variables.

env
the environment to destroy.
Thread safety
It is safe to call this function from any thread, as long as the environment is no longer in use.
See also
sDL_CreateEnvironment
C declaration
SDL_DestroyEnvironment, defined at SDL3/SDL_stdinc.h 1795:34

Since: 3.2.0

sDL_getenv :: FunPtr (PtrConst CChar -> IO (PtrConst CChar)) Source #

Get the value of a variable in the environment.

The name of the variable is case sensitive on all platforms.

This function uses SDL's cached copy of the environment and is thread-safe.

name
the name of the variable to get.
Returns
a pointer to the value of the variable or NULL if it can't be found.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_getenv, defined at SDL3/SDL_stdinc.h 1812:42

Since: 3.2.0

sDL_getenv_unsafe :: FunPtr (PtrConst CChar -> IO (PtrConst CChar)) Source #

Get the value of a variable in the environment.

This function bypasses SDL's cached copy of the environment and is not thread-safe.

On some platforms, this may make case-insensitive matches, while other platforms are case-sensitive. It is best to be precise with strings used for queries through this interface. SDL_getenv is always case-sensitive, however.

name
the name of the variable to get.
Returns
a pointer to the value of the variable or NULL if it can't be found.
Thread safety
This function is not thread safe, consider using SDL_getenv() instead.
See also
sDL_getenv
C declaration
SDL_getenv_unsafe, defined at SDL3/SDL_stdinc.h 1836:42

Since: 3.2.0

sDL_setenv_unsafe :: FunPtr (PtrConst CChar -> PtrConst CChar -> CInt -> IO CInt) Source #

Set the value of a variable in the environment.

name
the name of the variable to set.
value
the value of the variable to set.
overwrite
1 to overwrite the variable if it exists, 0 to return success without setting the variable if it already exists.
Returns
0 on success, -1 on error.
Thread safety
This function is not thread safe, consider using SDL_SetEnvironmentVariable() instead.
See also
sDL_SetEnvironmentVariable
C declaration
SDL_setenv_unsafe, defined at SDL3/SDL_stdinc.h 1854:33

Since: 3.2.0

sDL_unsetenv_unsafe :: FunPtr (PtrConst CChar -> IO CInt) Source #

Clear a variable from the environment.

name
the name of the variable to unset.
Returns
0 on success, -1 on error.
Thread safety
This function is not thread safe, consider using SDL_UnsetEnvironmentVariable() instead.
See also
sDL_UnsetEnvironmentVariable
C declaration
SDL_unsetenv_unsafe, defined at SDL3/SDL_stdinc.h 1869:33

Since: 3.2.0

sDL_qsort :: FunPtr (Ptr Void -> CSize -> CSize -> SDL_CompareCallback -> IO ()) Source #

Sort an array.

For example:

    typedef struct {
        int key;
        const char *string;
    } data;

    int SDLCALL compare(const void *a, const void *b)
    {
        const data *A = (const data *)a;
        const data *B = (const data *)b;

        if (A->n < B->n) {
            return -1;
        } else if (B->n < A->n) {
            return 1;
        } else {
            return 0;
        }
    }

    data values[] = {
        { 3, "third" }, { 1, "first" }, { 2, "second" }
    };

    SDL_qsort(values, SDL_arraysize(values), sizeof(values[0]), compare);
    
base
a pointer to the start of the array.
nmemb
the number of elements in the array.
size
the size of the elements in the array.
compare
a function used to compare elements in the array.
Thread safety
It is safe to call this function from any thread.
See also
sDL_bsearch, sDL_qsort_r
C declaration
SDL_qsort, defined at SDL3/SDL_stdinc.h 1931:34

Since: 3.2.0

sDL_bsearch :: FunPtr (PtrConst Void -> PtrConst Void -> CSize -> CSize -> SDL_CompareCallback -> IO (Ptr Void)) Source #

Perform a binary search on a previously sorted array.

For example:

    typedef struct {
        int key;
        const char *string;
    } data;

    int SDLCALL compare(const void *a, const void *b)
    {
        const data *A = (const data *)a;
        const data *B = (const data *)b;

        if (A->n < B->n) {
            return -1;
        } else if (B->n < A->n) {
            return 1;
        } else {
            return 0;
        }
    }

    data values[] = {
        { 1, "first" }, { 2, "second" }, { 3, "third" }
    };
    data key = { 2, NULL };

    data *result = SDL_bsearch(&key, values, SDL_arraysize(values), sizeof(values[0]), compare);
    
key
a pointer to a key equal to the element being searched for.
base
a pointer to the start of the array.
nmemb
the number of elements in the array.
size
the size of the elements in the array.
compare
a function used to compare elements in the array.
Returns
a pointer to the matching element in the array, or NULL if not found.
Thread safety
It is safe to call this function from any thread.
See also
sDL_bsearch_r, sDL_qsort
C declaration
SDL_bsearch, defined at SDL3/SDL_stdinc.h 1981:36

Since: 3.2.0

sDL_qsort_r :: FunPtr (Ptr Void -> CSize -> CSize -> SDL_CompareCallback_r -> Ptr Void -> IO ()) Source #

Sort an array, passing a userdata pointer to the compare function.

For example:

    typedef enum {
        sort_increasing,
        sort_decreasing,
    } sort_method;

    typedef struct {
        int key;
        const char *string;
    } data;

    int SDLCALL compare(const void *userdata, const void *a, const void *b)
    {
        sort_method method = (sort_method)(uintptr_t)userdata;
        const data *A = (const data *)a;
        const data *B = (const data *)b;

        if (A->key < B->key) {
            return (method == sort_increasing) ? -1 : 1;
        } else if (B->key < A->key) {
            return (method == sort_increasing) ? 1 : -1;
        } else {
            return 0;
        }
    }

    data values[] = {
        { 3, "third" }, { 1, "first" }, { 2, "second" }
    };

    SDL_qsort_r(values, SDL_arraysize(values), sizeof(values[0]), compare, (const void *)(uintptr_t)sort_increasing);
    
base
a pointer to the start of the array.
nmemb
the number of elements in the array.
size
the size of the elements in the array.
compare
a function used to compare elements in the array.
userdata
a pointer to pass to the compare function.
Thread safety
It is safe to call this function from any thread.
See also
sDL_bsearch_r, sDL_qsort
C declaration
SDL_qsort_r, defined at SDL3/SDL_stdinc.h 2051:34

Since: 3.2.0

sDL_bsearch_r :: FunPtr (PtrConst Void -> PtrConst Void -> CSize -> CSize -> SDL_CompareCallback_r -> Ptr Void -> IO (Ptr Void)) Source #

Perform a binary search on a previously sorted array, passing a userdata pointer to the compare function.

For example:

    typedef enum {
        sort_increasing,
        sort_decreasing,
    } sort_method;

    typedef struct {
        int key;
        const char *string;
    } data;

    int SDLCALL compare(const void *userdata, const void *a, const void *b)
    {
        sort_method method = (sort_method)(uintptr_t)userdata;
        const data *A = (const data *)a;
        const data *B = (const data *)b;

        if (A->key < B->key) {
            return (method == sort_increasing) ? -1 : 1;
        } else if (B->key < A->key) {
            return (method == sort_increasing) ? 1 : -1;
        } else {
            return 0;
        }
    }

    data values[] = {
        { 1, "first" }, { 2, "second" }, { 3, "third" }
    };
    data key = { 2, NULL };

    data *result = SDL_bsearch_r(&key, values, SDL_arraysize(values), sizeof(values[0]), compare, (const void *)(uintptr_t)sort_increasing);
    
key
a pointer to a key equal to the element being searched for.
base
a pointer to the start of the array.
nmemb
the number of elements in the array.
size
the size of the elements in the array.
compare
a function used to compare elements in the array.
userdata
a pointer to pass to the compare function.
Returns
a pointer to the matching element in the array, or NULL if not found.
Thread safety
It is safe to call this function from any thread.
See also
sDL_bsearch, sDL_qsort_r
C declaration
SDL_bsearch_r, defined at SDL3/SDL_stdinc.h 2109:36

Since: 3.2.0

sDL_abs :: FunPtr (CInt -> IO CInt) Source #

Compute the absolute value of x.

x
an integer value.
Returns
the absolute value of x.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_abs, defined at SDL3/SDL_stdinc.h 2121:33

Since: 3.2.0

sDL_isalpha :: FunPtr (CInt -> IO CInt) Source #

Query if a character is alphabetic (a letter).

WARNING: Regardless of system locale, this will only treat ASCII values for English 'a-z' and 'A-Z' as true.

x
character value to check.
Returns
non-zero if x falls within the character class, zero otherwise.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_isalpha, defined at SDL3/SDL_stdinc.h 2196:33

Since: 3.2.0

sDL_isalnum :: FunPtr (CInt -> IO CInt) Source #

Query if a character is alphabetic (a letter) or a number.

WARNING: Regardless of system locale, this will only treat ASCII values for English 'a-z', 'A-Z', and '0-9' as true.

x
character value to check.
Returns
non-zero if x falls within the character class, zero otherwise.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_isalnum, defined at SDL3/SDL_stdinc.h 2211:33

Since: 3.2.0

sDL_isblank :: FunPtr (CInt -> IO CInt) Source #

Report if a character is blank (a space or tab).

WARNING: Regardless of system locale, this will only treat ASCII values 0x20 (space) or 0x9 (tab) as true.

x
character value to check.
Returns
non-zero if x falls within the character class, zero otherwise.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_isblank, defined at SDL3/SDL_stdinc.h 2226:33

Since: 3.2.0

sDL_iscntrl :: FunPtr (CInt -> IO CInt) Source #

Report if a character is a control character.

WARNING: Regardless of system locale, this will only treat ASCII values 0 through 0x1F, and 0x7F, as true.

x
character value to check.
Returns
non-zero if x falls within the character class, zero otherwise.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_iscntrl, defined at SDL3/SDL_stdinc.h 2241:33

Since: 3.2.0

sDL_isdigit :: FunPtr (CInt -> IO CInt) Source #

Report if a character is a numeric digit.

WARNING: Regardless of system locale, this will only treat ASCII values '0' (0x30) through '9' (0x39), as true.

x
character value to check.
Returns
non-zero if x falls within the character class, zero otherwise.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_isdigit, defined at SDL3/SDL_stdinc.h 2256:33

Since: 3.2.0

sDL_isxdigit :: FunPtr (CInt -> IO CInt) Source #

Report if a character is a hexadecimal digit.

WARNING: Regardless of system locale, this will only treat ASCII values 'A' through 'F', 'a' through 'f', and '0' through '9', as true.

x
character value to check.
Returns
non-zero if x falls within the character class, zero otherwise.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_isxdigit, defined at SDL3/SDL_stdinc.h 2271:33

Since: 3.2.0

sDL_ispunct :: FunPtr (CInt -> IO CInt) Source #

Report if a character is a punctuation mark.

WARNING: Regardless of system locale, this is equivalent to ((SDL_isgraph(x)) && (!SDL_isalnum(x))).

x
character value to check.
Returns
non-zero if x falls within the character class, zero otherwise.
Thread safety
It is safe to call this function from any thread.
See also
sDL_isgraph, sDL_isalnum
C declaration
SDL_ispunct, defined at SDL3/SDL_stdinc.h 2289:33

Since: 3.2.0

sDL_isspace :: FunPtr (CInt -> IO CInt) Source #

Report if a character is whitespace.

WARNING: Regardless of system locale, this will only treat the following ASCII values as true:

  • space (0x20)
  • tab (0x09)
  • newline (0x0A)
  • vertical tab (0x0B)
  • form feed (0x0C)
  • return (0x0D)
x
character value to check.
Returns
non-zero if x falls within the character class, zero otherwise.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_isspace, defined at SDL3/SDL_stdinc.h 2311:33

Since: 3.2.0

sDL_isupper :: FunPtr (CInt -> IO CInt) Source #

Report if a character is upper case.

WARNING: Regardless of system locale, this will only treat ASCII values 'A' through 'Z' as true.

x
character value to check.
Returns
non-zero if x falls within the character class, zero otherwise.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_isupper, defined at SDL3/SDL_stdinc.h 2326:33

Since: 3.2.0

sDL_islower :: FunPtr (CInt -> IO CInt) Source #

Report if a character is lower case.

WARNING: Regardless of system locale, this will only treat ASCII values 'a' through 'z' as true.

x
character value to check.
Returns
non-zero if x falls within the character class, zero otherwise.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_islower, defined at SDL3/SDL_stdinc.h 2341:33

Since: 3.2.0

sDL_isprint :: FunPtr (CInt -> IO CInt) Source #

Report if a character is "printable".

Be advised that "printable" has a definition that goes back to text terminals from the dawn of computing, making this a sort of special case function that is not suitable for Unicode (or most any) text management.

WARNING: Regardless of system locale, this will only treat ASCII values ' ' (0x20) through '~' (0x7E) as true.

x
character value to check.
Returns
non-zero if x falls within the character class, zero otherwise.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_isprint, defined at SDL3/SDL_stdinc.h 2360:33

Since: 3.2.0

sDL_isgraph :: FunPtr (CInt -> IO CInt) Source #

Report if a character is any "printable" except space.

Be advised that "printable" has a definition that goes back to text terminals from the dawn of computing, making this a sort of special case function that is not suitable for Unicode (or most any) text management.

WARNING: Regardless of system locale, this is equivalent to (SDL_isprint(x)) && ((x) != ' ').

x
character value to check.
Returns
non-zero if x falls within the character class, zero otherwise.
Thread safety
It is safe to call this function from any thread.
See also
sDL_isprint
C declaration
SDL_isgraph, defined at SDL3/SDL_stdinc.h 2381:33

Since: 3.2.0

sDL_toupper :: FunPtr (CInt -> IO CInt) Source #

Convert low-ASCII English letters to uppercase.

WARNING: Regardless of system locale, this will only convert ASCII values 'a' through 'z' to uppercase.

This function returns the uppercase equivalent of x. If a character cannot be converted, or is already uppercase, this function returns x.

x
character value to check.
Returns
capitalized version of x, or x if no conversion available.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_toupper, defined at SDL3/SDL_stdinc.h 2399:33

Since: 3.2.0

sDL_tolower :: FunPtr (CInt -> IO CInt) Source #

Convert low-ASCII English letters to lowercase.

WARNING: Regardless of system locale, this will only convert ASCII values 'A' through 'Z' to lowercase.

This function returns the lowercase equivalent of x. If a character cannot be converted, or is already lowercase, this function returns x.

x
character value to check.
Returns
lowercase version of x, or x if no conversion available.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_tolower, defined at SDL3/SDL_stdinc.h 2417:33

Since: 3.2.0

sDL_crc16 :: FunPtr (Uint16 -> PtrConst Void -> CSize -> IO Uint16) Source #

Calculate a CRC-16 value.

https://en.wikipedia.org/wiki/Cyclic_redundancy_check

This function can be called multiple times, to stream data to be checksummed in blocks. Each call must provide the previous CRC-16 return value to be updated with the next block. The first call to this function for a set of blocks should pass in a zero CRC value.

crc
the current checksum for this data set, or 0 for a new data set.
data
a new block of data to add to the checksum.
len
the size, in bytes, of the new block of data.
Returns
a CRC-16 checksum value of all blocks in the data set.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_crc16, defined at SDL3/SDL_stdinc.h 2438:36

Since: 3.2.0

sDL_crc32 :: FunPtr (Uint32 -> PtrConst Void -> CSize -> IO Uint32) Source #

Calculate a CRC-32 value.

https://en.wikipedia.org/wiki/Cyclic_redundancy_check

This function can be called multiple times, to stream data to be checksummed in blocks. Each call must provide the previous CRC-32 return value to be updated with the next block. The first call to this function for a set of blocks should pass in a zero CRC value.

crc
the current checksum for this data set, or 0 for a new data set.
data
a new block of data to add to the checksum.
len
the size, in bytes, of the new block of data.
Returns
a CRC-32 checksum value of all blocks in the data set.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_crc32, defined at SDL3/SDL_stdinc.h 2459:36

Since: 3.2.0

sDL_murmur3_32 :: FunPtr (PtrConst Void -> CSize -> Uint32 -> IO Uint32) Source #

Calculate a 32-bit MurmurHash3 value for a block of data.

https://en.wikipedia.org/wiki/MurmurHash

A seed may be specified, which changes the final results consistently, but this does not work like SDL_crc16 and SDL_crc32: you can't feed a previous result from this function back into itself as the next seed value to calculate a hash in chunks; it won't produce the same hash as it would if the same data was provided in a single call.

If you aren't sure what to provide for a seed, zero is fine. Murmur3 is not cryptographically secure, so it shouldn't be used for hashing top-secret data.

data
the data to be hashed.
len
the size of data, in bytes.
seed
a value that alters the final hash value.
Returns
a Murmur3 32-bit hash value.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_murmur3_32, defined at SDL3/SDL_stdinc.h 2485:36

Since: 3.2.0

sDL_memcpy :: FunPtr (Ptr Void -> PtrConst Void -> CSize -> IO (Ptr Void)) Source #

Copy non-overlapping memory.

The memory regions must not overlap. If they do, use SDL_memmove() instead.

dst
The destination memory region. Must not be NULL, and must not overlap with src.
src
The source memory region. Must not be NULL, and must not overlap with dst.
len
The length in bytes of both dst and src.
Returns
dst.
Thread safety
It is safe to call this function from any thread.
See also
sDL_memmove
C declaration
SDL_memcpy, defined at SDL3/SDL_stdinc.h 2505:36

Since: 3.2.0

sDL_memmove :: FunPtr (Ptr Void -> PtrConst Void -> CSize -> IO (Ptr Void)) Source #

Copy memory ranges that might overlap.

It is okay for the memory regions to overlap. If you are confident that the regions never overlap, using SDL_memcpy() may improve performance.

dst
The destination memory region. Must not be NULL.
src
The source memory region. Must not be NULL.
len
The length in bytes of both dst and src.
Returns
dst.
Thread safety
It is safe to call this function from any thread.
See also
sDL_memcpy
C declaration
SDL_memmove, defined at SDL3/SDL_stdinc.h 2561:36

Since: 3.2.0

sDL_memset :: FunPtr (Ptr Void -> CInt -> CSize -> IO (Ptr Void)) Source #

Initialize all bytes of buffer of memory to a specific value.

This function will set len bytes, pointed to by dst, to the value specified in c.

Despite c being an int instead of a char, this only operates on bytes; c must be a value between 0 and 255, inclusive.

dst
the destination memory region. Must not be NULL.
c
the byte value to set.
len
the length, in bytes, to set in dst.
Returns
dst.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_memset, defined at SDL3/SDL_stdinc.h 2589:36

Since: 3.2.0

sDL_memset4 :: FunPtr (Ptr Void -> Uint32 -> CSize -> IO (Ptr Void)) Source #

Initialize all 32-bit words of buffer of memory to a specific value.

This function will set a buffer of dwords Uint32 values, pointed to by dst, to the value specified in val.

Unlike SDL_memset, this sets 32-bit values, not bytes, so it's not limited to a range of 0-255.

dst
the destination memory region. Must not be NULL.
val
the Uint32 value to set.
dwords
the number of Uint32 values to set in dst.
Returns
dst.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_memset4, defined at SDL3/SDL_stdinc.h 2609:36

Since: 3.2.0

sDL_memcmp :: FunPtr (PtrConst Void -> PtrConst Void -> CSize -> IO CInt) Source #

Compare two buffers of memory.

s1
the first buffer to compare. NULL is not permitted!
s2
the second buffer to compare. NULL is not permitted!
len
the number of bytes to compare between the buffers.
Returns
less than zero if s1 is "less than" s2, greater than zero if s1 is "greater than" s2, and zero if the buffers match exactly for len bytes.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_memcmp, defined at SDL3/SDL_stdinc.h 2691:33

Since: 3.2.0

sDL_wcslen :: FunPtr (PtrConst CWchar -> IO CSize) Source #

This works exactly like wcslen() but doesn't require access to a C runtime.

Counts the number of wchar_t values in wstr, excluding the null terminator.

Like SDL_strlen only counts bytes and not codepoints in a UTF-8 string, this counts wchar_t values in a string, even if the string's encoding is of variable width, like UTF-16.

Also be aware that wchar_t is different sizes on different platforms (4 bytes on Linux, 2 on Windows, etc).

wstr
The null-terminated wide string to read. Must not be NULL.
Returns
the length (in wchar_t values, excluding the null terminator) of wstr.
Thread safety
It is safe to call this function from any thread.
See also
sDL_wcsnlen, sDL_utf8strlen, sDL_utf8strnlen
C declaration
SDL_wcslen, defined at SDL3/SDL_stdinc.h 2718:36

Since: 3.2.0

sDL_wcsnlen :: FunPtr (PtrConst CWchar -> CSize -> IO CSize) Source #

This works exactly like wcsnlen() but doesn't require access to a C runtime.

Counts up to a maximum of maxlen wchar_t values in wstr, excluding the null terminator.

Like SDL_strnlen only counts bytes and not codepoints in a UTF-8 string, this counts wchar_t values in a string, even if the string's encoding is of variable width, like UTF-16.

Also be aware that wchar_t is different sizes on different platforms (4 bytes on Linux, 2 on Windows, etc).

Also, maxlen is a count of wide characters, not bytes!

wstr
The null-terminated wide string to read. Must not be NULL.
maxlen
The maximum amount of wide characters to count.
Returns
the length (in wide characters, excluding the null terminator) of wstr but never more than maxlen.
Thread safety
It is safe to call this function from any thread.
See also
sDL_wcslen, sDL_utf8strlen, sDL_utf8strnlen
C declaration
SDL_wcsnlen, defined at SDL3/SDL_stdinc.h 2749:36

Since: 3.2.0

sDL_wcslcpy :: FunPtr (Ptr CWchar -> PtrConst CWchar -> CSize -> IO CSize) Source #

Copy a wide string.

This function copies maxlen - 1 wide characters from src to dst, then appends a null terminator.

src and dst must not overlap.

If maxlen is 0, no wide characters are copied and no null terminator is written.

dst
The destination buffer. Must not be NULL, and must not overlap with src.
src
The null-terminated wide string to copy. Must not be NULL, and must not overlap with dst.
maxlen
The length (in wide characters) of the destination buffer.
Returns
the length (in wide characters, excluding the null terminator) of src.
Thread safety
It is safe to call this function from any thread.
See also
sDL_wcslcat
C declaration
SDL_wcslcpy, defined at SDL3/SDL_stdinc.h 2776:36

Since: 3.2.0

sDL_wcslcat :: FunPtr (Ptr CWchar -> PtrConst CWchar -> CSize -> IO CSize) Source #

Concatenate wide strings.

This function appends up to maxlen - SDL_wcslen(dst) - 1 wide characters from src to the end of the wide string in dst, then appends a null terminator.

src and dst must not overlap.

If maxlen - SDL_wcslen(dst) - 1 is less than or equal to 0, then dst is unmodified.

dst
The destination buffer already containing the first null-terminated wide string. Must not be NULL and must not overlap with src.
src
The second null-terminated wide string. Must not be NULL, and must not overlap with dst.
maxlen
The length (in wide characters) of the destination buffer.
Returns
the length (in wide characters, excluding the null terminator) of the string in dst plus the length of src.
Thread safety
It is safe to call this function from any thread.
See also
sDL_wcslcpy
C declaration
SDL_wcslcat, defined at SDL3/SDL_stdinc.h 2805:36

Since: 3.2.0

sDL_wcsdup :: FunPtr (PtrConst CWchar -> IO (Ptr CWchar)) Source #

Allocate a copy of a wide string.

This allocates enough space for a null-terminated copy of wstr, using SDL_malloc, and then makes a copy of the string into this space.

The returned string is owned by the caller, and should be passed to SDL_free when no longer needed.

wstr
the string to copy.
Returns
a pointer to the newly-allocated wide string.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_wcsdup, defined at SDL3/SDL_stdinc.h 2823:39

Since: 3.2.0

sDL_wcsstr :: FunPtr (PtrConst CWchar -> PtrConst CWchar -> IO (Ptr CWchar)) Source #

Search a wide string for the first instance of a specific substring.

The search ends once it finds the requested substring, or a null terminator byte to end the string.

Note that this looks for strings of wide characters, not codepoints, so it's legal to search for malformed and incomplete UTF-16 sequences.

haystack
the wide string to search. Must not be NULL.
needle
the wide string to search for. Must not be NULL.
Returns
a pointer to the first instance of needle in the string, or NULL if not found.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_wcsstr, defined at SDL3/SDL_stdinc.h 2843:39

Since: 3.2.0

sDL_wcsnstr :: FunPtr (PtrConst CWchar -> PtrConst CWchar -> CSize -> IO (Ptr CWchar)) Source #

Search a wide string, up to n wide chars, for the first instance of a specific substring.

The search ends once it finds the requested substring, or a null terminator value to end the string, or maxlen wide character have been examined. It is possible to use this function on a wide string without a null terminator.

Note that this looks for strings of wide characters, not codepoints, so it's legal to search for malformed and incomplete UTF-16 sequences.

haystack
the wide string to search. Must not be NULL.
needle
the wide string to search for. Must not be NULL.
maxlen
the maximum number of wide characters to search in haystack.
Returns
a pointer to the first instance of needle in the string, or NULL if not found.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_wcsnstr, defined at SDL3/SDL_stdinc.h 2868:39

Since: 3.2.0

sDL_wcscmp :: FunPtr (PtrConst CWchar -> PtrConst CWchar -> IO CInt) Source #

Compare two null-terminated wide strings.

This only compares wchar_t values until it hits a null-terminating character; it does not care if the string is well-formed UTF-16 (or UTF-32, depending on your platform's wchar_t size), or uses valid Unicode values.

str1
the first string to compare. NULL is not permitted!
str2
the second string to compare. NULL is not permitted!
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_wcscmp, defined at SDL3/SDL_stdinc.h 2887:33

Since: 3.2.0

sDL_wcsncmp :: FunPtr (PtrConst CWchar -> PtrConst CWchar -> CSize -> IO CInt) Source #

Compare two wide strings up to a number of wchar_t values.

This only compares wchar_t values; it does not care if the string is well-formed UTF-16 (or UTF-32, depending on your platform's wchar_t size), or uses valid Unicode values.

Note that while this function is intended to be used with UTF-16 (or UTF-32, depending on your platform's definition of wchar_t), it is comparing raw wchar_t values and not Unicode codepoints: maxlen specifies a wchar_t limit! If the limit lands in the middle of a multi-wchar UTF-16 sequence, it will only compare a portion of the final character.

maxlen specifies a maximum number of wchar_t to compare; if the strings match to this number of wide chars (or both have matched to a null-terminator character before this count), they will be considered equal.

str1
the first string to compare. NULL is not permitted!
str2
the second string to compare. NULL is not permitted!
maxlen
the maximum number of wchar_t to compare.
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_wcsncmp, defined at SDL3/SDL_stdinc.h 2918:33

Since: 3.2.0

sDL_wcscasecmp :: FunPtr (PtrConst CWchar -> PtrConst CWchar -> IO CInt) Source #

Compare two null-terminated wide strings, case-insensitively.

This will work with Unicode strings, using a technique called "case-folding" to handle the vast majority of case-sensitive human languages regardless of system locale. It can deal with expanding values: a German Eszett character can compare against two ASCII 's' chars and be considered a match, for example. A notable exception: it does not handle the Turkish 'i' character; human language is complicated!

Depending on your platform, "wchar_t" might be 2 bytes, and expected to be UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this handles Unicode, it expects the string to be well-formed and not a null-terminated string of arbitrary bytes. Characters that are not valid UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT CHARACTER), which is to say two strings of random bits may turn out to match if they convert to the same amount of replacement characters.

str1
the first string to compare. NULL is not permitted!
str2
the second string to compare. NULL is not permitted!
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_wcscasecmp, defined at SDL3/SDL_stdinc.h 2948:33

Since: 3.2.0

sDL_wcsncasecmp :: FunPtr (PtrConst CWchar -> PtrConst CWchar -> CSize -> IO CInt) Source #

Compare two wide strings, case-insensitively, up to a number of wchar_t.

This will work with Unicode strings, using a technique called "case-folding" to handle the vast majority of case-sensitive human languages regardless of system locale. It can deal with expanding values: a German Eszett character can compare against two ASCII 's' chars and be considered a match, for example. A notable exception: it does not handle the Turkish 'i' character; human language is complicated!

Depending on your platform, "wchar_t" might be 2 bytes, and expected to be UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this handles Unicode, it expects the string to be well-formed and not a null-terminated string of arbitrary bytes. Characters that are not valid UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT CHARACTER), which is to say two strings of random bits may turn out to match if they convert to the same amount of replacement characters.

Note that while this function might deal with variable-sized characters, maxlen specifies a wchar limit! If the limit lands in the middle of a multi-byte UTF-16 sequence, it may convert a portion of the final character to one or more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not to overflow a buffer.

maxlen specifies a maximum number of wchar_t values to compare; if the strings match to this number of wchar_t (or both have matched to a null-terminator character before this number of bytes), they will be considered equal.

str1
the first string to compare. NULL is not permitted!
str2
the second string to compare. NULL is not permitted!
maxlen
the maximum number of wchar_t values to compare.
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_wcsncasecmp, defined at SDL3/SDL_stdinc.h 2990:33

Since: 3.2.0

sDL_strlen :: FunPtr (PtrConst CChar -> IO CSize) Source #

This works exactly like strlen() but doesn't require access to a C runtime.

Counts the bytes in str, excluding the null terminator.

If you need the length of a UTF-8 string, consider using SDL_utf8strlen().

str
The null-terminated string to read. Must not be NULL.
Returns
the length (in bytes, excluding the null terminator) of src.
Thread safety
It is safe to call this function from any thread.
See also
sDL_strnlen, sDL_utf8strlen, sDL_utf8strnlen
C declaration
SDL_strlen, defined at SDL3/SDL_stdinc.h 3037:36

Since: 3.2.0

sDL_strnlen :: FunPtr (PtrConst CChar -> CSize -> IO CSize) Source #

This works exactly like strnlen() but doesn't require access to a C runtime.

Counts up to a maximum of maxlen bytes in str, excluding the null terminator.

If you need the length of a UTF-8 string, consider using SDL_utf8strnlen().

str
The null-terminated string to read. Must not be NULL.
maxlen
The maximum amount of bytes to count.
Returns
the length (in bytes, excluding the null terminator) of src but never more than maxlen.
Thread safety
It is safe to call this function from any thread.
See also
sDL_strlen, sDL_utf8strlen, sDL_utf8strnlen
C declaration
SDL_strnlen, defined at SDL3/SDL_stdinc.h 3061:36

Since: 3.2.0

sDL_strlcpy :: FunPtr (Ptr CChar -> PtrConst CChar -> CSize -> IO CSize) Source #

Copy a string.

This function copies up to maxlen - 1 characters from src to dst, then appends a null terminator.

If maxlen is 0, no characters are copied and no null terminator is written.

If you want to copy an UTF-8 string but need to ensure that multi-byte sequences are not truncated, consider using SDL_utf8strlcpy().

dst
The destination buffer. Must not be NULL, and must not overlap with src.
src
The null-terminated string to copy. Must not be NULL, and must not overlap with dst.
maxlen
The length (in characters) of the destination buffer.
Returns
the length (in characters, excluding the null terminator) of src.
Thread safety
It is safe to call this function from any thread.
See also
sDL_strlcat, sDL_utf8strlcpy
C declaration
SDL_strlcpy, defined at SDL3/SDL_stdinc.h 3090:36

Since: 3.2.0

sDL_utf8strlcpy :: FunPtr (Ptr CChar -> PtrConst CChar -> CSize -> IO CSize) Source #

Copy an UTF-8 string.

This function copies up to dst_bytes - 1 bytes from src to dst while also ensuring that the string written to dst does not end in a truncated multi-byte sequence. Finally, it appends a null terminator.

src and dst must not overlap.

Note that unlike SDL_strlcpy(), this function returns the number of bytes written, not the length of src.

dst
The destination buffer. Must not be NULL, and must not overlap with src.
src
The null-terminated UTF-8 string to copy. Must not be NULL, and must not overlap with dst.
dst_bytes
The length (in bytes) of the destination buffer. Must not be 0.
Returns
the number of bytes written, excluding the null terminator.
Thread safety
It is safe to call this function from any thread.
See also
sDL_strlcpy
C declaration
SDL_utf8strlcpy, defined at SDL3/SDL_stdinc.h 3118:36

Since: 3.2.0

sDL_strlcat :: FunPtr (Ptr CChar -> PtrConst CChar -> CSize -> IO CSize) Source #

Concatenate strings.

This function appends up to maxlen - SDL_strlen(dst) - 1 characters from src to the end of the string in dst, then appends a null terminator.

src and dst must not overlap.

If maxlen - SDL_strlen(dst) - 1 is less than or equal to 0, then dst is unmodified.

dst
The destination buffer already containing the first null-terminated string. Must not be NULL and must not overlap with src.
src
The second null-terminated string. Must not be NULL, and must not overlap with dst.
maxlen
The length (in characters) of the destination buffer.
Returns
the length (in characters, excluding the null terminator) of the string in dst plus the length of src.
Thread safety
It is safe to call this function from any thread.
See also
sDL_strlcpy
C declaration
SDL_strlcat, defined at SDL3/SDL_stdinc.h 3146:36

Since: 3.2.0

sDL_strdup :: FunPtr (PtrConst CChar -> IO (Ptr CChar)) Source #

Allocate a copy of a string.

This allocates enough space for a null-terminated copy of str, using SDL_malloc, and then makes a copy of the string into this space.

The returned string is owned by the caller, and should be passed to SDL_free when no longer needed.

str
the string to copy.
Returns
a pointer to the newly-allocated string.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strdup, defined at SDL3/SDL_stdinc.h 3164:47

Since: 3.2.0

sDL_strndup :: FunPtr (PtrConst CChar -> CSize -> IO (Ptr CChar)) Source #

Allocate a copy of a string, up to n characters.

This allocates enough space for a null-terminated copy of str, up to maxlen bytes, using SDL_malloc, and then makes a copy of the string into this space.

If the string is longer than maxlen bytes, the returned string will be maxlen bytes long, plus a null-terminator character that isn't included in the count.

The returned string is owned by the caller, and should be passed to SDL_free when no longer needed.

str
the string to copy.
maxlen
the maximum length of the copied string, not counting the null-terminator character.
Returns
a pointer to the newly-allocated string.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strndup, defined at SDL3/SDL_stdinc.h 3189:47

Since: 3.2.0

sDL_strrev :: FunPtr (Ptr CChar -> IO (Ptr CChar)) Source #

Reverse a string's contents.

This reverses a null-terminated string in-place. Only the content of the string is reversed; the null-terminator character remains at the end of the reversed string.

WARNING: This function reverses the bytes of the string, not the codepoints. If str is a UTF-8 string with Unicode codepoints > 127, this will ruin the string data. You should only use this function on strings that are completely comprised of low ASCII characters.

str
the string to reverse.
Returns
str.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strrev, defined at SDL3/SDL_stdinc.h 3210:36

Since: 3.2.0

sDL_strupr :: FunPtr (Ptr CChar -> IO (Ptr CChar)) Source #

Convert a string to uppercase.

WARNING: Regardless of system locale, this will only convert ASCII values 'A' through 'Z' to uppercase.

This function operates on a null-terminated string of bytes even if it is malformed UTF-8! and converts ASCII characters 'a' through 'z' to their uppercase equivalents in-place, returning the original str pointer.

str
the string to convert in-place. Can not be NULL.
Returns
the str pointer passed into this function.
Thread safety
It is safe to call this function from any thread.
See also
sDL_strlwr
C declaration
SDL_strupr, defined at SDL3/SDL_stdinc.h 3231:36

Since: 3.2.0

sDL_strlwr :: FunPtr (Ptr CChar -> IO (Ptr CChar)) Source #

Convert a string to lowercase.

WARNING: Regardless of system locale, this will only convert ASCII values 'A' through 'Z' to lowercase.

This function operates on a null-terminated string of bytes even if it is malformed UTF-8! and converts ASCII characters 'A' through 'Z' to their lowercase equivalents in-place, returning the original str pointer.

str
the string to convert in-place. Can not be NULL.
Returns
the str pointer passed into this function.
Thread safety
It is safe to call this function from any thread.
See also
sDL_strupr
C declaration
SDL_strlwr, defined at SDL3/SDL_stdinc.h 3252:36

Since: 3.2.0

sDL_strchr :: FunPtr (PtrConst CChar -> CInt -> IO (Ptr CChar)) Source #

Search a string for the first instance of a specific byte.

The search ends once it finds the requested byte value, or a null terminator byte to end the string.

Note that this looks for bytes, not characters, so you cannot match against a Unicode codepoint > 255, regardless of character encoding.

str
the string to search. Must not be NULL.
c
the byte value to search for.
Returns
a pointer to the first instance of c in the string, or NULL if not found.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strchr, defined at SDL3/SDL_stdinc.h 3272:36

Since: 3.2.0

sDL_strrchr :: FunPtr (PtrConst CChar -> CInt -> IO (Ptr CChar)) Source #

Search a string for the last instance of a specific byte.

The search must go until it finds a null terminator byte to end the string.

Note that this looks for bytes, not characters, so you cannot match against a Unicode codepoint > 255, regardless of character encoding.

str
the string to search. Must not be NULL.
c
the byte value to search for.
Returns
a pointer to the last instance of c in the string, or NULL if not found.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strrchr, defined at SDL3/SDL_stdinc.h 3291:36

Since: 3.2.0

sDL_strstr :: FunPtr (PtrConst CChar -> PtrConst CChar -> IO (Ptr CChar)) Source #

Search a string for the first instance of a specific substring.

The search ends once it finds the requested substring, or a null terminator byte to end the string.

Note that this looks for strings of bytes, not characters, so it's legal to search for malformed and incomplete UTF-8 sequences.

haystack
the string to search. Must not be NULL.
needle
the string to search for. Must not be NULL.
Returns
a pointer to the first instance of needle in the string, or NULL if not found.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strstr, defined at SDL3/SDL_stdinc.h 3311:36

Since: 3.2.0

sDL_strnstr :: FunPtr (PtrConst CChar -> PtrConst CChar -> CSize -> IO (Ptr CChar)) Source #

Search a string, up to n bytes, for the first instance of a specific substring.

The search ends once it finds the requested substring, or a null terminator byte to end the string, or maxlen bytes have been examined. It is possible to use this function on a string without a null terminator.

Note that this looks for strings of bytes, not characters, so it's legal to search for malformed and incomplete UTF-8 sequences.

haystack
the string to search. Must not be NULL.
needle
the string to search for. Must not be NULL.
maxlen
the maximum number of bytes to search in haystack.
Returns
a pointer to the first instance of needle in the string, or NULL if not found.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strnstr, defined at SDL3/SDL_stdinc.h 3334:36

Since: 3.2.0

sDL_strcasestr :: FunPtr (PtrConst CChar -> PtrConst CChar -> IO (Ptr CChar)) Source #

Search a UTF-8 string for the first instance of a specific substring, case-insensitively.

This will work with Unicode strings, using a technique called "case-folding" to handle the vast majority of case-sensitive human languages regardless of system locale. It can deal with expanding values: a German Eszett character can compare against two ASCII 's' chars and be considered a match, for example. A notable exception: it does not handle the Turkish 'i' character; human language is complicated!

Since this handles Unicode, it expects the strings to be well-formed UTF-8 and not a null-terminated string of arbitrary bytes. Bytes that are not valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT CHARACTER), which is to say two strings of random bits may turn out to match if they convert to the same amount of replacement characters.

haystack
the string to search. Must not be NULL.
needle
the string to search for. Must not be NULL.
Returns
a pointer to the first instance of needle in the string, or NULL if not found.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strcasestr, defined at SDL3/SDL_stdinc.h 3362:36

Since: 3.2.0

sDL_strtok_r :: FunPtr (Ptr CChar -> PtrConst CChar -> Ptr (Ptr CChar) -> IO (Ptr CChar)) Source #

This works exactly like strtok_r() but doesn't require access to a C runtime.

Break a string up into a series of tokens.

To start tokenizing a new string, str should be the non-NULL address of the string to start tokenizing. Future calls to get the next token from the same string should specify a NULL.

Note that this function will overwrite pieces of str with null chars to split it into tokens. This function cannot be used with const/read-only strings!

saveptr just needs to point to a char * that can be overwritten; SDL will use this to save tokenizing state between calls. It is initialized if str is non-NULL, and used to resume tokenizing when str is NULL.

str
the string to tokenize, or NULL to continue tokenizing.
delim
the delimiter string that separates tokens.
saveptr
pointer to a char *, used for ongoing state.
Returns
A pointer to the next token, or NULL if no tokens remain.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strtok_r, defined at SDL3/SDL_stdinc.h 3391:36

Since: 3.2.0

sDL_utf8strlen :: FunPtr (PtrConst CChar -> IO CSize) Source #

Count the number of codepoints in a UTF-8 string.

Counts the codepoints, not bytes, in str, excluding the null terminator.

If you need to count the bytes in a string instead, consider using SDL_strlen().

Since this handles Unicode, it expects the strings to be well-formed UTF-8 and not a null-terminated string of arbitrary bytes. Bytes that are not valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT CHARACTER), so a malformed or incomplete UTF-8 sequence might increase the count by several replacement characters.

str
The null-terminated UTF-8 string to read. Must not be NULL.
Returns
The length (in codepoints, excluding the null terminator) of src.
Thread safety
It is safe to call this function from any thread.
See also
sDL_utf8strnlen, sDL_strlen
C declaration
SDL_utf8strlen, defined at SDL3/SDL_stdinc.h 3419:36

Since: 3.2.0

sDL_utf8strnlen :: FunPtr (PtrConst CChar -> CSize -> IO CSize) Source #

Count the number of codepoints in a UTF-8 string, up to n bytes.

Counts the codepoints, not bytes, in str, excluding the null terminator.

If you need to count the bytes in a string instead, consider using SDL_strnlen().

The counting stops at bytes bytes (not codepoints!). This seems counterintuitive, but makes it easy to express the total size of the string's buffer.

Since this handles Unicode, it expects the strings to be well-formed UTF-8 and not a null-terminated string of arbitrary bytes. Bytes that are not valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT CHARACTER), so a malformed or incomplete UTF-8 sequence might increase the count by several replacement characters.

str
The null-terminated UTF-8 string to read. Must not be NULL.
bytes
The maximum amount of bytes to count.
Returns
The length (in codepoints, excluding the null terminator) of src but never more than maxlen.
Thread safety
It is safe to call this function from any thread.
See also
sDL_utf8strlen, sDL_strnlen
C declaration
SDL_utf8strnlen, defined at SDL3/SDL_stdinc.h 3452:36

Since: 3.2.0

sDL_itoa :: FunPtr (CInt -> Ptr CChar -> CInt -> IO (Ptr CChar)) Source #

Convert an integer into a string.

This requires a radix to specified for string format. Specifying 10 produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 to 36.

Note that this function will overflow a buffer if str is not large enough to hold the output! It may be safer to use SDL_snprintf to clamp output, or SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate much more space than you expect to use (and don't forget possible negative signs, null terminator bytes, etc).

value
the integer to convert.
str
the buffer to write the string into.
radix
the radix to use for string generation.
Returns
str.
Thread safety
It is safe to call this function from any thread.
See also
sDL_uitoa, SDL_ltoa, sDL_lltoa
C declaration
SDL_itoa, defined at SDL3/SDL_stdinc.h 3480:36

Since: 3.2.0

sDL_uitoa :: FunPtr (CUInt -> Ptr CChar -> CInt -> IO (Ptr CChar)) Source #

Convert an unsigned integer into a string.

This requires a radix to specified for string format. Specifying 10 produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 to 36.

Note that this function will overflow a buffer if str is not large enough to hold the output! It may be safer to use SDL_snprintf to clamp output, or SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate much more space than you expect to use (and don't forget null terminator bytes, etc).

value
the unsigned integer to convert.
str
the buffer to write the string into.
radix
the radix to use for string generation.
Returns
str.
Thread safety
It is safe to call this function from any thread.
See also
sDL_itoa, SDL_ultoa, sDL_ulltoa
C declaration
SDL_uitoa, defined at SDL3/SDL_stdinc.h 3508:36

Since: 3.2.0

sDL_lltoa :: FunPtr (CLLong -> Ptr CChar -> CInt -> IO (Ptr CChar)) Source #

Convert a long long integer into a string.

This requires a radix to specified for string format. Specifying 10 produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 to 36.

Note that this function will overflow a buffer if str is not large enough to hold the output! It may be safer to use SDL_snprintf to clamp output, or SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate much more space than you expect to use (and don't forget possible negative signs, null terminator bytes, etc).

value
the long long integer to convert.
str
the buffer to write the string into.
radix
the radix to use for string generation.
Returns
str.
Thread safety
It is safe to call this function from any thread.
See also
sDL_ulltoa, sDL_itoa, SDL_ltoa
C declaration
SDL_lltoa, defined at SDL3/SDL_stdinc.h 3594:36

Since: 3.2.0

sDL_ulltoa :: FunPtr (CULLong -> Ptr CChar -> CInt -> IO (Ptr CChar)) Source #

Convert an unsigned long long integer into a string.

This requires a radix to specified for string format. Specifying 10 produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 to 36.

Note that this function will overflow a buffer if str is not large enough to hold the output! It may be safer to use SDL_snprintf to clamp output, or SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate much more space than you expect to use (and don't forget null terminator bytes, etc).

value
the unsigned long long integer to convert.
str
the buffer to write the string into.
radix
the radix to use for string generation.
Returns
str.
Thread safety
It is safe to call this function from any thread.
See also
sDL_lltoa, sDL_uitoa, SDL_ultoa
C declaration
SDL_ulltoa, defined at SDL3/SDL_stdinc.h 3622:36

Since: 3.2.0

sDL_atoi :: FunPtr (PtrConst CChar -> IO CInt) Source #

Parse an int from a string.

The result of calling SDL_atoi(str) is equivalent to (int)SDL_strtol(str, NULL, 10).

str
The null-terminated string to read. Must not be NULL.
Returns
the parsed int.
Thread safety
It is safe to call this function from any thread.
See also
sDL_atof, SDL_strtol, SDL_strtoul, sDL_strtoll, sDL_strtoull, sDL_strtod, sDL_itoa
C declaration
SDL_atoi, defined at SDL3/SDL_stdinc.h 3646:33

Since: 3.2.0

sDL_atof :: FunPtr (PtrConst CChar -> IO CDouble) Source #

Parse a double from a string.

The result of calling SDL_atof(str) is equivalent to SDL_strtod(str, NULL).

str
The null-terminated string to read. Must not be NULL.
Returns
the parsed double.
Thread safety
It is safe to call this function from any thread.
See also
sDL_atoi, SDL_strtol, SDL_strtoul, sDL_strtoll, sDL_strtoull, sDL_strtod
C declaration
SDL_atof, defined at SDL3/SDL_stdinc.h 3668:36

Since: 3.2.0

sDL_strtoll :: FunPtr (PtrConst CChar -> Ptr (Ptr CChar) -> CInt -> IO CLLong) Source #

Parse a long long from a string.

If str starts with whitespace, then those whitespace characters are skipped before attempting to parse the number.

If the parsed number does not fit inside a long long, the result is clamped to the minimum and maximum representable long long values.

str
The null-terminated string to read. Must not be NULL.
endp
If not NULL, the address of the first invalid character (i.e. the next character after the parsed number) will be written to this pointer.
base
The base of the integer to read. Supported values are 0 and 2 to 36 inclusive. If 0, the base will be inferred from the number's prefix (0x for hexadecimal, 0 for octal, decimal otherwise).
Returns
the parsed long long, or 0 if no number could be parsed.
Thread safety
It is safe to call this function from any thread.
See also
sDL_atoi, sDL_atof, SDL_strtol, SDL_strtoul, sDL_strtoull, sDL_strtod, sDL_lltoa
C declaration
SDL_strtoll, defined at SDL3/SDL_stdinc.h 3770:39

Since: 3.2.0

sDL_strtoull :: FunPtr (PtrConst CChar -> Ptr (Ptr CChar) -> CInt -> IO CULLong) Source #

Parse an unsigned long long from a string.

If str starts with whitespace, then those whitespace characters are skipped before attempting to parse the number.

If the parsed number does not fit inside an unsigned long long, the result is clamped to the maximum representable unsigned long long value.

str
The null-terminated string to read. Must not be NULL.
endp
If not NULL, the address of the first invalid character (i.e. the next character after the parsed number) will be written to this pointer.
base
The base of the integer to read. Supported values are 0 and 2 to 36 inclusive. If 0, the base will be inferred from the number's prefix (0x for hexadecimal, 0 for octal, decimal otherwise).
Returns
the parsed unsigned long long, or 0 if no number could be parsed.
Thread safety
It is safe to call this function from any thread.
See also
sDL_atoi, sDL_atof, SDL_strtol, sDL_strtoll, SDL_strtoul, sDL_strtod, sDL_ulltoa
C declaration
SDL_strtoull, defined at SDL3/SDL_stdinc.h 3804:48

Since: 3.2.0

sDL_strtod :: FunPtr (PtrConst CChar -> Ptr (Ptr CChar) -> IO CDouble) Source #

Parse a double from a string.

This function makes fewer guarantees than the C runtime strtod:

  • Only decimal notation is guaranteed to be supported. The handling of scientific and hexadecimal notation is unspecified.
  • Whether or not INF and NAN can be parsed is unspecified.
  • The precision of the result is unspecified.
str
the null-terminated string to read. Must not be NULL.
endp
if not NULL, the address of the first invalid character (i.e. the next character after the parsed number) will be written to this pointer.
Returns
the parsed double, or 0 if no number could be parsed.
Thread safety
It is safe to call this function from any thread.
See also
sDL_atoi, sDL_atof, SDL_strtol, sDL_strtoll, SDL_strtoul, sDL_strtoull
C declaration
SDL_strtod, defined at SDL3/SDL_stdinc.h 3834:36

Since: 3.2.0

sDL_strcmp :: FunPtr (PtrConst CChar -> PtrConst CChar -> IO CInt) Source #

Compare two null-terminated UTF-8 strings.

Due to the nature of UTF-8 encoding, this will work with Unicode strings, since effectively this function just compares bytes until it hits a null-terminating character. Also due to the nature of UTF-8, this can be used with SDL_qsort() to put strings in (roughly) alphabetical order.

str1
the first string to compare. NULL is not permitted!
str2
the second string to compare. NULL is not permitted!
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strcmp, defined at SDL3/SDL_stdinc.h 3854:33

Since: 3.2.0

sDL_strncmp :: FunPtr (PtrConst CChar -> PtrConst CChar -> CSize -> IO CInt) Source #

Compare two UTF-8 strings up to a number of bytes.

Due to the nature of UTF-8 encoding, this will work with Unicode strings, since effectively this function just compares bytes until it hits a null-terminating character. Also due to the nature of UTF-8, this can be used with SDL_qsort() to put strings in (roughly) alphabetical order.

Note that while this function is intended to be used with UTF-8, it is doing a bytewise comparison, and maxlen specifies a byte limit! If the limit lands in the middle of a multi-byte UTF-8 sequence, it will only compare a portion of the final character.

maxlen specifies a maximum number of bytes to compare; if the strings match to this number of bytes (or both have matched to a null-terminator character before this number of bytes), they will be considered equal.

str1
the first string to compare. NULL is not permitted!
str2
the second string to compare. NULL is not permitted!
maxlen
the maximum number of bytes to compare.
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strncmp, defined at SDL3/SDL_stdinc.h 3884:33

Since: 3.2.0

sDL_strcasecmp :: FunPtr (PtrConst CChar -> PtrConst CChar -> IO CInt) Source #

Compare two null-terminated UTF-8 strings, case-insensitively.

This will work with Unicode strings, using a technique called "case-folding" to handle the vast majority of case-sensitive human languages regardless of system locale. It can deal with expanding values: a German Eszett character can compare against two ASCII 's' chars and be considered a match, for example. A notable exception: it does not handle the Turkish 'i' character; human language is complicated!

Since this handles Unicode, it expects the string to be well-formed UTF-8 and not a null-terminated string of arbitrary bytes. Bytes that are not valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT CHARACTER), which is to say two strings of random bits may turn out to match if they convert to the same amount of replacement characters.

str1
the first string to compare. NULL is not permitted!
str2
the second string to compare. NULL is not permitted!
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strcasecmp, defined at SDL3/SDL_stdinc.h 3912:33

Since: 3.2.0

sDL_strncasecmp :: FunPtr (PtrConst CChar -> PtrConst CChar -> CSize -> IO CInt) Source #

Compare two UTF-8 strings, case-insensitively, up to a number of bytes.

This will work with Unicode strings, using a technique called "case-folding" to handle the vast majority of case-sensitive human languages regardless of system locale. It can deal with expanding values: a German Eszett character can compare against two ASCII 's' chars and be considered a match, for example. A notable exception: it does not handle the Turkish 'i' character; human language is complicated!

Since this handles Unicode, it expects the string to be well-formed UTF-8 and not a null-terminated string of arbitrary bytes. Bytes that are not valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT CHARACTER), which is to say two strings of random bits may turn out to match if they convert to the same amount of replacement characters.

Note that while this function is intended to be used with UTF-8, maxlen specifies a byte limit! If the limit lands in the middle of a multi-byte UTF-8 sequence, it may convert a portion of the final character to one or more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not to overflow a buffer.

maxlen specifies a maximum number of bytes to compare; if the strings match to this number of bytes (or both have matched to a null-terminator character before this number of bytes), they will be considered equal.

str1
the first string to compare. NULL is not permitted!
str2
the second string to compare. NULL is not permitted!
maxlen
the maximum number of bytes to compare.
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strncasecmp, defined at SDL3/SDL_stdinc.h 3952:33

Since: 3.2.0

sDL_strpbrk :: FunPtr (PtrConst CChar -> PtrConst CChar -> IO (Ptr CChar)) Source #

Searches a string for the first occurrence of any character contained in a breakset, and returns a pointer from the string to that character.

str
The null-terminated string to be searched. Must not be NULL, and must not overlap with breakset.
breakset
A null-terminated string containing the list of characters to look for. Must not be NULL, and must not overlap with str.
Returns
A pointer to the location, in str, of the first occurrence of a character present in the breakset, or NULL if none is found.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_strpbrk, defined at SDL3/SDL_stdinc.h 3970:36

Since: 3.2.0

sDL_StepUTF8 :: FunPtr (Ptr (PtrConst CChar) -> Ptr CSize -> IO Uint32) Source #

Decode a UTF-8 string, one Unicode codepoint at a time.

This will return the first Unicode codepoint in the UTF-8 encoded string in *pstr, and then advance *pstr past any consumed bytes before returning.

It will not access more than *pslen bytes from the string. *pslen will be adjusted, as well, subtracting the number of bytes consumed.

pslen is allowed to be NULL, in which case the string must be NULL-terminated, as the function will blindly read until it sees the NULL char.

if *pslen is zero, it assumes the end of string is reached and returns a zero codepoint regardless of the contents of the string buffer.

If the resulting codepoint is zero (a NULL terminator), or *pslen is zero, it will not advance *pstr or *pslen at all.

Generally this function is called in a loop until it returns zero, adjusting its parameters each iteration.

If an invalid UTF-8 sequence is encountered, this function returns SDL_INVALID_UNICODE_CODEPOINT and advances the string/length by one byte (which is to say, a multibyte sequence might produce several SDL_INVALID_UNICODE_CODEPOINT returns before it syncs to the next valid UTF-8 sequence).

Several things can generate invalid UTF-8 sequences, including overlong encodings, the use of UTF-16 surrogate values, and truncated data. Please refer to RFC3629 for details.

pstr
a pointer to a UTF-8 string pointer to be read and adjusted.
pslen
a pointer to the number of bytes in the string, to be read and adjusted. NULL is allowed.
Returns
the first Unicode codepoint in the string.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_StepUTF8, defined at SDL3/SDL_stdinc.h 4030:36

Since: 3.2.0

sDL_StepBackUTF8 :: FunPtr (PtrConst CChar -> Ptr (PtrConst CChar) -> IO Uint32) Source #

Decode a UTF-8 string in reverse, one Unicode codepoint at a time.

This will go to the start of the previous Unicode codepoint in the string, move *pstr to that location and return that codepoint.

If *pstr is already at the start of the string), it will not advance *pstr at all.

Generally this function is called in a loop until it returns zero, adjusting its parameter each iteration.

If an invalid UTF-8 sequence is encountered, this function returns SDL_INVALID_UNICODE_CODEPOINT.

Several things can generate invalid UTF-8 sequences, including overlong encodings, the use of UTF-16 surrogate values, and truncated data. Please refer to RFC3629 for details.

start
a pointer to the beginning of the UTF-8 string.
pstr
a pointer to a UTF-8 string pointer to be read and adjusted.
Returns
the previous Unicode codepoint in the string.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_StepBackUTF8, defined at SDL3/SDL_stdinc.h 4061:36

Since: 3.2.0

sDL_UCS4ToUTF8 :: FunPtr (Uint32 -> Ptr CChar -> IO (Ptr CChar)) Source #

Convert a single Unicode codepoint to UTF-8.

The buffer pointed to by dst must be at least 4 bytes long, as this function may generate between 1 and 4 bytes of output.

This function returns the first byte after the newly-written UTF-8 sequence, which is useful for encoding multiple codepoints in a loop, or knowing where to write a NULL-terminator character to end the string (in either case, plan to have a buffer of more than 4 bytes!).

If codepoint is an invalid value (outside the Unicode range, or a UTF-16 surrogate value, etc), this will use U+FFFD (REPLACEMENT CHARACTER) for the codepoint instead, and not set an error.

If dst is NULL, this returns NULL immediately without writing to the pointer and without setting an error.

codepoint
a Unicode codepoint to convert to UTF-8.
dst
the location to write the encoded UTF-8. Must point to at least 4 bytes!
Returns
the first byte past the newly-written UTF-8 sequence.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_UCS4ToUTF8, defined at SDL3/SDL_stdinc.h 4090:36

Since: 3.2.0

sDL_srand :: FunPtr (Uint64 -> IO ()) Source #

Seeds the pseudo-random number generator.

Reusing the seed number will cause SDL_rand() to repeat the same stream of 'random' numbers.

seed
the value to use as a random number seed, or 0 to use SDL_GetPerformanceCounter().
Thread safety
This should be called on the same thread that calls SDL_rand()
See also
sDL_rand, sDL_rand_bits, sDL_randf
C declaration
SDL_srand, defined at SDL3/SDL_stdinc.h 4302:34

Since: 3.2.0

sDL_rand :: FunPtr (Sint32 -> IO Sint32) Source #

Generate a pseudo-random number less than n for positive n

The method used is faster and of better quality than rand() % n. Odds are roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and much worse as n gets bigger.

Example: to simulate a d6 use SDL_rand(6) + 1 The +1 converts 0..5 to 1..6

If you want to generate a pseudo-random number in the full range of Sint32, you should use: (Sint32) SDL_rand_bits()

If you want reproducible output, be sure to initialize with SDL_srand() first.

There are no guarantees as to the quality of the random sequence produced, and this should not be used for security (cryptography, passwords) or where money is on the line (loot-boxes, casinos). There are many random number libraries available with different characteristics and you should pick one of those to meet any serious needs.

n
the number of possible outcomes. n must be positive.
Returns
a random value in the range of [0 .. n-1].
Thread safety
All calls should be made from a single thread
See also
sDL_srand, sDL_randf
C declaration
SDL_rand, defined at SDL3/SDL_stdinc.h 4336:36

Since: 3.2.0

sDL_randf :: FunPtr (IO CFloat) Source #

Generate a uniform pseudo-random floating point number less than 1.0

If you want reproducible output, be sure to initialize with SDL_srand() first.

There are no guarantees as to the quality of the random sequence produced, and this should not be used for security (cryptography, passwords) or where money is on the line (loot-boxes, casinos). There are many random number libraries available with different characteristics and you should pick one of those to meet any serious needs.

Returns
a random value in the range of [0.0, 1.0).
Thread safety
All calls should be made from a single thread
See also
sDL_srand, sDL_rand
C declaration
SDL_randf, defined at SDL3/SDL_stdinc.h 4359:35

Since: 3.2.0

sDL_rand_bits :: FunPtr (IO Uint32) Source #

Generate 32 pseudo-random bits.

You likely want to use SDL_rand() to get a psuedo-random number instead.

There are no guarantees as to the quality of the random sequence produced, and this should not be used for security (cryptography, passwords) or where money is on the line (loot-boxes, casinos). There are many random number libraries available with different characteristics and you should pick one of those to meet any serious needs.

Returns
a random value in the range of [0-SDL_MAX_UINT32].
Thread safety
All calls should be made from a single thread
See also
sDL_rand, sDL_randf, sDL_srand
C declaration
SDL_rand_bits, defined at SDL3/SDL_stdinc.h 4382:36

Since: 3.2.0

sDL_rand_r :: FunPtr (Ptr Uint64 -> Sint32 -> IO Sint32) Source #

Generate a pseudo-random number less than n for positive n

The method used is faster and of better quality than rand() % n. Odds are roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and much worse as n gets bigger.

Example: to simulate a d6 use SDL_rand_r(state, 6) + 1 The +1 converts 0..5 to 1..6

If you want to generate a pseudo-random number in the full range of Sint32, you should use: (Sint32)SDL_rand_bits_r(state)

There are no guarantees as to the quality of the random sequence produced, and this should not be used for security (cryptography, passwords) or where money is on the line (loot-boxes, casinos). There are many random number libraries available with different characteristics and you should pick one of those to meet any serious needs.

state
a pointer to the current random number state, this may not be NULL.
n
the number of possible outcomes. n must be positive.
Returns
a random value in the range of [0 .. n-1].
Thread safety
This function is thread-safe, as long as the state pointer isn't shared between threads.
See also
sDL_rand, sDL_rand_bits_r, sDL_randf_r
C declaration
SDL_rand_r, defined at SDL3/SDL_stdinc.h 4417:36

Since: 3.2.0

sDL_randf_r :: FunPtr (Ptr Uint64 -> IO CFloat) Source #

Generate a uniform pseudo-random floating point number less than 1.0

If you want reproducible output, be sure to initialize with SDL_srand() first.

There are no guarantees as to the quality of the random sequence produced, and this should not be used for security (cryptography, passwords) or where money is on the line (loot-boxes, casinos). There are many random number libraries available with different characteristics and you should pick one of those to meet any serious needs.

state
a pointer to the current random number state, this may not be NULL.
Returns
a random value in the range of [0.0, 1.0).
Thread safety
This function is thread-safe, as long as the state pointer isn't shared between threads.
See also
sDL_rand_bits_r, sDL_rand_r, sDL_randf
C declaration
SDL_randf_r, defined at SDL3/SDL_stdinc.h 4444:35

Since: 3.2.0

sDL_rand_bits_r :: FunPtr (Ptr Uint64 -> IO Uint32) Source #

Generate 32 pseudo-random bits.

You likely want to use SDL_rand_r() to get a psuedo-random number instead.

There are no guarantees as to the quality of the random sequence produced, and this should not be used for security (cryptography, passwords) or where money is on the line (loot-boxes, casinos). There are many random number libraries available with different characteristics and you should pick one of those to meet any serious needs.

state
a pointer to the current random number state, this may not be NULL.
Returns
a random value in the range of [0-SDL_MAX_UINT32].
Thread safety
This function is thread-safe, as long as the state pointer isn't shared between threads.
See also
sDL_rand_r, sDL_randf_r
C declaration
SDL_rand_bits_r, defined at SDL3/SDL_stdinc.h 4469:36

Since: 3.2.0

sDL_acos :: FunPtr (CDouble -> IO CDouble) Source #

Compute the arc cosine of x.

The definition of y = acos(x) is x = cos(y).

Domain: -1 <= x <= 1

Range: 0 <= y <= Pi

This function operates on double-precision floating point values, use SDL_acosf for single-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value.
Returns
arc cosine of x, in radians.
Thread safety
It is safe to call this function from any thread.
See also
sDL_acosf, sDL_asin, sDL_cos
C declaration
SDL_acos, defined at SDL3/SDL_stdinc.h 4523:36

Since: 3.2.0

sDL_acosf :: FunPtr (CFloat -> IO CFloat) Source #

Compute the arc cosine of x.

The definition of y = acos(x) is x = cos(y).

Domain: -1 <= x <= 1

Range: 0 <= y <= Pi

This function operates on single-precision floating point values, use SDL_acos for double-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value.
Returns
arc cosine of x, in radians.
Thread safety
It is safe to call this function from any thread.
See also
sDL_acos, sDL_asinf, sDL_cosf
C declaration
SDL_acosf, defined at SDL3/SDL_stdinc.h 4553:35

Since: 3.2.0

sDL_asin :: FunPtr (CDouble -> IO CDouble) Source #

Compute the arc sine of x.

The definition of y = asin(x) is x = sin(y).

Domain: -1 <= x <= 1

Range: -Pi/2 <= y <= Pi/2

This function operates on double-precision floating point values, use SDL_asinf for single-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value.
Returns
arc sine of x, in radians.
Thread safety
It is safe to call this function from any thread.
See also
sDL_asinf, sDL_acos, sDL_sin
C declaration
SDL_asin, defined at SDL3/SDL_stdinc.h 4583:36

Since: 3.2.0

sDL_asinf :: FunPtr (CFloat -> IO CFloat) Source #

Compute the arc sine of x.

The definition of y = asin(x) is x = sin(y).

Domain: -1 <= x <= 1

Range: -Pi/2 <= y <= Pi/2

This function operates on single-precision floating point values, use SDL_asin for double-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value.
Returns
arc sine of x, in radians.
Thread safety
It is safe to call this function from any thread.
See also
sDL_asin, sDL_acosf, sDL_sinf
C declaration
SDL_asinf, defined at SDL3/SDL_stdinc.h 4613:35

Since: 3.2.0

sDL_atan :: FunPtr (CDouble -> IO CDouble) Source #

Compute the arc tangent of x.

The definition of y = atan(x) is x = tan(y).

Domain: -INF <= x <= INF

Range: -Pi/2 <= y <= Pi/2

This function operates on double-precision floating point values, use SDL_atanf for single-precision floats.

To calculate the arc tangent of y / x, use SDL_atan2.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value.
Returns
arc tangent of of x in radians, or 0 if x = 0.
Thread safety
It is safe to call this function from any thread.
See also
sDL_atanf, sDL_atan2, sDL_tan
C declaration
SDL_atan, defined at SDL3/SDL_stdinc.h 4645:36

Since: 3.2.0

sDL_atanf :: FunPtr (CFloat -> IO CFloat) Source #

Compute the arc tangent of x.

The definition of y = atan(x) is x = tan(y).

Domain: -INF <= x <= INF

Range: -Pi/2 <= y <= Pi/2

This function operates on single-precision floating point values, use SDL_atan for dboule-precision floats.

To calculate the arc tangent of y / x, use SDL_atan2f.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value.
Returns
arc tangent of of x in radians, or 0 if x = 0.
Thread safety
It is safe to call this function from any thread.
See also
sDL_atan, sDL_atan2f, sDL_tanf
C declaration
SDL_atanf, defined at SDL3/SDL_stdinc.h 4677:35

Since: 3.2.0

sDL_atan2 :: FunPtr (CDouble -> CDouble -> IO CDouble) Source #

Compute the arc tangent of y / x, using the signs of x and y to adjust the result's quadrant.

The definition of z = atan2(x, y) is y = x tan(z), where the quadrant of z is determined based on the signs of x and y.

Domain: -INF <= x <= INF, -INF <= y <= INF

Range: -Pi <= y <= Pi

This function operates on double-precision floating point values, use SDL_atan2f for single-precision floats.

To calculate the arc tangent of a single value, use SDL_atan.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

y
floating point value of the numerator (y coordinate).
x
floating point value of the denominator (x coordinate).
Returns
arc tangent of of y / x in radians, or, if x = 0, either -Pi/2, 0, or Pi/2, depending on the value of y.
Thread safety
It is safe to call this function from any thread.
See also
sDL_atan2f, sDL_atan, sDL_tan
C declaration
SDL_atan2, defined at SDL3/SDL_stdinc.h 4713:36

Since: 3.2.0

sDL_atan2f :: FunPtr (CFloat -> CFloat -> IO CFloat) Source #

Compute the arc tangent of y / x, using the signs of x and y to adjust the result's quadrant.

The definition of z = atan2(x, y) is y = x tan(z), where the quadrant of z is determined based on the signs of x and y.

Domain: -INF <= x <= INF, -INF <= y <= INF

Range: -Pi <= y <= Pi

This function operates on single-precision floating point values, use SDL_atan2 for double-precision floats.

To calculate the arc tangent of a single value, use SDL_atanf.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

y
floating point value of the numerator (y coordinate).
x
floating point value of the denominator (x coordinate).
Returns
arc tangent of of y / x in radians, or, if x = 0, either -Pi/2, 0, or Pi/2, depending on the value of y.
Thread safety
It is safe to call this function from any thread.
See also
sDL_atan2, sDL_atan, sDL_tan
C declaration
SDL_atan2f, defined at SDL3/SDL_stdinc.h 4749:35

Since: 3.2.0

sDL_ceil :: FunPtr (CDouble -> IO CDouble) Source #

Compute the ceiling of x.

The ceiling of x is the smallest integer y such that y >= x, i.e x rounded up to the nearest integer.

Domain: -INF <= x <= INF

Range: -INF <= y <= INF, y integer

This function operates on double-precision floating point values, use SDL_ceilf for single-precision floats.

x
floating point value.
Returns
the ceiling of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_ceilf, sDL_floor, sDL_trunc, sDL_round, SDL_lround
C declaration
SDL_ceil, defined at SDL3/SDL_stdinc.h 4777:36

Since: 3.2.0

sDL_ceilf :: FunPtr (CFloat -> IO CFloat) Source #

Compute the ceiling of x.

The ceiling of x is the smallest integer y such that y >= x, i.e x rounded up to the nearest integer.

Domain: -INF <= x <= INF

Range: -INF <= y <= INF, y integer

This function operates on single-precision floating point values, use SDL_ceil for double-precision floats.

x
floating point value.
Returns
the ceiling of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_ceil, sDL_floorf, sDL_truncf, sDL_roundf, SDL_lroundf
C declaration
SDL_ceilf, defined at SDL3/SDL_stdinc.h 4805:35

Since: 3.2.0

sDL_copysign :: FunPtr (CDouble -> CDouble -> IO CDouble) Source #

Copy the sign of one floating-point value to another.

The definition of copysign is that copysign(x, y) = abs(x) * sign(y).

Domain: -INF <= x <= INF, -INF <= y <= f

Range: -INF <= z <= INF

This function operates on double-precision floating point values, use SDL_copysignf for single-precision floats.

x
floating point value to use as the magnitude.
y
floating point value to use as the sign.
Returns
the floating point value with the sign of y and the magnitude of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_copysignf, sDL_fabs
C declaration
SDL_copysign, defined at SDL3/SDL_stdinc.h 4831:36

Since: 3.2.0

sDL_copysignf :: FunPtr (CFloat -> CFloat -> IO CFloat) Source #

Copy the sign of one floating-point value to another.

The definition of copysign is that copysign(x, y) = abs(x) * sign(y).

Domain: -INF <= x <= INF, -INF <= y <= f

Range: -INF <= z <= INF

This function operates on single-precision floating point values, use SDL_copysign for double-precision floats.

x
floating point value to use as the magnitude.
y
floating point value to use as the sign.
Returns
the floating point value with the sign of y and the magnitude of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_copysign, sDL_fabsf
C declaration
SDL_copysignf, defined at SDL3/SDL_stdinc.h 4857:35

Since: 3.2.0

sDL_cos :: FunPtr (CDouble -> IO CDouble) Source #

Compute the cosine of x.

Domain: -INF <= x <= INF

Range: -1 <= y <= 1

This function operates on double-precision floating point values, use SDL_cosf for single-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value, in radians.
Returns
cosine of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_cosf, sDL_acos, sDL_sin
C declaration
SDL_cos, defined at SDL3/SDL_stdinc.h 4885:36

Since: 3.2.0

sDL_cosf :: FunPtr (CFloat -> IO CFloat) Source #

Compute the cosine of x.

Domain: -INF <= x <= INF

Range: -1 <= y <= 1

This function operates on single-precision floating point values, use SDL_cos for double-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value, in radians.
Returns
cosine of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_cos, sDL_acosf, sDL_sinf
C declaration
SDL_cosf, defined at SDL3/SDL_stdinc.h 4913:35

Since: 3.2.0

sDL_exp :: FunPtr (CDouble -> IO CDouble) Source #

Compute the exponential of x.

The definition of y = exp(x) is y = e^x, where e is the base of the natural logarithm. The inverse is the natural logarithm, SDL_log.

Domain: -INF <= x <= INF

Range: 0 <= y <= INF

The output will overflow if exp(x) is too large to be represented.

This function operates on double-precision floating point values, use SDL_expf for single-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value.
Returns
value of e^x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_expf, sDL_log
C declaration
SDL_exp, defined at SDL3/SDL_stdinc.h 4945:36

Since: 3.2.0

sDL_expf :: FunPtr (CFloat -> IO CFloat) Source #

Compute the exponential of x.

The definition of y = exp(x) is y = e^x, where e is the base of the natural logarithm. The inverse is the natural logarithm, SDL_logf.

Domain: -INF <= x <= INF

Range: 0 <= y <= INF

The output will overflow if exp(x) is too large to be represented.

This function operates on single-precision floating point values, use SDL_exp for double-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value.
Returns
value of e^x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_exp, sDL_logf
C declaration
SDL_expf, defined at SDL3/SDL_stdinc.h 4977:35

Since: 3.2.0

sDL_fabs :: FunPtr (CDouble -> IO CDouble) Source #

Compute the absolute value of x

Domain: -INF <= x <= INF

Range: 0 <= y <= INF

This function operates on double-precision floating point values, use SDL_fabsf for single-precision floats.

x
floating point value to use as the magnitude.
Returns
the absolute value of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_fabsf
C declaration
SDL_fabs, defined at SDL3/SDL_stdinc.h 4998:36

Since: 3.2.0

sDL_fabsf :: FunPtr (CFloat -> IO CFloat) Source #

Compute the absolute value of x

Domain: -INF <= x <= INF

Range: 0 <= y <= INF

This function operates on single-precision floating point values, use SDL_fabs for double-precision floats.

x
floating point value to use as the magnitude.
Returns
the absolute value of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_fabs
C declaration
SDL_fabsf, defined at SDL3/SDL_stdinc.h 5019:35

Since: 3.2.0

sDL_floor :: FunPtr (CDouble -> IO CDouble) Source #

Compute the floor of x.

The floor of x is the largest integer y such that y <= x, i.e x rounded down to the nearest integer.

Domain: -INF <= x <= INF

Range: -INF <= y <= INF, y integer

This function operates on double-precision floating point values, use SDL_floorf for single-precision floats.

x
floating point value.
Returns
the floor of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_floorf, sDL_ceil, sDL_trunc, sDL_round, SDL_lround
C declaration
SDL_floor, defined at SDL3/SDL_stdinc.h 5047:36

Since: 3.2.0

sDL_floorf :: FunPtr (CFloat -> IO CFloat) Source #

Compute the floor of x.

The floor of x is the largest integer y such that y <= x, i.e x rounded down to the nearest integer.

Domain: -INF <= x <= INF

Range: -INF <= y <= INF, y integer

This function operates on single-precision floating point values, use SDL_floor for double-precision floats.

x
floating point value.
Returns
the floor of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_floor, sDL_ceilf, sDL_truncf, sDL_roundf, SDL_lroundf
C declaration
SDL_floorf, defined at SDL3/SDL_stdinc.h 5075:35

Since: 3.2.0

sDL_trunc :: FunPtr (CDouble -> IO CDouble) Source #

Truncate x to an integer.

Rounds x to the next closest integer to 0. This is equivalent to removing the fractional part of x, leaving only the integer part.

Domain: -INF <= x <= INF

Range: -INF <= y <= INF, y integer

This function operates on double-precision floating point values, use SDL_truncf for single-precision floats.

x
floating point value.
Returns
x truncated to an integer.
Thread safety
It is safe to call this function from any thread.
See also
sDL_truncf, sDL_fmod, sDL_ceil, sDL_floor, sDL_round, SDL_lround
C declaration
SDL_trunc, defined at SDL3/SDL_stdinc.h 5104:36

Since: 3.2.0

sDL_truncf :: FunPtr (CFloat -> IO CFloat) Source #

Truncate x to an integer.

Rounds x to the next closest integer to 0. This is equivalent to removing the fractional part of x, leaving only the integer part.

Domain: -INF <= x <= INF

Range: -INF <= y <= INF, y integer

This function operates on single-precision floating point values, use SDL_trunc for double-precision floats.

x
floating point value.
Returns
x truncated to an integer.
Thread safety
It is safe to call this function from any thread.
See also
sDL_trunc, sDL_fmodf, sDL_ceilf, sDL_floorf, sDL_roundf, SDL_lroundf
C declaration
SDL_truncf, defined at SDL3/SDL_stdinc.h 5133:35

Since: 3.2.0

sDL_fmod :: FunPtr (CDouble -> CDouble -> IO CDouble) Source #

Return the floating-point remainder of x / y

Divides x by y, and returns the remainder.

Domain: -INF <= x <= INF, -INF <= y <= INF, y != 0

Range: -y <= z <= y

This function operates on double-precision floating point values, use SDL_fmodf for single-precision floats.

x
the numerator.
y
the denominator. Must not be 0.
Returns
the remainder of x / y.
Thread safety
It is safe to call this function from any thread.
See also
sDL_fmodf, sDL_modf, sDL_trunc, sDL_ceil, sDL_floor, sDL_round, SDL_lround
C declaration
SDL_fmod, defined at SDL3/SDL_stdinc.h 5163:36

Since: 3.2.0

sDL_fmodf :: FunPtr (CFloat -> CFloat -> IO CFloat) Source #

Return the floating-point remainder of x / y

Divides x by y, and returns the remainder.

Domain: -INF <= x <= INF, -INF <= y <= INF, y != 0

Range: -y <= z <= y

This function operates on single-precision floating point values, use SDL_fmod for double-precision floats.

x
the numerator.
y
the denominator. Must not be 0.
Returns
the remainder of x / y.
Thread safety
It is safe to call this function from any thread.
See also
sDL_fmod, sDL_truncf, sDL_modff, sDL_ceilf, sDL_floorf, sDL_roundf, SDL_lroundf
C declaration
SDL_fmodf, defined at SDL3/SDL_stdinc.h 5193:35

Since: 3.2.0

sDL_isinf :: FunPtr (CDouble -> IO CInt) Source #

Return whether the value is infinity.

x
double-precision floating point value.
Returns
non-zero if the value is infinity, 0 otherwise.
Thread safety
It is safe to call this function from any thread.
See also
sDL_isinff
C declaration
SDL_isinf, defined at SDL3/SDL_stdinc.h 5207:33

Since: 3.2.0

sDL_isinff :: FunPtr (CFloat -> IO CInt) Source #

Return whether the value is infinity.

x
floating point value.
Returns
non-zero if the value is infinity, 0 otherwise.
Thread safety
It is safe to call this function from any thread.
See also
sDL_isinf
C declaration
SDL_isinff, defined at SDL3/SDL_stdinc.h 5221:33

Since: 3.2.0

sDL_isnan :: FunPtr (CDouble -> IO CInt) Source #

Return whether the value is NaN.

x
double-precision floating point value.
Returns
non-zero if the value is NaN, 0 otherwise.
Thread safety
It is safe to call this function from any thread.
See also
sDL_isnanf
C declaration
SDL_isnan, defined at SDL3/SDL_stdinc.h 5235:33

Since: 3.2.0

sDL_isnanf :: FunPtr (CFloat -> IO CInt) Source #

Return whether the value is NaN.

x
floating point value.
Returns
non-zero if the value is NaN, 0 otherwise.
Thread safety
It is safe to call this function from any thread.
See also
sDL_isnan
C declaration
SDL_isnanf, defined at SDL3/SDL_stdinc.h 5249:33

Since: 3.2.0

sDL_log :: FunPtr (CDouble -> IO CDouble) Source #

Compute the natural logarithm of x.

Domain: 0 < x <= INF

Range: -INF <= y <= INF

It is an error for x to be less than or equal to 0.

This function operates on double-precision floating point values, use SDL_logf for single-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value. Must be greater than 0.
Returns
the natural logarithm of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_logf, sDL_log10, sDL_exp
C declaration
SDL_log, defined at SDL3/SDL_stdinc.h 5279:36

Since: 3.2.0

sDL_logf :: FunPtr (CFloat -> IO CFloat) Source #

Compute the natural logarithm of x.

Domain: 0 < x <= INF

Range: -INF <= y <= INF

It is an error for x to be less than or equal to 0.

This function operates on single-precision floating point values, use SDL_log for double-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value. Must be greater than 0.
Returns
the natural logarithm of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_log, sDL_expf
C declaration
SDL_logf, defined at SDL3/SDL_stdinc.h 5308:35

Since: 3.2.0

sDL_log10 :: FunPtr (CDouble -> IO CDouble) Source #

Compute the base-10 logarithm of x.

Domain: 0 < x <= INF

Range: -INF <= y <= INF

It is an error for x to be less than or equal to 0.

This function operates on double-precision floating point values, use SDL_log10f for single-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value. Must be greater than 0.
Returns
the logarithm of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_log10f, sDL_log, sDL_pow
C declaration
SDL_log10, defined at SDL3/SDL_stdinc.h 5338:36

Since: 3.2.0

sDL_log10f :: FunPtr (CFloat -> IO CFloat) Source #

Compute the base-10 logarithm of x.

Domain: 0 < x <= INF

Range: -INF <= y <= INF

It is an error for x to be less than or equal to 0.

This function operates on single-precision floating point values, use SDL_log10 for double-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value. Must be greater than 0.
Returns
the logarithm of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_log10, sDL_logf, sDL_powf
C declaration
SDL_log10f, defined at SDL3/SDL_stdinc.h 5368:35

Since: 3.2.0

sDL_modf :: FunPtr (CDouble -> Ptr CDouble -> IO CDouble) Source #

Split x into integer and fractional parts

This function operates on double-precision floating point values, use SDL_modff for single-precision floats.

x
floating point value.
y
output pointer to store the integer part of x.
Returns
the fractional part of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_modff, sDL_trunc, sDL_fmod
C declaration
SDL_modf, defined at SDL3/SDL_stdinc.h 5388:36

Since: 3.2.0

sDL_modff :: FunPtr (CFloat -> Ptr CFloat -> IO CFloat) Source #

Split x into integer and fractional parts

This function operates on single-precision floating point values, use SDL_modf for double-precision floats.

x
floating point value.
y
output pointer to store the integer part of x.
Returns
the fractional part of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_modf, sDL_truncf, sDL_fmodf
C declaration
SDL_modff, defined at SDL3/SDL_stdinc.h 5408:35

Since: 3.2.0

sDL_pow :: FunPtr (CDouble -> CDouble -> IO CDouble) Source #

Raise x to the power y

Domain: -INF <= x <= INF, -INF <= y <= INF

Range: -INF <= z <= INF

If y is the base of the natural logarithm (e), consider using SDL_exp instead.

This function operates on double-precision floating point values, use SDL_powf for single-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
the base.
y
the exponent.
Returns
x raised to the power y.
Thread safety
It is safe to call this function from any thread.
See also
sDL_powf, sDL_exp, sDL_log
C declaration
SDL_pow, defined at SDL3/SDL_stdinc.h 5440:36

Since: 3.2.0

sDL_powf :: FunPtr (CFloat -> CFloat -> IO CFloat) Source #

Raise x to the power y

Domain: -INF <= x <= INF, -INF <= y <= INF

Range: -INF <= z <= INF

If y is the base of the natural logarithm (e), consider using SDL_exp instead.

This function operates on single-precision floating point values, use SDL_pow for double-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
the base.
y
the exponent.
Returns
x raised to the power y.
Thread safety
It is safe to call this function from any thread.
See also
sDL_pow, sDL_expf, sDL_logf
C declaration
SDL_powf, defined at SDL3/SDL_stdinc.h 5472:35

Since: 3.2.0

sDL_round :: FunPtr (CDouble -> IO CDouble) Source #

Round x to the nearest integer.

Rounds x to the nearest integer. Values halfway between integers will be rounded away from zero.

Domain: -INF <= x <= INF

Range: -INF <= y <= INF, y integer

This function operates on double-precision floating point values, use SDL_roundf for single-precision floats. To get the result as an integer type, use SDL_lround.

x
floating point value.
Returns
the nearest integer to x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_roundf, SDL_lround, sDL_floor, sDL_ceil, sDL_trunc
C declaration
SDL_round, defined at SDL3/SDL_stdinc.h 5501:36

Since: 3.2.0

sDL_roundf :: FunPtr (CFloat -> IO CFloat) Source #

Round x to the nearest integer.

Rounds x to the nearest integer. Values halfway between integers will be rounded away from zero.

Domain: -INF <= x <= INF

Range: -INF <= y <= INF, y integer

This function operates on single-precision floating point values, use SDL_round for double-precision floats. To get the result as an integer type, use SDL_lroundf.

x
floating point value.
Returns
the nearest integer to x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_round, SDL_lroundf, sDL_floorf, sDL_ceilf, sDL_truncf
C declaration
SDL_roundf, defined at SDL3/SDL_stdinc.h 5530:35

Since: 3.2.0

sDL_scalbn :: FunPtr (CDouble -> CInt -> IO CDouble) Source #

Scale x by an integer power of two.

Multiplies x by the n th power of the floating point radix (always 2).

Domain: -INF <= x <= INF, n integer

Range: -INF <= y <= INF

This function operates on double-precision floating point values, use SDL_scalbnf for single-precision floats.

x
floating point value to be scaled.
n
integer exponent.
Returns
x * 2^n.
Thread safety
It is safe to call this function from any thread.
See also
sDL_scalbnf, sDL_pow
C declaration
SDL_scalbn, defined at SDL3/SDL_stdinc.h 5613:36

Since: 3.2.0

sDL_scalbnf :: FunPtr (CFloat -> CInt -> IO CFloat) Source #

Scale x by an integer power of two.

Multiplies x by the n th power of the floating point radix (always 2).

Domain: -INF <= x <= INF, n integer

Range: -INF <= y <= INF

This function operates on single-precision floating point values, use SDL_scalbn for double-precision floats.

x
floating point value to be scaled.
n
integer exponent.
Returns
x * 2^n.
Thread safety
It is safe to call this function from any thread.
See also
sDL_scalbn, sDL_powf
C declaration
SDL_scalbnf, defined at SDL3/SDL_stdinc.h 5638:35

Since: 3.2.0

sDL_sin :: FunPtr (CDouble -> IO CDouble) Source #

Compute the sine of x.

Domain: -INF <= x <= INF

Range: -1 <= y <= 1

This function operates on double-precision floating point values, use SDL_sinf for single-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value, in radians.
Returns
sine of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_sinf, sDL_asin, sDL_cos
C declaration
SDL_sin, defined at SDL3/SDL_stdinc.h 5666:36

Since: 3.2.0

sDL_sinf :: FunPtr (CFloat -> IO CFloat) Source #

Compute the sine of x.

Domain: -INF <= x <= INF

Range: -1 <= y <= 1

This function operates on single-precision floating point values, use SDL_sin for double-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value, in radians.
Returns
sine of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_sin, sDL_asinf, sDL_cosf
C declaration
SDL_sinf, defined at SDL3/SDL_stdinc.h 5694:35

Since: 3.2.0

sDL_sqrt :: FunPtr (CDouble -> IO CDouble) Source #

Compute the square root of x.

Domain: 0 <= x <= INF

Range: 0 <= y <= INF

This function operates on double-precision floating point values, use SDL_sqrtf for single-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value. Must be greater than or equal to 0.
Returns
square root of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_sqrtf
C declaration
SDL_sqrt, defined at SDL3/SDL_stdinc.h 5720:36

Since: 3.2.0

sDL_sqrtf :: FunPtr (CFloat -> IO CFloat) Source #

Compute the square root of x.

Domain: 0 <= x <= INF

Range: 0 <= y <= INF

This function operates on single-precision floating point values, use SDL_sqrt for double-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value. Must be greater than or equal to 0.
Returns
square root of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_sqrt
C declaration
SDL_sqrtf, defined at SDL3/SDL_stdinc.h 5746:35

Since: 3.2.0

sDL_tan :: FunPtr (CDouble -> IO CDouble) Source #

Compute the tangent of x.

Domain: -INF <= x <= INF

Range: -INF <= y <= INF

This function operates on double-precision floating point values, use SDL_tanf for single-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value, in radians.
Returns
tangent of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_tanf, sDL_sin, sDL_cos, sDL_atan, sDL_atan2
C declaration
SDL_tan, defined at SDL3/SDL_stdinc.h 5776:36

Since: 3.2.0

sDL_tanf :: FunPtr (CFloat -> IO CFloat) Source #

Compute the tangent of x.

Domain: -INF <= x <= INF

Range: -INF <= y <= INF

This function operates on single-precision floating point values, use SDL_tan for double-precision floats.

This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.

x
floating point value, in radians.
Returns
tangent of x.
Thread safety
It is safe to call this function from any thread.
See also
sDL_tan, sDL_sinf, sDL_cosf, sDL_atanf, sDL_atan2f
C declaration
SDL_tanf, defined at SDL3/SDL_stdinc.h 5806:35

Since: 3.2.0

sDL_iconv_open :: FunPtr (PtrConst CChar -> PtrConst CChar -> IO SDL_iconv_t) Source #

This function allocates a context for the specified character set conversion.

tocode
The target character encoding, must not be NULL.
fromcode
The source character encoding, must not be NULL.
Returns
a handle that must be freed with SDL_iconv_close, or SDL_ICONV_ERROR on failure.
Thread safety
It is safe to call this function from any thread.
See also
sDL_iconv, sDL_iconv_close, sDL_iconv_string
C declaration
SDL_iconv_open, defined at SDL3/SDL_stdinc.h 5834:41

Since: 3.2.0

sDL_iconv_close :: FunPtr (SDL_iconv_t -> IO CInt) Source #

This function frees a context used for character set conversion.

cd
The character set conversion handle.
Returns
0 on success, or -1 on failure.
Thread safety
It is safe to call this function from any thread.
See also
sDL_iconv, sDL_iconv_open, sDL_iconv_string
C declaration
SDL_iconv_close, defined at SDL3/SDL_stdinc.h 5851:33

Since: 3.2.0

sDL_iconv :: FunPtr (SDL_iconv_t -> Ptr (PtrConst CChar) -> Ptr CSize -> Ptr (Ptr CChar) -> Ptr CSize -> IO CSize) Source #

This function converts text between encodings, reading from and writing to a buffer.

It returns the number of successful conversions on success. On error, SDL_ICONV_E2BIG is returned when the output buffer is too small, or SDL_ICONV_EILSEQ is returned when an invalid input sequence is encountered, or SDL_ICONV_EINVAL is returned when an incomplete input sequence is encountered.

On exit:

  • inbuf will point to the beginning of the next multibyte sequence. On error, this is the location of the problematic input sequence. On success, this is the end of the input sequence.
  • inbytesleft will be set to the number of bytes left to convert, which will be 0 on success.
  • outbuf will point to the location where to store the next output byte.
  • outbytesleft will be set to the number of bytes left in the output buffer.
cd
The character set conversion context, created in SDL_iconv_open().
inbuf
Address of variable that points to the first character of the input sequence.
inbytesleft
The number of bytes in the input buffer.
outbuf
Address of variable that points to the output buffer.
outbytesleft
The number of bytes in the output buffer.
Returns
the number of conversions on success, or a negative error code.
Thread safety
Do not use the same SDL_iconv_t from two threads at once.
See also
sDL_iconv_open, sDL_iconv_close, sDL_iconv_string
C declaration
SDL_iconv, defined at SDL3/SDL_stdinc.h 5891:36

Since: 3.2.0

sDL_iconv_string :: FunPtr (PtrConst CChar -> PtrConst CChar -> PtrConst CChar -> CSize -> IO (Ptr CChar)) Source #

Helper function to convert a string's encoding in one call.

This function converts a buffer or string between encodings in one pass.

The string does not need to be NULL-terminated; this function operates on the number of bytes specified in inbytesleft whether there is a NULL character anywhere in the buffer.

The returned string is owned by the caller, and should be passed to SDL_free when no longer needed.

tocode
the character encoding of the output string. Examples are "UTF-8", "UCS-4", etc.
fromcode
the character encoding of data in inbuf.
inbuf
the string to convert to a different encoding.
inbytesleft
the size of the input string in bytes.
Returns
a new string, converted to the new encoding, or NULL on error.
Thread safety
It is safe to call this function from any thread.
See also
sDL_iconv_open, sDL_iconv_close, sDL_iconv
C declaration
SDL_iconv_string, defined at SDL3/SDL_stdinc.h 5928:36

Since: 3.2.0

sDL_size_mul_check_overflow_builtin :: FunPtr (CSize -> CSize -> Ptr CSize -> IO CBool) Source #

C declaration
SDL_size_mul_check_overflow_builtin, defined at SDL3/SDL_stdinc.h 6109:23

sDL_size_add_check_overflow_builtin :: FunPtr (CSize -> CSize -> Ptr CSize -> IO CBool) Source #

C declaration
SDL_size_add_check_overflow_builtin, defined at SDL3/SDL_stdinc.h 6147:23