sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Bindgen.Stdinc.Unsafe

Synopsis

Documentation

sDL_malloc Source #

Arguments

:: CSize
size
the size to allocate.
-> IO (Ptr Void) 

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.

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 Source #

Arguments

:: CSize
C declaration
nmemb
-> CSize
C declaration
size
-> IO (Ptr Void) 
C declaration
SDL_calloc, defined at SDL3/SDL_stdinc.h 1367:69

sDL_realloc Source #

Arguments

:: Ptr Void
C declaration
mem
-> CSize
C declaration
size
-> IO (Ptr Void) 
C declaration
SDL_realloc, defined at SDL3/SDL_stdinc.h 1407:54

sDL_free Source #

Arguments

:: Ptr Void
mem
a pointer to allocated memory, or NULL.
-> IO () 

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.

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 Source #

Arguments

:: Ptr SDL_malloc_func
malloc_func
filled with malloc function.
-> Ptr SDL_calloc_func
calloc_func
filled with calloc function.
-> Ptr SDL_realloc_func
realloc_func
filled with realloc function.
-> Ptr SDL_free_func
free_func
filled with free function.
-> IO () 

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.

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 Source #

Arguments

:: Ptr SDL_malloc_func
malloc_func
filled with malloc function.
-> Ptr SDL_calloc_func
calloc_func
filled with calloc function.
-> Ptr SDL_realloc_func
realloc_func
filled with realloc function.
-> Ptr SDL_free_func
free_func
filled with free function.
-> IO () 

Get the current set of SDL memory functions.

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 Source #

Arguments

:: SDL_malloc_func
malloc_func
custom malloc function.
-> SDL_calloc_func
calloc_func
custom calloc function.
-> SDL_realloc_func
realloc_func
custom realloc function.
-> SDL_free_func
free_func
custom free function.
-> IO CBool 

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.

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 Source #

Arguments

:: CSize
alignment
the alignment of the memory.
-> CSize
size
the size to allocate.
-> IO (Ptr Void) 

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.

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 Source #

Arguments

:: Ptr Void
mem
a pointer previously returned by SDL_aligned_alloc(), or NULL.
-> IO () 

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.

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 :: 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 :: 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 Source #

Arguments

:: CBool
populated
true to initialize it from the C runtime environment, false to create an empty environment.
-> IO (Ptr SDL_Environment) 

Create a set of environment variables

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 Source #

Arguments

:: Ptr SDL_Environment
env
the environment to query.
-> PtrConst CChar
name
the name of the variable to get.
-> IO (PtrConst CChar) 

Get the value of a variable in the environment.

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 Source #

Arguments

:: Ptr SDL_Environment
env
the environment to query.
-> IO (Ptr (Ptr CChar)) 

Get all variables in the environment.

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 Source #

Arguments

:: Ptr SDL_Environment
env
the environment to modify.
-> PtrConst CChar
name
the name of the variable to set.
-> PtrConst CChar
value
the value of the variable to set.
-> CBool
overwrite
true to overwrite the variable if it exists, false to return success without setting the variable if it already exists.
-> IO CBool 

Set the value of a variable in the environment.

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 Source #

Arguments

:: Ptr SDL_Environment
env
the environment to modify.
-> PtrConst CChar
name
the name of the variable to unset.
-> IO CBool 

Clear a variable from the environment.

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 Source #

Arguments

:: Ptr SDL_Environment
env
the environment to destroy.
-> IO () 

Destroy a set of environment variables.

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 Source #

Arguments

:: PtrConst CChar
name
the name of the variable to get.
-> IO (PtrConst CChar) 

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.

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 Source #

Arguments

:: PtrConst CChar
name
the name of the variable to get.
-> IO (PtrConst CChar) 

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.

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 Source #

Arguments

:: PtrConst CChar
name
the name of the variable to set.
-> PtrConst CChar
value
the value of the variable to set.
-> CInt
overwrite
1 to overwrite the variable if it exists, 0 to return success without setting the variable if it already exists.
-> IO CInt 

Set the value of a variable in the environment.

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 Source #

Arguments

:: PtrConst CChar
name
the name of the variable to unset.
-> IO CInt 

Clear a variable from the environment.

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 Source #

Arguments

:: Ptr Void
base
a pointer to the start of the array.
-> CSize
nmemb
the number of elements in the array.
-> CSize
size
the size of the elements in the array.
-> SDL_CompareCallback
compare
a function used to compare elements in the array.
-> IO () 

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);
    
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 Source #

Arguments

:: PtrConst Void
key
a pointer to a key equal to the element being searched for.
-> PtrConst Void
base
a pointer to the start of the array.
-> CSize
nmemb
the number of elements in the array.
-> CSize
size
the size of the elements in the array.
-> SDL_CompareCallback
compare
a function used to compare elements in the array.
-> IO (Ptr Void) 

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);
    
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 Source #

Arguments

:: Ptr Void
base
a pointer to the start of the array.
-> CSize
nmemb
the number of elements in the array.
-> CSize
size
the size of the elements in the array.
-> SDL_CompareCallback_r
compare
a function used to compare elements in the array.
-> Ptr Void
userdata
a pointer to pass to the compare function.
-> IO () 

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);
    
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 Source #

Arguments

:: PtrConst Void
key
a pointer to a key equal to the element being searched for.
-> PtrConst Void
base
a pointer to the start of the array.
-> CSize
nmemb
the number of elements in the array.
-> CSize
size
the size of the elements in the array.
-> SDL_CompareCallback_r
compare
a function used to compare elements in the array.
-> Ptr Void
userdata
a pointer to pass to the compare function.
-> IO (Ptr Void) 

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);
    
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 Source #

Arguments

:: CInt
x
an integer value.
-> IO CInt 

Compute the absolute value of x.

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

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.

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

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.

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

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.

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

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.

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

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.

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

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.

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

Report if a character is a punctuation mark.

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

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

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)
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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

Report if a character is upper case.

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

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

Report if a character is lower case.

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

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

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.

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

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) != ' ').

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

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.

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 Source #

Arguments

:: CInt
x
character value to check.
-> IO CInt 

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.

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 Source #

Arguments

:: Uint16
crc
the current checksum for this data set, or 0 for a new data set.
-> PtrConst Void
data
a new block of data to add to the checksum.
-> CSize
len
the size, in bytes, of the new block of data.
-> IO Uint16 

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.

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 Source #

Arguments

:: Uint32
crc
the current checksum for this data set, or 0 for a new data set.
-> PtrConst Void
data
a new block of data to add to the checksum.
-> CSize
len
the size, in bytes, of the new block of data.
-> IO Uint32 

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.

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 Source #

Arguments

:: PtrConst Void
data
the data to be hashed.
-> CSize
len
the size of data, in bytes.
-> Uint32
seed
a value that alters the final hash value.
-> IO Uint32 

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.

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 Source #

Arguments

:: Ptr Void
dst
The destination memory region. Must not be NULL, and must not overlap with src.
-> PtrConst Void
src
The source memory region. Must not be NULL, and must not overlap with dst.
-> CSize
len
The length in bytes of both dst and src.
-> IO (Ptr Void) 

Copy non-overlapping memory.

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

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 Source #

Arguments

:: Ptr Void
dst
The destination memory region. Must not be NULL.
-> PtrConst Void
src
The source memory region. Must not be NULL.
-> CSize
len
The length in bytes of both dst and src.
-> IO (Ptr Void) 

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.

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 Source #

Arguments

:: Ptr Void
dst
the destination memory region. Must not be NULL.
-> CInt
c
the byte value to set.
-> CSize
len
the length, in bytes, to set in dst.
-> IO (Ptr Void) 

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.

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 Source #

Arguments

:: Ptr Void
dst
the destination memory region. Must not be NULL.
-> Uint32
val
the Uint32 value to set.
-> CSize
dwords
the number of Uint32 values to set in dst.
-> IO (Ptr Void) 

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.

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 Source #

Arguments

:: PtrConst Void
s1
the first buffer to compare. NULL is not permitted!
-> PtrConst Void
s2
the second buffer to compare. NULL is not permitted!
-> CSize
len
the number of bytes to compare between the buffers.
-> IO CInt 

Compare two buffers of memory.

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 Source #

Arguments

:: PtrConst CWchar
wstr
The null-terminated wide string to read. Must not be NULL.
-> IO CSize 

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).

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 Source #

Arguments

:: PtrConst CWchar
wstr
The null-terminated wide string to read. Must not be NULL.
-> CSize
maxlen
The maximum amount of wide characters to count.
-> IO CSize 

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!

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 Source #

Arguments

:: Ptr CWchar
dst
The destination buffer. Must not be NULL, and must not overlap with src.
-> PtrConst CWchar
src
The null-terminated wide string to copy. Must not be NULL, and must not overlap with dst.
-> CSize
maxlen
The length (in wide characters) of the destination buffer.
-> IO CSize 

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.

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 Source #

Arguments

:: Ptr CWchar
dst
The destination buffer already containing the first null-terminated wide string. Must not be NULL and must not overlap with src.
-> PtrConst CWchar
src
The second null-terminated wide string. Must not be NULL, and must not overlap with dst.
-> CSize
maxlen
The length (in wide characters) of the destination buffer.
-> IO CSize 

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.

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 Source #

Arguments

:: PtrConst CWchar
wstr
the string to copy.
-> IO (Ptr CWchar) 

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.

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 Source #

Arguments

:: PtrConst CWchar
haystack
the wide string to search. Must not be NULL.
-> PtrConst CWchar
needle
the wide string to search for. Must not be NULL.
-> IO (Ptr CWchar) 

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.

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 Source #

Arguments

:: PtrConst CWchar
haystack
the wide string to search. Must not be NULL.
-> PtrConst CWchar
needle
the wide string to search for. Must not be NULL.
-> CSize
maxlen
the maximum number of wide characters to search in haystack.
-> IO (Ptr CWchar) 

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.

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 Source #

Arguments

:: PtrConst CWchar
str1
the first string to compare. NULL is not permitted!
-> PtrConst CWchar
str2
the second string to compare. NULL is not permitted!
-> IO CInt 

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.

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 Source #

Arguments

:: PtrConst CWchar
str1
the first string to compare. NULL is not permitted!
-> PtrConst CWchar
str2
the second string to compare. NULL is not permitted!
-> CSize
maxlen
the maximum number of wchar_t to compare.
-> IO CInt 

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.

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 Source #

Arguments

:: PtrConst CWchar
str1
the first string to compare. NULL is not permitted!
-> PtrConst CWchar
str2
the second string to compare. NULL is not permitted!
-> IO CInt 

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.

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 Source #

Arguments

:: PtrConst CWchar
str1
the first string to compare. NULL is not permitted!
-> PtrConst CWchar
str2
the second string to compare. NULL is not permitted!
-> CSize
maxlen
the maximum number of wchar_t values to compare.
-> IO CInt 

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.

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 Source #

Arguments

:: PtrConst CChar
str
The null-terminated string to read. Must not be NULL.
-> IO CSize 

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().

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 Source #

Arguments

:: PtrConst CChar
str
The null-terminated string to read. Must not be NULL.
-> CSize
maxlen
The maximum amount of bytes to count.
-> IO CSize 

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().

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 Source #

Arguments

:: Ptr CChar
dst
The destination buffer. Must not be NULL, and must not overlap with src.
-> PtrConst CChar
src
The null-terminated string to copy. Must not be NULL, and must not overlap with dst.
-> CSize
maxlen
The length (in characters) of the destination buffer.
-> IO CSize 

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().

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 Source #

Arguments

:: Ptr CChar
dst
The destination buffer. Must not be NULL, and must not overlap with src.
-> PtrConst CChar
src
The null-terminated UTF-8 string to copy. Must not be NULL, and must not overlap with dst.
-> CSize
dst_bytes
The length (in bytes) of the destination buffer. Must not be 0.
-> IO CSize 

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.

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 Source #

Arguments

:: Ptr CChar
dst
The destination buffer already containing the first null-terminated string. Must not be NULL and must not overlap with src.
-> PtrConst CChar
src
The second null-terminated string. Must not be NULL, and must not overlap with dst.
-> CSize
maxlen
The length (in characters) of the destination buffer.
-> IO CSize 

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.

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 Source #

Arguments

:: PtrConst CChar
str
the string to copy.
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: PtrConst CChar
str
the string to copy.
-> CSize
maxlen
the maximum length of the copied string, not counting the null-terminator character.
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: Ptr CChar
str
the string to reverse.
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: Ptr CChar
str
the string to convert in-place. Can not be NULL.
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: Ptr CChar
str
the string to convert in-place. Can not be NULL.
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: PtrConst CChar
str
the string to search. Must not be NULL.
-> CInt
c
the byte value to search for.
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: PtrConst CChar
str
the string to search. Must not be NULL.
-> CInt
c
the byte value to search for.
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: PtrConst CChar
haystack
the string to search. Must not be NULL.
-> PtrConst CChar
needle
the string to search for. Must not be NULL.
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: PtrConst CChar
haystack
the string to search. Must not be NULL.
-> PtrConst CChar
needle
the string to search for. Must not be NULL.
-> CSize
maxlen
the maximum number of bytes to search in haystack.
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: PtrConst CChar
haystack
the string to search. Must not be NULL.
-> PtrConst CChar
needle
the string to search for. Must not be NULL.
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: Ptr CChar
str
the string to tokenize, or NULL to continue tokenizing.
-> PtrConst CChar
delim
the delimiter string that separates tokens.
-> Ptr (Ptr CChar)
saveptr
pointer to a char *, used for ongoing state.
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: PtrConst CChar
str
The null-terminated UTF-8 string to read. Must not be NULL.
-> IO CSize 

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.

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 Source #

Arguments

:: PtrConst CChar
str
The null-terminated UTF-8 string to read. Must not be NULL.
-> CSize
bytes
The maximum amount of bytes to count.
-> IO CSize 

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.

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 Source #

Arguments

:: CInt
value
the integer to convert.
-> Ptr CChar
str
the buffer to write the string into.
-> CInt
radix
the radix to use for string generation.
-> IO (Ptr CChar) 

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).

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 Source #

Arguments

:: CUInt
value
the unsigned integer to convert.
-> Ptr CChar
str
the buffer to write the string into.
-> CInt
radix
the radix to use for string generation.
-> IO (Ptr CChar) 

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).

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 Source #

Arguments

:: CLLong
value
the long long integer to convert.
-> Ptr CChar
str
the buffer to write the string into.
-> CInt
radix
the radix to use for string generation.
-> IO (Ptr CChar) 

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).

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 Source #

Arguments

:: CULLong
value
the unsigned long long integer to convert.
-> Ptr CChar
str
the buffer to write the string into.
-> CInt
radix
the radix to use for string generation.
-> IO (Ptr CChar) 

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).

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 Source #

Arguments

:: PtrConst CChar
str
The null-terminated string to read. Must not be NULL.
-> IO CInt 

Parse an int from a string.

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

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 Source #

Arguments

:: PtrConst CChar
str
The null-terminated string to read. Must not be NULL.
-> IO CDouble 

Parse a double from a string.

The result of calling SDL_atof(str) is equivalent to SDL_strtod(str, 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 Source #

Arguments

:: PtrConst CChar
str
The null-terminated string to read. Must not be NULL.
-> Ptr (Ptr CChar)
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.
-> CInt
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).
-> IO CLLong 

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.

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 Source #

Arguments

:: PtrConst CChar
str
The null-terminated string to read. Must not be NULL.
-> Ptr (Ptr CChar)
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.
-> CInt
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).
-> IO CULLong 

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.

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 Source #

Arguments

:: PtrConst CChar
str
the null-terminated string to read. Must not be NULL.
-> Ptr (Ptr CChar)
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.
-> IO CDouble 

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.
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 Source #

Arguments

:: PtrConst CChar
str1
the first string to compare. NULL is not permitted!
-> PtrConst CChar
str2
the second string to compare. NULL is not permitted!
-> IO CInt 

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.

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 Source #

Arguments

:: PtrConst CChar
str1
the first string to compare. NULL is not permitted!
-> PtrConst CChar
str2
the second string to compare. NULL is not permitted!
-> CSize
maxlen
the maximum number of bytes to compare.
-> IO CInt 

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.

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 Source #

Arguments

:: PtrConst CChar
str1
the first string to compare. NULL is not permitted!
-> PtrConst CChar
str2
the second string to compare. NULL is not permitted!
-> IO CInt 

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.

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 Source #

Arguments

:: PtrConst CChar
str1
the first string to compare. NULL is not permitted!
-> PtrConst CChar
str2
the second string to compare. NULL is not permitted!
-> CSize
maxlen
the maximum number of bytes to compare.
-> IO CInt 

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.

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 Source #

Arguments

:: PtrConst CChar
str
The null-terminated string to be searched. Must not be NULL, and must not overlap with breakset.
-> PtrConst CChar
breakset
A null-terminated string containing the list of characters to look for. Must not be NULL, and must not overlap with str.
-> IO (Ptr CChar) 

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

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 Source #

Arguments

:: Ptr (PtrConst CChar)
pstr
a pointer to a UTF-8 string pointer to be read and adjusted.
-> Ptr CSize
pslen
a pointer to the number of bytes in the string, to be read and adjusted. NULL is allowed.
-> IO Uint32 

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.

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 Source #

Arguments

:: PtrConst CChar
start
a pointer to the beginning of the UTF-8 string.
-> Ptr (PtrConst CChar)
pstr
a pointer to a UTF-8 string pointer to be read and adjusted.
-> IO Uint32 

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.

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 Source #

Arguments

:: Uint32
codepoint
a Unicode codepoint to convert to UTF-8.
-> Ptr CChar
dst
the location to write the encoded UTF-8. Must point to at least 4 bytes!
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: Uint64
seed
the value to use as a random number seed, or 0 to use SDL_GetPerformanceCounter().
-> IO () 

Seeds the pseudo-random number generator.

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

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 Source #

Arguments

:: Sint32
n
the number of possible outcomes. n must be positive.
-> IO Sint32 

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.

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 :: 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 :: 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 Source #

Arguments

:: Ptr Uint64
state
a pointer to the current random number state, this may not be NULL.
-> Sint32
n
the number of possible outcomes. n must be positive.
-> IO Sint32 

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.

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 Source #

Arguments

:: Ptr Uint64
state
a pointer to the current random number state, this may not be NULL.
-> IO CFloat 

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
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 Source #

Arguments

:: Ptr Uint64
state
a pointer to the current random number state, this may not be NULL.
-> IO Uint32 

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.

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 Source #

Arguments

:: CDouble
x
floating point value.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
y
floating point value of the numerator (y coordinate).
-> CDouble
x
floating point value of the denominator (x coordinate).
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
y
floating point value of the numerator (y coordinate).
-> CFloat
x
floating point value of the denominator (x coordinate).
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value to use as the magnitude.
-> CDouble
y
floating point value to use as the sign.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value to use as the magnitude.
-> CFloat
y
floating point value to use as the sign.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value, in radians.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value, in radians.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value to use as the magnitude.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value to use as the magnitude.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
the numerator.
-> CDouble
y
the denominator. Must not be 0.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
the numerator.
-> CFloat
y
the denominator. Must not be 0.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
double-precision floating point value.
-> IO CInt 

Return whether the value is infinity.

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 Source #

Arguments

:: CFloat
x
floating point value.
-> IO CInt 

Return whether the value is infinity.

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 Source #

Arguments

:: CDouble
x
double-precision floating point value.
-> IO CInt 

Return whether the value is NaN.

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 Source #

Arguments

:: CFloat
x
floating point value.
-> IO CInt 

Return whether the value is NaN.

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 Source #

Arguments

:: CDouble
x
floating point value. Must be greater than 0.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value. Must be greater than 0.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value. Must be greater than 0.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value. Must be greater than 0.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value.
-> Ptr CDouble
y
output pointer to store the integer part of x.
-> IO CDouble 

Split x into integer and fractional parts

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

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 Source #

Arguments

:: CFloat
x
floating point value.
-> Ptr CFloat
y
output pointer to store the integer part of x.
-> IO CFloat 

Split x into integer and fractional parts

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

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 Source #

Arguments

:: CDouble
x
the base.
-> CDouble
y
the exponent.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
the base.
-> CFloat
y
the exponent.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value to be scaled.
-> CInt
n
integer exponent.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value to be scaled.
-> CInt
n
integer exponent.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value, in radians.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value, in radians.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value. Must be greater than or equal to 0.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value. Must be greater than or equal to 0.
-> IO CFloat 

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.

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 Source #

Arguments

:: CDouble
x
floating point value, in radians.
-> IO CDouble 

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.

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 Source #

Arguments

:: CFloat
x
floating point value, in radians.
-> IO CFloat 

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.

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 Source #

Arguments

:: PtrConst CChar
tocode
The target character encoding, must not be NULL.
-> PtrConst CChar
fromcode
The source character encoding, must not be NULL.
-> IO SDL_iconv_t 

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

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 Source #

Arguments

:: SDL_iconv_t
cd
The character set conversion handle.
-> IO CInt 

This function frees a context used for character set conversion.

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 Source #

Arguments

:: SDL_iconv_t
cd
The character set conversion context, created in SDL_iconv_open().
-> Ptr (PtrConst CChar)
inbuf
Address of variable that points to the first character of the input sequence.
-> Ptr CSize
inbytesleft
The number of bytes in the input buffer.
-> Ptr (Ptr CChar)
outbuf
Address of variable that points to the output buffer.
-> Ptr CSize
outbytesleft
The number of bytes in the output buffer.
-> IO CSize 

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.
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 Source #

Arguments

:: PtrConst CChar
tocode
the character encoding of the output string. Examples are "UTF-8", "UCS-4", etc.
-> PtrConst CChar
fromcode
the character encoding of data in inbuf.
-> PtrConst CChar
inbuf
the string to convert to a different encoding.
-> CSize
inbytesleft
the size of the input string in bytes.
-> IO (Ptr CChar) 

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.

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 Source #

Arguments

:: CSize
C declaration
a
-> CSize
C declaration
b
-> Ptr CSize
C declaration
ret
-> IO CBool 
C declaration
SDL_size_mul_check_overflow_builtin, defined at SDL3/SDL_stdinc.h 6109:23

sDL_size_add_check_overflow_builtin Source #

Arguments

:: CSize
C declaration
a
-> CSize
C declaration
b
-> Ptr CSize
C declaration
ret
-> IO CBool 
C declaration
SDL_size_add_check_overflow_builtin, defined at SDL3/SDL_stdinc.h 6147:23