| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
SDL3.Sys.Bindgen.Stdinc.Unsafe
Synopsis
- sDL_malloc :: CSize -> IO (Ptr Void)
- sDL_calloc :: CSize -> CSize -> IO (Ptr Void)
- sDL_realloc :: Ptr Void -> CSize -> IO (Ptr Void)
- sDL_free :: Ptr Void -> IO ()
- sDL_GetOriginalMemoryFunctions :: Ptr SDL_malloc_func -> Ptr SDL_calloc_func -> Ptr SDL_realloc_func -> Ptr SDL_free_func -> IO ()
- sDL_GetMemoryFunctions :: Ptr SDL_malloc_func -> Ptr SDL_calloc_func -> Ptr SDL_realloc_func -> Ptr SDL_free_func -> IO ()
- sDL_SetMemoryFunctions :: SDL_malloc_func -> SDL_calloc_func -> SDL_realloc_func -> SDL_free_func -> IO CBool
- sDL_aligned_alloc :: CSize -> CSize -> IO (Ptr Void)
- sDL_aligned_free :: Ptr Void -> IO ()
- sDL_GetNumAllocations :: IO CInt
- sDL_GetEnvironment :: IO (Ptr SDL_Environment)
- sDL_CreateEnvironment :: CBool -> IO (Ptr SDL_Environment)
- sDL_GetEnvironmentVariable :: Ptr SDL_Environment -> PtrConst CChar -> IO (PtrConst CChar)
- sDL_GetEnvironmentVariables :: Ptr SDL_Environment -> IO (Ptr (Ptr CChar))
- sDL_SetEnvironmentVariable :: Ptr SDL_Environment -> PtrConst CChar -> PtrConst CChar -> CBool -> IO CBool
- sDL_UnsetEnvironmentVariable :: Ptr SDL_Environment -> PtrConst CChar -> IO CBool
- sDL_DestroyEnvironment :: Ptr SDL_Environment -> IO ()
- sDL_getenv :: PtrConst CChar -> IO (PtrConst CChar)
- sDL_getenv_unsafe :: PtrConst CChar -> IO (PtrConst CChar)
- sDL_setenv_unsafe :: PtrConst CChar -> PtrConst CChar -> CInt -> IO CInt
- sDL_unsetenv_unsafe :: PtrConst CChar -> IO CInt
- sDL_qsort :: Ptr Void -> CSize -> CSize -> SDL_CompareCallback -> IO ()
- sDL_bsearch :: PtrConst Void -> PtrConst Void -> CSize -> CSize -> SDL_CompareCallback -> IO (Ptr Void)
- sDL_qsort_r :: Ptr Void -> CSize -> CSize -> SDL_CompareCallback_r -> Ptr Void -> IO ()
- sDL_bsearch_r :: PtrConst Void -> PtrConst Void -> CSize -> CSize -> SDL_CompareCallback_r -> Ptr Void -> IO (Ptr Void)
- sDL_abs :: CInt -> IO CInt
- sDL_isalpha :: CInt -> IO CInt
- sDL_isalnum :: CInt -> IO CInt
- sDL_isblank :: CInt -> IO CInt
- sDL_iscntrl :: CInt -> IO CInt
- sDL_isdigit :: CInt -> IO CInt
- sDL_isxdigit :: CInt -> IO CInt
- sDL_ispunct :: CInt -> IO CInt
- sDL_isspace :: CInt -> IO CInt
- sDL_isupper :: CInt -> IO CInt
- sDL_islower :: CInt -> IO CInt
- sDL_isprint :: CInt -> IO CInt
- sDL_isgraph :: CInt -> IO CInt
- sDL_toupper :: CInt -> IO CInt
- sDL_tolower :: CInt -> IO CInt
- sDL_crc16 :: Uint16 -> PtrConst Void -> CSize -> IO Uint16
- sDL_crc32 :: Uint32 -> PtrConst Void -> CSize -> IO Uint32
- sDL_murmur3_32 :: PtrConst Void -> CSize -> Uint32 -> IO Uint32
- sDL_memcpy :: Ptr Void -> PtrConst Void -> CSize -> IO (Ptr Void)
- sDL_memmove :: Ptr Void -> PtrConst Void -> CSize -> IO (Ptr Void)
- sDL_memset :: Ptr Void -> CInt -> CSize -> IO (Ptr Void)
- sDL_memset4 :: Ptr Void -> Uint32 -> CSize -> IO (Ptr Void)
- sDL_memcmp :: PtrConst Void -> PtrConst Void -> CSize -> IO CInt
- sDL_wcslen :: PtrConst CWchar -> IO CSize
- sDL_wcsnlen :: PtrConst CWchar -> CSize -> IO CSize
- sDL_wcslcpy :: Ptr CWchar -> PtrConst CWchar -> CSize -> IO CSize
- sDL_wcslcat :: Ptr CWchar -> PtrConst CWchar -> CSize -> IO CSize
- sDL_wcsdup :: PtrConst CWchar -> IO (Ptr CWchar)
- sDL_wcsstr :: PtrConst CWchar -> PtrConst CWchar -> IO (Ptr CWchar)
- sDL_wcsnstr :: PtrConst CWchar -> PtrConst CWchar -> CSize -> IO (Ptr CWchar)
- sDL_wcscmp :: PtrConst CWchar -> PtrConst CWchar -> IO CInt
- sDL_wcsncmp :: PtrConst CWchar -> PtrConst CWchar -> CSize -> IO CInt
- sDL_wcscasecmp :: PtrConst CWchar -> PtrConst CWchar -> IO CInt
- sDL_wcsncasecmp :: PtrConst CWchar -> PtrConst CWchar -> CSize -> IO CInt
- sDL_strlen :: PtrConst CChar -> IO CSize
- sDL_strnlen :: PtrConst CChar -> CSize -> IO CSize
- sDL_strlcpy :: Ptr CChar -> PtrConst CChar -> CSize -> IO CSize
- sDL_utf8strlcpy :: Ptr CChar -> PtrConst CChar -> CSize -> IO CSize
- sDL_strlcat :: Ptr CChar -> PtrConst CChar -> CSize -> IO CSize
- sDL_strdup :: PtrConst CChar -> IO (Ptr CChar)
- sDL_strndup :: PtrConst CChar -> CSize -> IO (Ptr CChar)
- sDL_strrev :: Ptr CChar -> IO (Ptr CChar)
- sDL_strupr :: Ptr CChar -> IO (Ptr CChar)
- sDL_strlwr :: Ptr CChar -> IO (Ptr CChar)
- sDL_strchr :: PtrConst CChar -> CInt -> IO (Ptr CChar)
- sDL_strrchr :: PtrConst CChar -> CInt -> IO (Ptr CChar)
- sDL_strstr :: PtrConst CChar -> PtrConst CChar -> IO (Ptr CChar)
- sDL_strnstr :: PtrConst CChar -> PtrConst CChar -> CSize -> IO (Ptr CChar)
- sDL_strcasestr :: PtrConst CChar -> PtrConst CChar -> IO (Ptr CChar)
- sDL_strtok_r :: Ptr CChar -> PtrConst CChar -> Ptr (Ptr CChar) -> IO (Ptr CChar)
- sDL_utf8strlen :: PtrConst CChar -> IO CSize
- sDL_utf8strnlen :: PtrConst CChar -> CSize -> IO CSize
- sDL_itoa :: CInt -> Ptr CChar -> CInt -> IO (Ptr CChar)
- sDL_uitoa :: CUInt -> Ptr CChar -> CInt -> IO (Ptr CChar)
- sDL_lltoa :: CLLong -> Ptr CChar -> CInt -> IO (Ptr CChar)
- sDL_ulltoa :: CULLong -> Ptr CChar -> CInt -> IO (Ptr CChar)
- sDL_atoi :: PtrConst CChar -> IO CInt
- sDL_atof :: PtrConst CChar -> IO CDouble
- sDL_strtoll :: PtrConst CChar -> Ptr (Ptr CChar) -> CInt -> IO CLLong
- sDL_strtoull :: PtrConst CChar -> Ptr (Ptr CChar) -> CInt -> IO CULLong
- sDL_strtod :: PtrConst CChar -> Ptr (Ptr CChar) -> IO CDouble
- sDL_strcmp :: PtrConst CChar -> PtrConst CChar -> IO CInt
- sDL_strncmp :: PtrConst CChar -> PtrConst CChar -> CSize -> IO CInt
- sDL_strcasecmp :: PtrConst CChar -> PtrConst CChar -> IO CInt
- sDL_strncasecmp :: PtrConst CChar -> PtrConst CChar -> CSize -> IO CInt
- sDL_strpbrk :: PtrConst CChar -> PtrConst CChar -> IO (Ptr CChar)
- sDL_StepUTF8 :: Ptr (PtrConst CChar) -> Ptr CSize -> IO Uint32
- sDL_StepBackUTF8 :: PtrConst CChar -> Ptr (PtrConst CChar) -> IO Uint32
- sDL_UCS4ToUTF8 :: Uint32 -> Ptr CChar -> IO (Ptr CChar)
- sDL_srand :: Uint64 -> IO ()
- sDL_rand :: Sint32 -> IO Sint32
- sDL_randf :: IO CFloat
- sDL_rand_bits :: IO Uint32
- sDL_rand_r :: Ptr Uint64 -> Sint32 -> IO Sint32
- sDL_randf_r :: Ptr Uint64 -> IO CFloat
- sDL_rand_bits_r :: Ptr Uint64 -> IO Uint32
- sDL_acos :: CDouble -> IO CDouble
- sDL_acosf :: CFloat -> IO CFloat
- sDL_asin :: CDouble -> IO CDouble
- sDL_asinf :: CFloat -> IO CFloat
- sDL_atan :: CDouble -> IO CDouble
- sDL_atanf :: CFloat -> IO CFloat
- sDL_atan2 :: CDouble -> CDouble -> IO CDouble
- sDL_atan2f :: CFloat -> CFloat -> IO CFloat
- sDL_ceil :: CDouble -> IO CDouble
- sDL_ceilf :: CFloat -> IO CFloat
- sDL_copysign :: CDouble -> CDouble -> IO CDouble
- sDL_copysignf :: CFloat -> CFloat -> IO CFloat
- sDL_cos :: CDouble -> IO CDouble
- sDL_cosf :: CFloat -> IO CFloat
- sDL_exp :: CDouble -> IO CDouble
- sDL_expf :: CFloat -> IO CFloat
- sDL_fabs :: CDouble -> IO CDouble
- sDL_fabsf :: CFloat -> IO CFloat
- sDL_floor :: CDouble -> IO CDouble
- sDL_floorf :: CFloat -> IO CFloat
- sDL_trunc :: CDouble -> IO CDouble
- sDL_truncf :: CFloat -> IO CFloat
- sDL_fmod :: CDouble -> CDouble -> IO CDouble
- sDL_fmodf :: CFloat -> CFloat -> IO CFloat
- sDL_isinf :: CDouble -> IO CInt
- sDL_isinff :: CFloat -> IO CInt
- sDL_isnan :: CDouble -> IO CInt
- sDL_isnanf :: CFloat -> IO CInt
- sDL_log :: CDouble -> IO CDouble
- sDL_logf :: CFloat -> IO CFloat
- sDL_log10 :: CDouble -> IO CDouble
- sDL_log10f :: CFloat -> IO CFloat
- sDL_modf :: CDouble -> Ptr CDouble -> IO CDouble
- sDL_modff :: CFloat -> Ptr CFloat -> IO CFloat
- sDL_pow :: CDouble -> CDouble -> IO CDouble
- sDL_powf :: CFloat -> CFloat -> IO CFloat
- sDL_round :: CDouble -> IO CDouble
- sDL_roundf :: CFloat -> IO CFloat
- sDL_scalbn :: CDouble -> CInt -> IO CDouble
- sDL_scalbnf :: CFloat -> CInt -> IO CFloat
- sDL_sin :: CDouble -> IO CDouble
- sDL_sinf :: CFloat -> IO CFloat
- sDL_sqrt :: CDouble -> IO CDouble
- sDL_sqrtf :: CFloat -> IO CFloat
- sDL_tan :: CDouble -> IO CDouble
- sDL_tanf :: CFloat -> IO CFloat
- sDL_iconv_open :: PtrConst CChar -> PtrConst CChar -> IO SDL_iconv_t
- sDL_iconv_close :: SDL_iconv_t -> IO CInt
- sDL_iconv :: SDL_iconv_t -> Ptr (PtrConst CChar) -> Ptr CSize -> Ptr (Ptr CChar) -> Ptr CSize -> IO CSize
- sDL_iconv_string :: PtrConst CChar -> PtrConst CChar -> PtrConst CChar -> CSize -> IO (Ptr CChar)
- sDL_size_mul_check_overflow_builtin :: CSize -> CSize -> Ptr CSize -> IO CBool
- sDL_size_add_check_overflow_builtin :: CSize -> CSize -> Ptr CSize -> IO CBool
Documentation
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 atSDL3/SDL_stdinc.h 1342:47
Since: 3.2.0
- C declaration
SDL_calloc, defined atSDL3/SDL_stdinc.h 1367:69
- C declaration
SDL_realloc, defined atSDL3/SDL_stdinc.h 1407:54
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 atSDL3/SDL_stdinc.h 1427:34
Since: 3.2.0
sDL_GetOriginalMemoryFunctions Source #
Arguments
| :: Ptr SDL_malloc_func |
|
| -> Ptr SDL_calloc_func |
|
| -> Ptr SDL_realloc_func |
|
| -> Ptr SDL_free_func |
|
| -> 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 atSDL3/SDL_stdinc.h 1525:34
Since: 3.2.0
sDL_GetMemoryFunctions Source #
Arguments
| :: Ptr SDL_malloc_func |
|
| -> Ptr SDL_calloc_func |
|
| -> Ptr SDL_realloc_func |
|
| -> Ptr SDL_free_func |
|
| -> 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 atSDL3/SDL_stdinc.h 1547:34
Since: 3.2.0
sDL_SetMemoryFunctions Source #
Arguments
| :: SDL_malloc_func |
|
| -> SDL_calloc_func |
|
| -> SDL_realloc_func |
|
| -> SDL_free_func |
|
| -> 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 atSDL3/SDL_stdinc.h 1578:34
Since: 3.2.0
Arguments
| :: CSize |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 1605:47
Since: 3.2.0
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 atSDL3/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 atSDL3/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 atSDL3/SDL_stdinc.h 1673:47
Since: 3.2.0
sDL_CreateEnvironment Source #
Arguments
| :: CBool |
|
| -> 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
populatedis 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 atSDL3/SDL_stdinc.h 1695:47
Since: 3.2.0
sDL_GetEnvironmentVariable Source #
Arguments
| :: Ptr SDL_Environment |
|
| -> PtrConst CChar |
|
| -> 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 atSDL3/SDL_stdinc.h 1715:42
Since: 3.2.0
sDL_GetEnvironmentVariables Source #
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 atSDL3/SDL_stdinc.h 1736:37
Since: 3.2.0
sDL_SetEnvironmentVariable Source #
Arguments
| :: Ptr SDL_Environment |
|
| -> PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> CBool |
|
| -> 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 atSDL3/SDL_stdinc.h 1760:34
Since: 3.2.0
sDL_UnsetEnvironmentVariable Source #
Arguments
| :: Ptr SDL_Environment |
|
| -> PtrConst CChar |
|
| -> 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 atSDL3/SDL_stdinc.h 1781:34
Since: 3.2.0
sDL_DestroyEnvironment Source #
Arguments
| :: Ptr SDL_Environment |
|
| -> 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 atSDL3/SDL_stdinc.h 1795:34
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 1812:42
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 1836:42
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> CInt |
|
| -> 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 atSDL3/SDL_stdinc.h 1854:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 1869:33
Since: 3.2.0
Arguments
| :: Ptr Void |
|
| -> CSize |
|
| -> CSize |
|
| -> SDL_CompareCallback |
|
| -> 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 atSDL3/SDL_stdinc.h 1931:34
Since: 3.2.0
Arguments
| :: PtrConst Void |
|
| -> PtrConst Void |
|
| -> CSize |
|
| -> CSize |
|
| -> SDL_CompareCallback |
|
| -> 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 atSDL3/SDL_stdinc.h 1981:36
Since: 3.2.0
Arguments
| :: Ptr Void |
|
| -> CSize |
|
| -> CSize |
|
| -> SDL_CompareCallback_r |
|
| -> Ptr Void |
|
| -> 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 atSDL3/SDL_stdinc.h 2051:34
Since: 3.2.0
Arguments
| :: PtrConst Void |
|
| -> PtrConst Void |
|
| -> CSize |
|
| -> CSize |
|
| -> SDL_CompareCallback_r |
|
| -> Ptr Void |
|
| -> 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 atSDL3/SDL_stdinc.h 2109:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2121:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2196:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2211:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2226:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2241:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2256:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2271:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2289:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2311:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2326:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2341:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2360:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2381:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2399:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2417:33
Since: 3.2.0
Arguments
| :: Uint16 |
|
| -> PtrConst Void |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 2438:36
Since: 3.2.0
Arguments
| :: Uint32 |
|
| -> PtrConst Void |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 2459:36
Since: 3.2.0
Arguments
| :: PtrConst Void |
|
| -> CSize |
|
| -> Uint32 |
|
| -> 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 atSDL3/SDL_stdinc.h 2485:36
Since: 3.2.0
Arguments
| :: Ptr Void |
|
| -> PtrConst Void |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 2505:36
Since: 3.2.0
Arguments
| :: Ptr Void |
|
| -> PtrConst Void |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 2561:36
Since: 3.2.0
Arguments
| :: Ptr Void |
|
| -> CInt |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 2589:36
Since: 3.2.0
Arguments
| :: Ptr Void |
|
| -> Uint32 |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 2609:36
Since: 3.2.0
Arguments
| :: PtrConst Void |
|
| -> PtrConst Void |
|
| -> CSize |
|
| -> 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
lenbytes. - Thread safety
- It is safe to call this function from any thread.
- C declaration
SDL_memcmp, defined atSDL3/SDL_stdinc.h 2691:33
Since: 3.2.0
Arguments
| :: PtrConst CWchar |
|
| -> 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 atSDL3/SDL_stdinc.h 2718:36
Since: 3.2.0
Arguments
| :: PtrConst CWchar |
|
| -> CSize |
|
| -> 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
wstrbut never more thanmaxlen. - 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 atSDL3/SDL_stdinc.h 2749:36
Since: 3.2.0
Arguments
| :: Ptr CWchar |
|
| -> PtrConst CWchar |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 2776:36
Since: 3.2.0
Arguments
| :: Ptr CWchar |
|
| -> PtrConst CWchar |
|
| -> CSize |
|
| -> 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
dstplus the length ofsrc. - Thread safety
- It is safe to call this function from any thread.
- See also
sDL_wcslcpy- C declaration
SDL_wcslcat, defined atSDL3/SDL_stdinc.h 2805:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 2823:39
Since: 3.2.0
Arguments
| :: PtrConst CWchar |
|
| -> PtrConst CWchar |
|
| -> 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
needlein the string, or NULL if not found. - Thread safety
- It is safe to call this function from any thread.
- C declaration
SDL_wcsstr, defined atSDL3/SDL_stdinc.h 2843:39
Since: 3.2.0
Arguments
| :: PtrConst CWchar |
|
| -> PtrConst CWchar |
|
| -> CSize |
|
| -> 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
needlein the string, or NULL if not found. - Thread safety
- It is safe to call this function from any thread.
- C declaration
SDL_wcsnstr, defined atSDL3/SDL_stdinc.h 2868:39
Since: 3.2.0
Arguments
| :: PtrConst CWchar |
|
| -> PtrConst CWchar |
|
| -> 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 atSDL3/SDL_stdinc.h 2887:33
Since: 3.2.0
Arguments
| :: PtrConst CWchar |
|
| -> PtrConst CWchar |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 2918:33
Since: 3.2.0
Arguments
| :: PtrConst CWchar |
|
| -> PtrConst CWchar |
|
| -> 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 atSDL3/SDL_stdinc.h 2948:33
Since: 3.2.0
Arguments
| :: PtrConst CWchar |
|
| -> PtrConst CWchar |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 2990:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 3037:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> CSize |
|
| -> 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
srcbut never more thanmaxlen. - 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 atSDL3/SDL_stdinc.h 3061:36
Since: 3.2.0
Arguments
| :: Ptr CChar |
|
| -> PtrConst CChar |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 3090:36
Since: 3.2.0
Arguments
| :: Ptr CChar |
|
| -> PtrConst CChar |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 3118:36
Since: 3.2.0
Arguments
| :: Ptr CChar |
|
| -> PtrConst CChar |
|
| -> CSize |
|
| -> 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
dstplus the length ofsrc. - Thread safety
- It is safe to call this function from any thread.
- See also
sDL_strlcpy- C declaration
SDL_strlcat, defined atSDL3/SDL_stdinc.h 3146:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 3164:47
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 3189:47
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 3210:36
Since: 3.2.0
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
strpointer 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 atSDL3/SDL_stdinc.h 3231:36
Since: 3.2.0
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
strpointer 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 atSDL3/SDL_stdinc.h 3252:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> CInt |
|
| -> 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
cin the string, or NULL if not found. - Thread safety
- It is safe to call this function from any thread.
- C declaration
SDL_strchr, defined atSDL3/SDL_stdinc.h 3272:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> CInt |
|
| -> 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
cin the string, or NULL if not found. - Thread safety
- It is safe to call this function from any thread.
- C declaration
SDL_strrchr, defined atSDL3/SDL_stdinc.h 3291:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> 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
needlein the string, or NULL if not found. - Thread safety
- It is safe to call this function from any thread.
- C declaration
SDL_strstr, defined atSDL3/SDL_stdinc.h 3311:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> CSize |
|
| -> 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
needlein the string, or NULL if not found. - Thread safety
- It is safe to call this function from any thread.
- C declaration
SDL_strnstr, defined atSDL3/SDL_stdinc.h 3334:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> 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
needlein the string, or NULL if not found. - Thread safety
- It is safe to call this function from any thread.
- C declaration
SDL_strcasestr, defined atSDL3/SDL_stdinc.h 3362:36
Since: 3.2.0
Arguments
| :: Ptr CChar |
|
| -> PtrConst CChar |
|
| -> Ptr (Ptr CChar) |
|
| -> 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 atSDL3/SDL_stdinc.h 3391:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 3419:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> CSize |
|
| -> 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
srcbut never more thanmaxlen. - Thread safety
- It is safe to call this function from any thread.
- See also
sDL_utf8strlen,sDL_strnlen- C declaration
SDL_utf8strnlen, defined atSDL3/SDL_stdinc.h 3452:36
Since: 3.2.0
Arguments
| :: CInt |
|
| -> Ptr CChar |
|
| -> CInt |
|
| -> 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 atSDL3/SDL_stdinc.h 3480:36
Since: 3.2.0
Arguments
| :: CUInt |
|
| -> Ptr CChar |
|
| -> CInt |
|
| -> 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 atSDL3/SDL_stdinc.h 3508:36
Since: 3.2.0
Arguments
| :: CLLong |
|
| -> Ptr CChar |
|
| -> CInt |
|
| -> 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 atSDL3/SDL_stdinc.h 3594:36
Since: 3.2.0
Arguments
| :: CULLong |
|
| -> Ptr CChar |
|
| -> CInt |
|
| -> 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 atSDL3/SDL_stdinc.h 3622:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 3646:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 3668:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> Ptr (Ptr CChar) |
|
| -> CInt |
|
| -> 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 atSDL3/SDL_stdinc.h 3770:39
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> Ptr (Ptr CChar) |
|
| -> CInt |
|
| -> 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 atSDL3/SDL_stdinc.h 3804:48
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> Ptr (Ptr CChar) |
|
| -> 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 atSDL3/SDL_stdinc.h 3834:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> 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 atSDL3/SDL_stdinc.h 3854:33
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 3884:33
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> 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 atSDL3/SDL_stdinc.h 3912:33
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 3952:33
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> 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 atSDL3/SDL_stdinc.h 3970:36
Since: 3.2.0
Arguments
| :: Ptr (PtrConst CChar) |
|
| -> Ptr CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 4030:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> Ptr (PtrConst CChar) |
|
| -> 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 atSDL3/SDL_stdinc.h 4061:36
Since: 3.2.0
Arguments
| :: Uint32 |
|
| -> Ptr CChar |
|
| -> 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 atSDL3/SDL_stdinc.h 4090:36
Since: 3.2.0
Arguments
| :: Uint64 |
|
| -> 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 atSDL3/SDL_stdinc.h 4302:34
Since: 3.2.0
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 atSDL3/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 atSDL3/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 atSDL3/SDL_stdinc.h 4382:36
Since: 3.2.0
Arguments
| :: Ptr Uint64 |
|
| -> Sint32 |
|
| -> 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 atSDL3/SDL_stdinc.h 4417:36
Since: 3.2.0
Arguments
| :: Ptr Uint64 |
|
| -> 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 atSDL3/SDL_stdinc.h 4444:35
Since: 3.2.0
Arguments
| :: Ptr Uint64 |
|
| -> 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 atSDL3/SDL_stdinc.h 4469:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 4523:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 4553:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 4583:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 4613:35
Since: 3.2.0
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
xin radians, or 0 ifx = 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 atSDL3/SDL_stdinc.h 4645:36
Since: 3.2.0
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
xin radians, or 0 ifx = 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 atSDL3/SDL_stdinc.h 4677:35
Since: 3.2.0
Arguments
| :: CDouble |
|
| -> CDouble |
|
| -> 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 / xin radians, or, ifx = 0, either-Pi/2,0, orPi/2, depending on the value ofy. - 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 atSDL3/SDL_stdinc.h 4713:36
Since: 3.2.0
Arguments
| :: CFloat |
|
| -> CFloat |
|
| -> 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 / xin radians, or, ifx = 0, either-Pi/2,0, orPi/2, depending on the value ofy. - 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 atSDL3/SDL_stdinc.h 4749:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 4777:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 4805:35
Since: 3.2.0
Arguments
| :: CDouble |
|
| -> CDouble |
|
| -> 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 atSDL3/SDL_stdinc.h 4831:36
Since: 3.2.0
Arguments
| :: CFloat |
|
| -> CFloat |
|
| -> 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 atSDL3/SDL_stdinc.h 4857:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 4885:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 4913:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 4945:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 4977:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 4998:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5019:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5047:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5075:35
Since: 3.2.0
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
xtruncated 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 atSDL3/SDL_stdinc.h 5104:36
Since: 3.2.0
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
xtruncated 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 atSDL3/SDL_stdinc.h 5133:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5163:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5193:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5207:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5221:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5235:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5249:33
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5279:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5308:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5338:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5368:35
Since: 3.2.0
Arguments
| :: CDouble |
|
| -> Ptr CDouble |
|
| -> 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 atSDL3/SDL_stdinc.h 5388:36
Since: 3.2.0
Arguments
| :: CFloat |
|
| -> Ptr CFloat |
|
| -> 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 atSDL3/SDL_stdinc.h 5408:35
Since: 3.2.0
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
xraised to the powery.- 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 atSDL3/SDL_stdinc.h 5440:36
Since: 3.2.0
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
xraised to the powery.- 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 atSDL3/SDL_stdinc.h 5472:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5501:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5530:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5613:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5638:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5666:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5694:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5720:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5746:35
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5776:36
Since: 3.2.0
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 atSDL3/SDL_stdinc.h 5806:35
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> 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 atSDL3/SDL_stdinc.h 5834:41
Since: 3.2.0
Arguments
| :: SDL_iconv_t |
|
| -> 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 atSDL3/SDL_stdinc.h 5851:33
Since: 3.2.0
Arguments
| :: SDL_iconv_t |
|
| -> Ptr (PtrConst CChar) |
|
| -> Ptr CSize |
|
| -> Ptr (Ptr CChar) |
|
| -> Ptr CSize |
|
| -> 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_tfrom two threads at once. - See also
sDL_iconv_open,sDL_iconv_close,sDL_iconv_string- C declaration
SDL_iconv, defined atSDL3/SDL_stdinc.h 5891:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> CSize |
|
| -> 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 atSDL3/SDL_stdinc.h 5928:36
Since: 3.2.0
sDL_size_mul_check_overflow_builtin Source #
- C declaration
SDL_size_mul_check_overflow_builtin, defined atSDL3/SDL_stdinc.h 6109:23