SDL 3.0
SDL_stdinc.h File Reference
#include <SDL3/SDL_platform_defines.h>
#include <stdarg.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <SDL3/SDL_begin_code.h>
#include <SDL3/SDL_close_code.h>
+ Include dependency graph for SDL_stdinc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SDL_SIZE_MAX   ((size_t) -1)
 
#define SDL_HAS_BUILTIN(x)   0
 
#define SDL_arraysize(array)   (sizeof(array)/sizeof(array[0]))
 
#define SDL_STRINGIFY_ARG(arg)   #arg
 
Cast operators

Use proper C++ casts when compiled as C++ to be compatible with the option -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above).

#define SDL_reinterpret_cast(type, expression)   ((type)(expression))
 
#define SDL_static_cast(type, expression)   ((type)(expression))
 
#define SDL_const_cast(type, expression)   ((type)(expression))
 
#define SDL_FOURCC(A, B, C, D)
 
#define SDL_SINT64_C(c)   c ## LL
 
#define SDL_UINT64_C(c)   c ## ULL
 

Functions

void * alloca (size_t)
 

Basic data types

#define SDL_FALSE   0
 
#define SDL_TRUE   1
 
#define SDL_MAX_SINT8   ((Sint8)0x7F) /* 127 */
 
#define SDL_MIN_SINT8   ((Sint8)(~0x7F)) /* -128 */
 
#define SDL_MAX_UINT8   ((Uint8)0xFF) /* 255 */
 
#define SDL_MIN_UINT8   ((Uint8)0x00) /* 0 */
 
#define SDL_MAX_SINT16   ((Sint16)0x7FFF) /* 32767 */
 
#define SDL_MIN_SINT16   ((Sint16)(~0x7FFF)) /* -32768 */
 
#define SDL_MAX_UINT16   ((Uint16)0xFFFF) /* 65535 */
 
#define SDL_MIN_UINT16   ((Uint16)0x0000) /* 0 */
 
#define SDL_MAX_SINT32   ((Sint32)0x7FFFFFFF) /* 2147483647 */
 
#define SDL_MIN_SINT32   ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */
 
#define SDL_MAX_UINT32   ((Uint32)0xFFFFFFFFu) /* 4294967295 */
 
#define SDL_MIN_UINT32   ((Uint32)0x00000000) /* 0 */
 
#define SDL_MAX_SINT64   SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* 9223372036854775807 */
 
#define SDL_MIN_SINT64   ~SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* -9223372036854775808 */
 
#define SDL_MAX_UINT64   SDL_UINT64_C(0xFFFFFFFFFFFFFFFF) /* 18446744073709551615 */
 
#define SDL_MIN_UINT64   SDL_UINT64_C(0x0000000000000000) /* 0 */
 
#define SDL_MAX_TIME   SDL_MAX_SINT64
 
#define SDL_MIN_TIME   SDL_MIN_SINT64
 
typedef int SDL_bool
 
typedef int8_t Sint8
 
typedef uint8_t Uint8
 
typedef int16_t Sint16
 
typedef uint16_t Uint16
 
typedef int32_t Sint32
 
typedef uint32_t Uint32
 
typedef int64_t Sint64
 
typedef uint64_t Uint64
 
typedef Sint64 SDL_Time
 

Floating-point constants

#define SDL_FLT_EPSILON   1.1920928955078125e-07F /* 0x0.000002p0 */
 
#define SDL_PRIs64   "lld"
 
#define SDL_PRIu64   "llu"
 
#define SDL_PRIx64   "llx"
 
#define SDL_PRIX64   "llX"
 
#define SDL_PRIs32   "d"
 
#define SDL_PRIu32   "u"
 
#define SDL_PRIx32   "x"
 
#define SDL_PRIX32   "X"
 
#define SDL_IN_BYTECAP(x)
 
#define SDL_INOUT_Z_CAP(x)
 
#define SDL_OUT_Z_CAP(x)
 
#define SDL_OUT_CAP(x)
 
#define SDL_OUT_BYTECAP(x)
 
#define SDL_OUT_Z_BYTECAP(x)
 
#define SDL_PRINTF_FORMAT_STRING
 
#define SDL_SCANF_FORMAT_STRING
 
#define SDL_PRINTF_VARARG_FUNC(fmtargnumber)
 
#define SDL_PRINTF_VARARG_FUNCV(fmtargnumber)
 
#define SDL_SCANF_VARARG_FUNC(fmtargnumber)
 
#define SDL_SCANF_VARARG_FUNCV(fmtargnumber)
 
#define SDL_WPRINTF_VARARG_FUNC(fmtargnumber)
 
#define SDL_WSCANF_VARARG_FUNC(fmtargnumber)
 
#define SDL_COMPILE_TIME_ASSERT(name, x)    typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
 
#define SDL_stack_alloc(type, count)   (type*)alloca(sizeof(type)*(count))
 
#define SDL_stack_free(data)
 
#define SDL_min(x, y)   (((x) < (y)) ? (x) : (y))
 
#define SDL_max(x, y)   (((x) > (y)) ? (x) : (y))
 
#define SDL_clamp(x, a, b)   (((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x)))
 
#define SDL_memcpy   memcpy
 
#define SDL_copyp(dst, src)
 
#define SDL_memmove   memmove
 
#define SDL_memset   memset
 
#define SDL_zero(x)   SDL_memset(&(x), 0, sizeof((x)))
 
#define SDL_zerop(x)   SDL_memset((x), 0, sizeof(*(x)))
 
#define SDL_zeroa(x)   SDL_memset((x), 0, sizeof((x)))
 
#define SDL_INVALID_UNICODE_CODEPOINT   0xFFFD
 
#define SDL_PI_D   3.141592653589793238462643383279502884
 
#define SDL_PI_F   3.141592653589793238462643383279502884F
 
#define SDL_ICONV_ERROR   (size_t)-1
 
#define SDL_ICONV_E2BIG   (size_t)-2
 
#define SDL_ICONV_EILSEQ   (size_t)-3
 
#define SDL_ICONV_EINVAL   (size_t)-4
 
#define SDL_iconv_utf8_locale(S)   SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
 
#define SDL_iconv_utf8_ucs2(S)   (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
 
#define SDL_iconv_utf8_ucs4(S)   (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
 
#define SDL_iconv_wchar_utf8(S)   SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t))
 
typedef void *(* SDL_malloc_func) (size_t size)
 
typedef void *(* SDL_calloc_func) (size_t nmemb, size_t size)
 
typedef void *(* SDL_realloc_func) (void *mem, size_t size)
 
typedef void(* SDL_free_func) (void *mem)
 
typedef int(* SDL_CompareCallback) (const void *a, const void *b)
 
typedef int(* SDL_CompareCallback_r) (void *userdata, const void *a, const void *b)
 
typedef struct SDL_iconv_data_t * SDL_iconv_t
 
typedef void(* SDL_FunctionPointer) (void)
 
SDL_MALLOC size_t size
 
SDL_MALLOC void * SDL_malloc (size_t size)
 
SDL_MALLOC SDL_ALLOC_SIZE2 (1, 2) void *SDL_calloc(size_t nmemb
 
 SDL_ALLOC_SIZE (2) void *SDL_realloc(void *mem
 
void SDL_free (void *mem)
 
void SDL_GetOriginalMemoryFunctions (SDL_malloc_func *malloc_func, SDL_calloc_func *calloc_func, SDL_realloc_func *realloc_func, SDL_free_func *free_func)
 
void SDL_GetMemoryFunctions (SDL_malloc_func *malloc_func, SDL_calloc_func *calloc_func, SDL_realloc_func *realloc_func, SDL_free_func *free_func)
 
int SDL_SetMemoryFunctions (SDL_malloc_func malloc_func, SDL_calloc_func calloc_func, SDL_realloc_func realloc_func, SDL_free_func free_func)
 
SDL_MALLOC void * SDL_aligned_alloc (size_t alignment, size_t size)
 
void SDL_aligned_free (void *mem)
 
int SDL_GetNumAllocations (void)
 
const char * SDL_getenv (const char *name)
 
int SDL_setenv (const char *name, const char *value, int overwrite)
 
int SDL_unsetenv (const char *name)
 
void SDL_qsort (void *base, size_t nmemb, size_t size, SDL_CompareCallback compare)
 
void * SDL_bsearch (const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback compare)
 
void SDL_qsort_r (void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata)
 
void * SDL_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata)
 
int SDL_abs (int x)
 
int SDL_isalpha (int x)
 
int SDL_isalnum (int x)
 
int SDL_isblank (int x)
 
int SDL_iscntrl (int x)
 
int SDL_isdigit (int x)
 
int SDL_isxdigit (int x)
 
int SDL_ispunct (int x)
 
int SDL_isspace (int x)
 
int SDL_isupper (int x)
 
int SDL_islower (int x)
 
int SDL_isprint (int x)
 
int SDL_isgraph (int x)
 
int SDL_toupper (int x)
 
int SDL_tolower (int x)
 
Uint16 SDL_crc16 (Uint16 crc, const void *data, size_t len)
 
Uint32 SDL_crc32 (Uint32 crc, const void *data, size_t len)
 
void * SDL_memcpy (SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
 
void * SDL_memmove (SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
 
void * SDL_memset (SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
 
void * SDL_memset4 (void *dst, Uint32 val, size_t dwords)
 
int SDL_memcmp (const void *s1, const void *s2, size_t len)
 
size_t SDL_wcslen (const wchar_t *wstr)
 
size_t SDL_wcsnlen (const wchar_t *wstr, size_t maxlen)
 
size_t SDL_wcslcpy (SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
 
size_t SDL_wcslcat (SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
 
wchar_t * SDL_wcsdup (const wchar_t *wstr)
 
wchar_t * SDL_wcsstr (const wchar_t *haystack, const wchar_t *needle)
 
wchar_t * SDL_wcsnstr (const wchar_t *haystack, const wchar_t *needle, size_t maxlen)
 
int SDL_wcscmp (const wchar_t *str1, const wchar_t *str2)
 
int SDL_wcsncmp (const wchar_t *str1, const wchar_t *str2, size_t maxlen)
 
int SDL_wcscasecmp (const wchar_t *str1, const wchar_t *str2)
 
int SDL_wcsncasecmp (const wchar_t *str1, const wchar_t *str2, size_t maxlen)
 
long SDL_wcstol (const wchar_t *str, wchar_t **endp, int base)
 
size_t SDL_strlen (const char *str)
 
size_t SDL_strnlen (const char *str, size_t maxlen)
 
size_t SDL_strlcpy (SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
 
size_t SDL_utf8strlcpy (SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes)
 
size_t SDL_strlcat (SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
 
SDL_MALLOC char * SDL_strdup (const char *str)
 
SDL_MALLOC char * SDL_strndup (const char *str, size_t maxlen)
 
char * SDL_strrev (char *str)
 
char * SDL_strupr (char *str)
 
char * SDL_strlwr (char *str)
 
char * SDL_strchr (const char *str, int c)
 
char * SDL_strrchr (const char *str, int c)
 
char * SDL_strstr (const char *haystack, const char *needle)
 
char * SDL_strnstr (const char *haystack, const char *needle, size_t maxlen)
 
char * SDL_strcasestr (const char *haystack, const char *needle)
 
char * SDL_strtok_r (char *s1, const char *s2, char **saveptr)
 
size_t SDL_utf8strlen (const char *str)
 
size_t SDL_utf8strnlen (const char *str, size_t bytes)
 
char * SDL_itoa (int value, char *str, int radix)
 
char * SDL_uitoa (unsigned int value, char *str, int radix)
 
char * SDL_ltoa (long value, char *str, int radix)
 
char * SDL_ultoa (unsigned long value, char *str, int radix)
 
char * SDL_lltoa (Sint64 value, char *str, int radix)
 
char * SDL_ulltoa (Uint64 value, char *str, int radix)
 
int SDL_atoi (const char *str)
 
double SDL_atof (const char *str)
 
long SDL_strtol (const char *str, char **endp, int base)
 
unsigned long SDL_strtoul (const char *str, char **endp, int base)
 
Sint64 SDL_strtoll (const char *str, char **endp, int base)
 
Uint64 SDL_strtoull (const char *str, char **endp, int base)
 
double SDL_strtod (const char *str, char **endp)
 
int SDL_strcmp (const char *str1, const char *str2)
 
int SDL_strncmp (const char *str1, const char *str2, size_t maxlen)
 
int SDL_strcasecmp (const char *str1, const char *str2)
 
int SDL_strncasecmp (const char *str1, const char *str2, size_t maxlen)
 
Uint32 SDL_StepUTF8 (const char **pstr, size_t *pslen)
 
char * SDL_UCS4ToUTF8 (Uint32 codepoint, char *dst)
 
int SDL_sscanf (const char *text, SDL_SCANF_FORMAT_STRING const char *fmt,...) SDL_SCANF_VARARG_FUNC(2)
 
int SDL_vsscanf (const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap) SDL_SCANF_VARARG_FUNCV(2)
 
int SDL_snprintf (SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(3)
 
int SDL_swprintf (SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt,...) SDL_WPRINTF_VARARG_FUNC(3)
 
int SDL_vsnprintf (SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3)
 
int SDL_vswprintf (SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, const wchar_t *fmt, va_list ap)
 
int SDL_asprintf (char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(2)
 
int SDL_vasprintf (char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2)
 
void SDL_srand (Uint64 seed)
 
Sint32 SDL_rand (Sint32 n)
 
float SDL_randf (void)
 
Uint32 SDL_rand_bits (void)
 
Sint32 SDL_rand_r (Uint64 *state, Sint32 n)
 
float SDL_randf_r (Uint64 *state)
 
Uint32 SDL_rand_bits_r (Uint64 *state)
 
double SDL_acos (double x)
 
float SDL_acosf (float x)
 
double SDL_asin (double x)
 
float SDL_asinf (float x)
 
double SDL_atan (double x)
 
float SDL_atanf (float x)
 
double SDL_atan2 (double y, double x)
 
float SDL_atan2f (float y, float x)
 
double SDL_ceil (double x)
 
float SDL_ceilf (float x)
 
double SDL_copysign (double x, double y)
 
float SDL_copysignf (float x, float y)
 
double SDL_cos (double x)
 
float SDL_cosf (float x)
 
double SDL_exp (double x)
 
float SDL_expf (float x)
 
double SDL_fabs (double x)
 
float SDL_fabsf (float x)
 
double SDL_floor (double x)
 
float SDL_floorf (float x)
 
double SDL_trunc (double x)
 
float SDL_truncf (float x)
 
double SDL_fmod (double x, double y)
 
float SDL_fmodf (float x, float y)
 
int SDL_isinf (double x)
 
int SDL_isinff (float x)
 
int SDL_isnan (double x)
 
int SDL_isnanf (float x)
 
double SDL_log (double x)
 
float SDL_logf (float x)
 
double SDL_log10 (double x)
 
float SDL_log10f (float x)
 
double SDL_modf (double x, double *y)
 
float SDL_modff (float x, float *y)
 
double SDL_pow (double x, double y)
 
float SDL_powf (float x, float y)
 
double SDL_round (double x)
 
float SDL_roundf (float x)
 
long SDL_lround (double x)
 
long SDL_lroundf (float x)
 
double SDL_scalbn (double x, int n)
 
float SDL_scalbnf (float x, int n)
 
double SDL_sin (double x)
 
float SDL_sinf (float x)
 
double SDL_sqrt (double x)
 
float SDL_sqrtf (float x)
 
double SDL_tan (double x)
 
float SDL_tanf (float x)
 
SDL_iconv_t SDL_iconv_open (const char *tocode, const char *fromcode)
 
int SDL_iconv_close (SDL_iconv_t cd)
 
size_t SDL_iconv (SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
 
char * SDL_iconv_string (const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft)
 
SDL_FORCE_INLINE int SDL_size_mul_overflow (size_t a, size_t b, size_t *ret)
 
SDL_FORCE_INLINE int SDL_size_add_overflow (size_t a, size_t b, size_t *ret)
 

Macro Definition Documentation

◆ SDL_arraysize

#define SDL_arraysize (   array)    (sizeof(array)/sizeof(array[0]))

The number of elements in an array.

This macro looks like it double-evaluates the argument, but it does so inside of sizeof, so there are no side-effects here, as expressions do not actually run any code in these cases.

Since
This macro is available since SDL 3.0.0.

Definition at line 100 of file SDL_stdinc.h.

◆ SDL_clamp

#define SDL_clamp (   x,
  a,
 
)    (((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x)))

Definition at line 683 of file SDL_stdinc.h.

◆ SDL_COMPILE_TIME_ASSERT

#define SDL_COMPILE_TIME_ASSERT (   name,
 
)     typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]

Definition at line 479 of file SDL_stdinc.h.

507{
508 DUMMY_ENUM_VALUE
509} SDL_DUMMY_ENUM;
510
511SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
512#endif
513#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
514/** \endcond */
515
516#include <SDL3/SDL_begin_code.h>
517/* Set up for C function definitions, even when using C++ */
518#ifdef __cplusplus
519extern "C" {
520#endif
521
522#ifndef SDL_DISABLE_ALLOCA
523#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count))
524#define SDL_stack_free(data)
525#else
526#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count))
527#define SDL_stack_free(data) SDL_free(data)
528#endif
529
530extern SDL_DECLSPEC SDL_MALLOC void * SDLCALL SDL_malloc(size_t size);
531extern SDL_DECLSPEC SDL_MALLOC SDL_ALLOC_SIZE2(1, 2) void * SDLCALL SDL_calloc(size_t nmemb, size_t size);
532extern SDL_DECLSPEC SDL_ALLOC_SIZE(2) void * SDLCALL SDL_realloc(void *mem, size_t size);
533extern SDL_DECLSPEC void SDLCALL SDL_free(void *mem);
534
535typedef void *(SDLCALL *SDL_malloc_func)(size_t size);
536typedef void *(SDLCALL *SDL_calloc_func)(size_t nmemb, size_t size);
537typedef void *(SDLCALL *SDL_realloc_func)(void *mem, size_t size);
538typedef void (SDLCALL *SDL_free_func)(void *mem);
539
540/**
541 * Get the original set of SDL memory functions.
542 *
543 * This is what SDL_malloc and friends will use by default, if there has been
544 * no call to SDL_SetMemoryFunctions. This is not necessarily using the C
545 * runtime's `malloc` functions behind the scenes! Different platforms and
546 * build configurations might do any number of unexpected things.
547 *
548 * \param malloc_func filled with malloc function.
549 * \param calloc_func filled with calloc function.
550 * \param realloc_func filled with realloc function.
551 * \param free_func filled with free function.
552 *
553 * \threadsafety It is safe to call this function from any thread.
554 *
555 * \since This function is available since SDL 3.0.0.
556 */
557extern SDL_DECLSPEC void SDLCALL SDL_GetOriginalMemoryFunctions(SDL_malloc_func *malloc_func,
558 SDL_calloc_func *calloc_func,
559 SDL_realloc_func *realloc_func,
560 SDL_free_func *free_func);
561
562/**
563 * Get the current set of SDL memory functions.
564 *
565 * \param malloc_func filled with malloc function.
566 * \param calloc_func filled with calloc function.
567 * \param realloc_func filled with realloc function.
568 * \param free_func filled with free function.
569 *
570 * \threadsafety This does not hold a lock, so do not call this in the
571 * unlikely event of a background thread calling
572 * SDL_SetMemoryFunctions simultaneously.
573 *
574 * \since This function is available since SDL 3.0.0.
575 *
576 * \sa SDL_SetMemoryFunctions
577 * \sa SDL_GetOriginalMemoryFunctions
578 */
579extern SDL_DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func,
580 SDL_calloc_func *calloc_func,
581 SDL_realloc_func *realloc_func,
582 SDL_free_func *free_func);
583
584/**
585 * Replace SDL's memory allocation functions with a custom set.
586 *
587 * It is not safe to call this function once any allocations have been made,
588 * as future calls to SDL_free will use the new allocator, even if they came
589 * from an SDL_malloc made with the old one!
590 *
591 * If used, usually this needs to be the first call made into the SDL library,
592 * if not the very first thing done at program startup time.
593 *
594 * \param malloc_func custom malloc function.
595 * \param calloc_func custom calloc function.
596 * \param realloc_func custom realloc function.
597 * \param free_func custom free function.
598 * \returns 0 on success or a negative error code on failure; call
599 * SDL_GetError() for more information.
600 *
601 * \threadsafety It is safe to call this function from any thread, but one
602 * should not replace the memory functions once any allocations
603 * are made!
604 *
605 * \since This function is available since SDL 3.0.0.
606 *
607 * \sa SDL_GetMemoryFunctions
608 * \sa SDL_GetOriginalMemoryFunctions
609 */
610extern SDL_DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
611 SDL_calloc_func calloc_func,
612 SDL_realloc_func realloc_func,
613 SDL_free_func free_func);
614
615/**
616 * Allocate memory aligned to a specific value.
617 *
618 * If `alignment` is less than the size of `void *`, then it will be increased
619 * to match that.
620 *
621 * The returned memory address will be a multiple of the alignment value, and
622 * the amount of memory allocated will be a multiple of the alignment value.
623 *
624 * The memory returned by this function must be freed with SDL_aligned_free(),
625 * and _not_ SDL_free.
626 *
627 * \param alignment the alignment requested.
628 * \param size the size to allocate.
629 * \returns a pointer to the aligned memory.
630 *
631 * \threadsafety It is safe to call this function from any thread.
632 *
633 * \since This function is available since SDL 3.0.0.
634 *
635 * \sa SDL_aligned_free
636 */
637extern SDL_DECLSPEC SDL_MALLOC void * SDLCALL SDL_aligned_alloc(size_t alignment, size_t size);
638
639/**
640 * Free memory allocated by SDL_aligned_alloc().
641 *
642 * The pointer is no longer valid after this call and cannot be dereferenced
643 * anymore.
644 *
645 * \param mem a pointer previously returned by SDL_aligned_alloc.
646 *
647 * \threadsafety It is safe to call this function from any thread.
648 *
649 * \since This function is available since SDL 3.0.0.
650 *
651 * \sa SDL_aligned_alloc
652 */
653extern SDL_DECLSPEC void SDLCALL SDL_aligned_free(void *mem);
654
655/**
656 * Get the number of outstanding (unfreed) allocations.
657 *
658 * \returns the number of allocations.
659 *
660 * \threadsafety It is safe to call this function from any thread.
661 *
662 * \since This function is available since SDL 3.0.0.
663 */
664extern SDL_DECLSPEC int SDLCALL SDL_GetNumAllocations(void);
665
666extern SDL_DECLSPEC const char * SDLCALL SDL_getenv(const char *name);
667extern SDL_DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
668extern SDL_DECLSPEC int SDLCALL SDL_unsetenv(const char *name);
669
670typedef int (SDLCALL *SDL_CompareCallback)(const void *a, const void *b);
671extern SDL_DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, SDL_CompareCallback compare);
672extern SDL_DECLSPEC void * SDLCALL SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback compare);
673
674typedef int (SDLCALL *SDL_CompareCallback_r)(void *userdata, const void *a, const void *b);
675extern SDL_DECLSPEC void SDLCALL SDL_qsort_r(void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata);
676extern SDL_DECLSPEC void * SDLCALL SDL_bsearch_r(const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata);
677
678extern SDL_DECLSPEC int SDLCALL SDL_abs(int x);
679
680/* NOTE: these double-evaluate their arguments, so you should never have side effects in the parameters */
681#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
682#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
683#define SDL_clamp(x, a, b) (((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x)))
684
685/**
686 * Query if a character is alphabetic (a letter).
687 *
688 * **WARNING**: Regardless of system locale, this will only treat ASCII values
689 * for English 'a-z' and 'A-Z' as true.
690 *
691 * \param x character value to check.
692 * \returns non-zero if x falls within the character class, zero otherwise.
693 *
694 * \threadsafety It is safe to call this function from any thread.
695 *
696 * \since This function is available since SDL 3.0.0.
697 */
698extern SDL_DECLSPEC int SDLCALL SDL_isalpha(int x);
699
700/**
701 * Query if a character is alphabetic (a letter) or a number.
702 *
703 * **WARNING**: Regardless of system locale, this will only treat ASCII values
704 * for English 'a-z', 'A-Z', and '0-9' as true.
705 *
706 * \param x character value to check.
707 * \returns non-zero if x falls within the character class, zero otherwise.
708 *
709 * \threadsafety It is safe to call this function from any thread.
710 *
711 * \since This function is available since SDL 3.0.0.
712 */
713extern SDL_DECLSPEC int SDLCALL SDL_isalnum(int x);
714
715/**
716 * Report if a character is blank (a space or tab).
717 *
718 * **WARNING**: Regardless of system locale, this will only treat ASCII values
719 * 0x20 (space) or 0x9 (tab) as true.
720 *
721 * \param x character value to check.
722 * \returns non-zero if x falls within the character class, zero otherwise.
723 *
724 * \threadsafety It is safe to call this function from any thread.
725 *
726 * \since This function is available since SDL 3.0.0.
727 */
728extern SDL_DECLSPEC int SDLCALL SDL_isblank(int x);
729
730/**
731 * Report if a character is a control character.
732 *
733 * **WARNING**: Regardless of system locale, this will only treat ASCII values
734 * 0 through 0x1F, and 0x7F, as true.
735 *
736 * \param x character value to check.
737 * \returns non-zero if x falls within the character class, zero otherwise.
738 *
739 * \threadsafety It is safe to call this function from any thread.
740 *
741 * \since This function is available since SDL 3.0.0.
742 */
743extern SDL_DECLSPEC int SDLCALL SDL_iscntrl(int x);
744
745/**
746 * Report if a character is a numeric digit.
747 *
748 * **WARNING**: Regardless of system locale, this will only treat ASCII values
749 * '0' (0x30) through '9' (0x39), as true.
750 *
751 * \param x character value to check.
752 * \returns non-zero if x falls within the character class, zero otherwise.
753 *
754 * \threadsafety It is safe to call this function from any thread.
755 *
756 * \since This function is available since SDL 3.0.0.
757 */
758extern SDL_DECLSPEC int SDLCALL SDL_isdigit(int x);
759
760/**
761 * Report if a character is a hexadecimal digit.
762 *
763 * **WARNING**: Regardless of system locale, this will only treat ASCII values
764 * 'A' through 'F', 'a' through 'f', and '0' through '9', as true.
765 *
766 * \param x character value to check.
767 * \returns non-zero if x falls within the character class, zero otherwise.
768 *
769 * \threadsafety It is safe to call this function from any thread.
770 *
771 * \since This function is available since SDL 3.0.0.
772 */
773extern SDL_DECLSPEC int SDLCALL SDL_isxdigit(int x);
774
775/**
776 * Report if a character is a punctuation mark.
777 *
778 * **WARNING**: Regardless of system locale, this is equivalent to
779 * `((SDL_isgraph(x)) && (!SDL_isalnum(x)))`.
780 *
781 * \param x character value to check.
782 * \returns non-zero if x falls within the character class, zero otherwise.
783 *
784 * \threadsafety It is safe to call this function from any thread.
785 *
786 * \since This function is available since SDL 3.0.0.
787 *
788 * \sa SDL_isgraph
789 * \sa SDL_isalnum
790 */
791extern SDL_DECLSPEC int SDLCALL SDL_ispunct(int x);
792
793/**
794 * Report if a character is whitespace.
795 *
796 * **WARNING**: Regardless of system locale, this will only treat the
797 * following ASCII values as true:
798 *
799 * - space (0x20)
800 * - tab (0x09)
801 * - newline (0x0A)
802 * - vertical tab (0x0B)
803 * - form feed (0x0C)
804 * - return (0x0D)
805 *
806 * \param x character value to check.
807 * \returns non-zero if x falls within the character class, zero otherwise.
808 *
809 * \threadsafety It is safe to call this function from any thread.
810 *
811 * \since This function is available since SDL 3.0.0.
812 */
813extern SDL_DECLSPEC int SDLCALL SDL_isspace(int x);
814
815/**
816 * Report if a character is upper case.
817 *
818 * **WARNING**: Regardless of system locale, this will only treat ASCII values
819 * 'A' through 'Z' as true.
820 *
821 * \param x character value to check.
822 * \returns non-zero if x falls within the character class, zero otherwise.
823 *
824 * \threadsafety It is safe to call this function from any thread.
825 *
826 * \since This function is available since SDL 3.0.0.
827 */
828extern SDL_DECLSPEC int SDLCALL SDL_isupper(int x);
829
830/**
831 * Report if a character is lower case.
832 *
833 * **WARNING**: Regardless of system locale, this will only treat ASCII values
834 * 'a' through 'z' as true.
835 *
836 * \param x character value to check.
837 * \returns non-zero if x falls within the character class, zero otherwise.
838 *
839 * \threadsafety It is safe to call this function from any thread.
840 *
841 * \since This function is available since SDL 3.0.0.
842 */
843extern SDL_DECLSPEC int SDLCALL SDL_islower(int x);
844
845/**
846 * Report if a character is "printable".
847 *
848 * Be advised that "printable" has a definition that goes back to text
849 * terminals from the dawn of computing, making this a sort of special case
850 * function that is not suitable for Unicode (or most any) text management.
851 *
852 * **WARNING**: Regardless of system locale, this will only treat ASCII values
853 * ' ' (0x20) through '~' (0x7E) as true.
854 *
855 * \param x character value to check.
856 * \returns non-zero if x falls within the character class, zero otherwise.
857 *
858 * \threadsafety It is safe to call this function from any thread.
859 *
860 * \since This function is available since SDL 3.0.0.
861 */
862extern SDL_DECLSPEC int SDLCALL SDL_isprint(int x);
863
864/**
865 * Report if a character is any "printable" except space.
866 *
867 * Be advised that "printable" has a definition that goes back to text
868 * terminals from the dawn of computing, making this a sort of special case
869 * function that is not suitable for Unicode (or most any) text management.
870 *
871 * **WARNING**: Regardless of system locale, this is equivalent to
872 * `(SDL_isprint(x)) && ((x) != ' ')`.
873 *
874 * \param x character value to check.
875 * \returns non-zero if x falls within the character class, zero otherwise.
876 *
877 * \threadsafety It is safe to call this function from any thread.
878 *
879 * \since This function is available since SDL 3.0.0.
880 *
881 * \sa SDL_isprint
882 */
883extern SDL_DECLSPEC int SDLCALL SDL_isgraph(int x);
884
885/**
886 * Convert low-ASCII English letters to uppercase.
887 *
888 * **WARNING**: Regardless of system locale, this will only convert ASCII
889 * values 'a' through 'z' to uppercase.
890 *
891 * This function returns the uppercase equivalent of `x`. If a character
892 * cannot be converted, or is already uppercase, this function returns `x`.
893 *
894 * \param x character value to check.
895 * \returns capitalized version of x, or x if no conversion available.
896 *
897 * \threadsafety It is safe to call this function from any thread.
898 *
899 * \since This function is available since SDL 3.0.0.
900 */
901extern SDL_DECLSPEC int SDLCALL SDL_toupper(int x);
902
903/**
904 * Convert low-ASCII English letters to lowercase.
905 *
906 * **WARNING**: Regardless of system locale, this will only convert ASCII
907 * values 'A' through 'Z' to lowercase.
908 *
909 * This function returns the lowercase equivalent of `x`. If a character
910 * cannot be converted, or is already lowercase, this function returns `x`.
911 *
912 * \param x character value to check.
913 * \returns lowercase version of x, or x if no conversion available.
914 *
915 * \threadsafety It is safe to call this function from any thread.
916 *
917 * \since This function is available since SDL 3.0.0.
918 */
919extern SDL_DECLSPEC int SDLCALL SDL_tolower(int x);
920
921extern SDL_DECLSPEC Uint16 SDLCALL SDL_crc16(Uint16 crc, const void *data, size_t len);
922extern SDL_DECLSPEC Uint32 SDLCALL SDL_crc32(Uint32 crc, const void *data, size_t len);
923
924extern SDL_DECLSPEC void * SDLCALL SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
925
926/* Take advantage of compiler optimizations for memcpy */
927#ifndef SDL_SLOW_MEMCPY
928#ifdef SDL_memcpy
929#undef SDL_memcpy
930#endif
931#define SDL_memcpy memcpy
932#endif
933
934#define SDL_copyp(dst, src) \
935 { SDL_COMPILE_TIME_ASSERT(SDL_copyp, sizeof (*(dst)) == sizeof (*(src))); } \
936 SDL_memcpy((dst), (src), sizeof(*(src)))
937
938extern SDL_DECLSPEC void * SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
939
940/* Take advantage of compiler optimizations for memmove */
941#ifndef SDL_SLOW_MEMMOVE
942#ifdef SDL_memmove
943#undef SDL_memmove
944#endif
945#define SDL_memmove memmove
946#endif
947
948extern SDL_DECLSPEC void * SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len);
949extern SDL_DECLSPEC void * SDLCALL SDL_memset4(void *dst, Uint32 val, size_t dwords);
950
951/* Take advantage of compiler optimizations for memset */
952#ifndef SDL_SLOW_MEMSET
953#ifdef SDL_memset
954#undef SDL_memset
955#endif
956#define SDL_memset memset
957#endif
958
959#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
960#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
961#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x)))
962
963extern SDL_DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
964
965extern SDL_DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr);
966extern SDL_DECLSPEC size_t SDLCALL SDL_wcsnlen(const wchar_t *wstr, size_t maxlen);
967extern SDL_DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen);
968extern SDL_DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen);
969extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsdup(const wchar_t *wstr);
970extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle);
971extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsnstr(const wchar_t *haystack, const wchar_t *needle, size_t maxlen);
972
973/**
974 * Compare two null-terminated wide strings.
975 *
976 * This only compares wchar_t values until it hits a null-terminating
977 * character; it does not care if the string is well-formed UTF-16 (or UTF-32,
978 * depending on your platform's wchar_t size), or uses valid Unicode values.
979 *
980 * \param str1 the first string to compare. NULL is not permitted!
981 * \param str2 the second string to compare. NULL is not permitted!
982 * \returns less than zero if str1 is "less than" str2, greater than zero if
983 * str1 is "greater than" str2, and zero if the strings match
984 * exactly.
985 *
986 * \threadsafety It is safe to call this function from any thread.
987 *
988 * \since This function is available since SDL 3.0.0.
989 */
990extern SDL_DECLSPEC int SDLCALL SDL_wcscmp(const wchar_t *str1, const wchar_t *str2);
991
992/**
993 * Compare two wide strings up to a number of wchar_t values.
994 *
995 * This only compares wchar_t values; it does not care if the string is
996 * well-formed UTF-16 (or UTF-32, depending on your platform's wchar_t size),
997 * or uses valid Unicode values.
998 *
999 * Note that while this function is intended to be used with UTF-16 (or
1000 * UTF-32, depending on your platform's definition of wchar_t), it is
1001 * comparing raw wchar_t values and not Unicode codepoints: `maxlen` specifies
1002 * a wchar_t limit! If the limit lands in the middle of a multi-wchar UTF-16
1003 * sequence, it will only compare a portion of the final character.
1004 *
1005 * `maxlen` specifies a maximum number of wchar_t to compare; if the strings
1006 * match to this number of wide chars (or both have matched to a
1007 * null-terminator character before this count), they will be considered
1008 * equal.
1009 *
1010 * \param str1 the first string to compare. NULL is not permitted!
1011 * \param str2 the second string to compare. NULL is not permitted!
1012 * \param maxlen the maximum number of wchar_t to compare.
1013 * \returns less than zero if str1 is "less than" str2, greater than zero if
1014 * str1 is "greater than" str2, and zero if the strings match
1015 * exactly.
1016 *
1017 * \threadsafety It is safe to call this function from any thread.
1018 *
1019 * \since This function is available since SDL 3.0.0.
1020 */
1021extern SDL_DECLSPEC int SDLCALL SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen);
1022
1023/**
1024 * Compare two null-terminated wide strings, case-insensitively.
1025 *
1026 * This will work with Unicode strings, using a technique called
1027 * "case-folding" to handle the vast majority of case-sensitive human
1028 * languages regardless of system locale. It can deal with expanding values: a
1029 * German Eszett character can compare against two ASCII 's' chars and be
1030 * considered a match, for example. A notable exception: it does not handle
1031 * the Turkish 'i' character; human language is complicated!
1032 *
1033 * Depending on your platform, "wchar_t" might be 2 bytes, and expected to be
1034 * UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this
1035 * handles Unicode, it expects the string to be well-formed and not a
1036 * null-terminated string of arbitrary bytes. Characters that are not valid
1037 * UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT
1038 * CHARACTER), which is to say two strings of random bits may turn out to
1039 * match if they convert to the same amount of replacement characters.
1040 *
1041 * \param str1 the first string to compare. NULL is not permitted!
1042 * \param str2 the second string to compare. NULL is not permitted!
1043 * \returns less than zero if str1 is "less than" str2, greater than zero if
1044 * str1 is "greater than" str2, and zero if the strings match
1045 * exactly.
1046 *
1047 * \threadsafety It is safe to call this function from any thread.
1048 *
1049 * \since This function is available since SDL 3.0.0.
1050 */
1051extern SDL_DECLSPEC int SDLCALL SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2);
1052
1053/**
1054 * Compare two wide strings, case-insensitively, up to a number of wchar_t.
1055 *
1056 * This will work with Unicode strings, using a technique called
1057 * "case-folding" to handle the vast majority of case-sensitive human
1058 * languages regardless of system locale. It can deal with expanding values: a
1059 * German Eszett character can compare against two ASCII 's' chars and be
1060 * considered a match, for example. A notable exception: it does not handle
1061 * the Turkish 'i' character; human language is complicated!
1062 *
1063 * Depending on your platform, "wchar_t" might be 2 bytes, and expected to be
1064 * UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this
1065 * handles Unicode, it expects the string to be well-formed and not a
1066 * null-terminated string of arbitrary bytes. Characters that are not valid
1067 * UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT
1068 * CHARACTER), which is to say two strings of random bits may turn out to
1069 * match if they convert to the same amount of replacement characters.
1070 *
1071 * Note that while this function might deal with variable-sized characters,
1072 * `maxlen` specifies a _wchar_ limit! If the limit lands in the middle of a
1073 * multi-byte UTF-16 sequence, it may convert a portion of the final character
1074 * to one or more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not
1075 * to overflow a buffer.
1076 *
1077 * `maxlen` specifies a maximum number of wchar_t values to compare; if the
1078 * strings match to this number of wchar_t (or both have matched to a
1079 * null-terminator character before this number of bytes), they will be
1080 * considered equal.
1081 *
1082 * \param str1 the first string to compare. NULL is not permitted!
1083 * \param str2 the second string to compare. NULL is not permitted!
1084 * \param maxlen the maximum number of wchar_t values to compare.
1085 * \returns less than zero if str1 is "less than" str2, greater than zero if
1086 * str1 is "greater than" str2, and zero if the strings match
1087 * exactly.
1088 *
1089 * \threadsafety It is safe to call this function from any thread.
1090 *
1091 * \since This function is available since SDL 3.0.0.
1092 */
1093extern SDL_DECLSPEC int SDLCALL SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen);
1094
1095extern SDL_DECLSPEC long SDLCALL SDL_wcstol(const wchar_t *str, wchar_t **endp, int base);
1096
1097extern SDL_DECLSPEC size_t SDLCALL SDL_strlen(const char *str);
1098extern SDL_DECLSPEC size_t SDLCALL SDL_strnlen(const char *str, size_t maxlen);
1099extern SDL_DECLSPEC size_t SDLCALL SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen);
1100extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes);
1101extern SDL_DECLSPEC size_t SDLCALL SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen);
1102extern SDL_DECLSPEC SDL_MALLOC char * SDLCALL SDL_strdup(const char *str);
1103extern SDL_DECLSPEC SDL_MALLOC char * SDLCALL SDL_strndup(const char *str, size_t maxlen);
1104extern SDL_DECLSPEC char * SDLCALL SDL_strrev(char *str);
1105
1106/**
1107 * Convert a string to uppercase.
1108 *
1109 * **WARNING**: Regardless of system locale, this will only convert ASCII
1110 * values 'A' through 'Z' to uppercase.
1111 *
1112 * This function operates on a null-terminated string of bytes--even if it is
1113 * malformed UTF-8!--and converts ASCII characters 'a' through 'z' to their
1114 * uppercase equivalents in-place, returning the original `str` pointer.
1115 *
1116 * \param str the string to convert in-place. Can not be NULL.
1117 * \returns the `str` pointer passed into this function.
1118 *
1119 * \threadsafety It is safe to call this function from any thread.
1120 *
1121 * \since This function is available since SDL 3.0.0.
1122 *
1123 * \sa SDL_strlwr
1124 */
1125extern SDL_DECLSPEC char * SDLCALL SDL_strupr(char *str);
1126
1127/**
1128 * Convert a string to lowercase.
1129 *
1130 * **WARNING**: Regardless of system locale, this will only convert ASCII
1131 * values 'A' through 'Z' to lowercase.
1132 *
1133 * This function operates on a null-terminated string of bytes--even if it is
1134 * malformed UTF-8!--and converts ASCII characters 'A' through 'Z' to their
1135 * lowercase equivalents in-place, returning the original `str` pointer.
1136 *
1137 * \param str the string to convert in-place. Can not be NULL.
1138 * \returns the `str` pointer passed into this function.
1139 *
1140 * \threadsafety It is safe to call this function from any thread.
1141 *
1142 * \since This function is available since SDL 3.0.0.
1143 *
1144 * \sa SDL_strupr
1145 */
1146extern SDL_DECLSPEC char * SDLCALL SDL_strlwr(char *str);
1147
1148extern SDL_DECLSPEC char * SDLCALL SDL_strchr(const char *str, int c);
1149extern SDL_DECLSPEC char * SDLCALL SDL_strrchr(const char *str, int c);
1150extern SDL_DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle);
1151extern SDL_DECLSPEC char * SDLCALL SDL_strnstr(const char *haystack, const char *needle, size_t maxlen);
1152extern SDL_DECLSPEC char * SDLCALL SDL_strcasestr(const char *haystack, const char *needle);
1153extern SDL_DECLSPEC char * SDLCALL SDL_strtok_r(char *s1, const char *s2, char **saveptr);
1154extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str);
1155extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strnlen(const char *str, size_t bytes);
1156
1157extern SDL_DECLSPEC char * SDLCALL SDL_itoa(int value, char *str, int radix);
1158extern SDL_DECLSPEC char * SDLCALL SDL_uitoa(unsigned int value, char *str, int radix);
1159extern SDL_DECLSPEC char * SDLCALL SDL_ltoa(long value, char *str, int radix);
1160extern SDL_DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *str, int radix);
1161extern SDL_DECLSPEC char * SDLCALL SDL_lltoa(Sint64 value, char *str, int radix);
1162extern SDL_DECLSPEC char * SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix);
1163
1164extern SDL_DECLSPEC int SDLCALL SDL_atoi(const char *str);
1165extern SDL_DECLSPEC double SDLCALL SDL_atof(const char *str);
1166extern SDL_DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base);
1167extern SDL_DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base);
1168extern SDL_DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base);
1169extern SDL_DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base);
1170extern SDL_DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp);
1171
1172/**
1173 * Compare two null-terminated UTF-8 strings.
1174 *
1175 * Due to the nature of UTF-8 encoding, this will work with Unicode strings,
1176 * since effectively this function just compares bytes until it hits a
1177 * null-terminating character. Also due to the nature of UTF-8, this can be
1178 * used with SDL_qsort() to put strings in (roughly) alphabetical order.
1179 *
1180 * \param str1 the first string to compare. NULL is not permitted!
1181 * \param str2 the second string to compare. NULL is not permitted!
1182 * \returns less than zero if str1 is "less than" str2, greater than zero if
1183 * str1 is "greater than" str2, and zero if the strings match
1184 * exactly.
1185 *
1186 * \threadsafety It is safe to call this function from any thread.
1187 *
1188 * \since This function is available since SDL 3.0.0.
1189 */
1190extern SDL_DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
1191
1192/**
1193 * Compare two UTF-8 strings up to a number of bytes.
1194 *
1195 * Due to the nature of UTF-8 encoding, this will work with Unicode strings,
1196 * since effectively this function just compares bytes until it hits a
1197 * null-terminating character. Also due to the nature of UTF-8, this can be
1198 * used with SDL_qsort() to put strings in (roughly) alphabetical order.
1199 *
1200 * Note that while this function is intended to be used with UTF-8, it is
1201 * doing a bytewise comparison, and `maxlen` specifies a _byte_ limit! If the
1202 * limit lands in the middle of a multi-byte UTF-8 sequence, it will only
1203 * compare a portion of the final character.
1204 *
1205 * `maxlen` specifies a maximum number of bytes to compare; if the strings
1206 * match to this number of bytes (or both have matched to a null-terminator
1207 * character before this number of bytes), they will be considered equal.
1208 *
1209 * \param str1 the first string to compare. NULL is not permitted!
1210 * \param str2 the second string to compare. NULL is not permitted!
1211 * \param maxlen the maximum number of _bytes_ to compare.
1212 * \returns less than zero if str1 is "less than" str2, greater than zero if
1213 * str1 is "greater than" str2, and zero if the strings match
1214 * exactly.
1215 *
1216 * \threadsafety It is safe to call this function from any thread.
1217 *
1218 * \since This function is available since SDL 3.0.0.
1219 */
1220extern SDL_DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
1221
1222/**
1223 * Compare two null-terminated UTF-8 strings, case-insensitively.
1224 *
1225 * This will work with Unicode strings, using a technique called
1226 * "case-folding" to handle the vast majority of case-sensitive human
1227 * languages regardless of system locale. It can deal with expanding values: a
1228 * German Eszett character can compare against two ASCII 's' chars and be
1229 * considered a match, for example. A notable exception: it does not handle
1230 * the Turkish 'i' character; human language is complicated!
1231 *
1232 * Since this handles Unicode, it expects the string to be well-formed UTF-8
1233 * and not a null-terminated string of arbitrary bytes. Bytes that are not
1234 * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT
1235 * CHARACTER), which is to say two strings of random bits may turn out to
1236 * match if they convert to the same amount of replacement characters.
1237 *
1238 * \param str1 the first string to compare. NULL is not permitted!
1239 * \param str2 the second string to compare. NULL is not permitted!
1240 * \returns less than zero if str1 is "less than" str2, greater than zero if
1241 * str1 is "greater than" str2, and zero if the strings match
1242 * exactly.
1243 *
1244 * \threadsafety It is safe to call this function from any thread.
1245 *
1246 * \since This function is available since SDL 3.0.0.
1247 */
1248extern SDL_DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
1249
1250
1251/**
1252 * Compare two UTF-8 strings, case-insensitively, up to a number of bytes.
1253 *
1254 * This will work with Unicode strings, using a technique called
1255 * "case-folding" to handle the vast majority of case-sensitive human
1256 * languages regardless of system locale. It can deal with expanding values: a
1257 * German Eszett character can compare against two ASCII 's' chars and be
1258 * considered a match, for example. A notable exception: it does not handle
1259 * the Turkish 'i' character; human language is complicated!
1260 *
1261 * Since this handles Unicode, it expects the string to be well-formed UTF-8
1262 * and not a null-terminated string of arbitrary bytes. Bytes that are not
1263 * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT
1264 * CHARACTER), which is to say two strings of random bits may turn out to
1265 * match if they convert to the same amount of replacement characters.
1266 *
1267 * Note that while this function is intended to be used with UTF-8, `maxlen`
1268 * specifies a _byte_ limit! If the limit lands in the middle of a multi-byte
1269 * UTF-8 sequence, it may convert a portion of the final character to one or
1270 * more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not to overflow
1271 * a buffer.
1272 *
1273 * `maxlen` specifies a maximum number of bytes to compare; if the strings
1274 * match to this number of bytes (or both have matched to a null-terminator
1275 * character before this number of bytes), they will be considered equal.
1276 *
1277 * \param str1 the first string to compare. NULL is not permitted!
1278 * \param str2 the second string to compare. NULL is not permitted!
1279 * \param maxlen the maximum number of bytes to compare.
1280 * \returns less than zero if str1 is "less than" str2, greater than zero if
1281 * str1 is "greater than" str2, and zero if the strings match
1282 * exactly.
1283 *
1284 * \threadsafety It is safe to call this function from any thread.
1285 *
1286 * \since This function is available since SDL 3.0.0.
1287 */
1288extern SDL_DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen);
1289
1290/**
1291 * The Unicode REPLACEMENT CHARACTER codepoint.
1292 *
1293 * SDL_StepUTF8() reports this codepoint when it encounters a UTF-8 string
1294 * with encoding errors.
1295 *
1296 * This tends to render as something like a question mark in most places.
1297 *
1298 * \since This macro is available since SDL 3.0.0.
1299 *
1300 * \sa SDL_StepUTF8
1301 */
1302#define SDL_INVALID_UNICODE_CODEPOINT 0xFFFD
1303
1304/**
1305 * Decode a UTF-8 string, one Unicode codepoint at a time.
1306 *
1307 * This will return the first Unicode codepoint in the UTF-8 encoded string in
1308 * `*pstr`, and then advance `*pstr` past any consumed bytes before returning.
1309 *
1310 * It will not access more than `*pslen` bytes from the string. `*pslen` will
1311 * be adjusted, as well, subtracting the number of bytes consumed.
1312 *
1313 * `pslen` is allowed to be NULL, in which case the string _must_ be
1314 * NULL-terminated, as the function will blindly read until it sees the NULL
1315 * char.
1316 *
1317 * if `*pslen` is zero, it assumes the end of string is reached and returns a
1318 * zero codepoint regardless of the contents of the string buffer.
1319 *
1320 * If the resulting codepoint is zero (a NULL terminator), or `*pslen` is
1321 * zero, it will not advance `*pstr` or `*pslen` at all.
1322 *
1323 * Generally this function is called in a loop until it returns zero,
1324 * adjusting its parameters each iteration.
1325 *
1326 * If an invalid UTF-8 sequence is encountered, this function returns
1327 * SDL_INVALID_UNICODE_CODEPOINT and advances the string/length by one byte
1328 * (which is to say, a multibyte sequence might produce several
1329 * SDL_INVALID_UNICODE_CODEPOINT returns before it syncs to the next valid
1330 * UTF-8 sequence).
1331 *
1332 * Several things can generate invalid UTF-8 sequences, including overlong
1333 * encodings, the use of UTF-16 surrogate values, and truncated data. Please
1334 * refer to
1335 * [RFC3629](https://www.ietf.org/rfc/rfc3629.txt)
1336 * for details.
1337 *
1338 * \param pstr a pointer to a UTF-8 string pointer to be read and adjusted.
1339 * \param pslen a pointer to the number of bytes in the string, to be read and
1340 * adjusted. NULL is allowed.
1341 * \returns the first Unicode codepoint in the string.
1342 *
1343 * \threadsafety It is safe to call this function from any thread.
1344 *
1345 * \since This function is available since SDL 3.0.0.
1346 */
1347extern SDL_DECLSPEC Uint32 SDLCALL SDL_StepUTF8(const char **pstr, size_t *pslen);
1348
1349/**
1350 * Convert a single Unicode codepoint to UTF-8.
1351 *
1352 * The buffer pointed to by `dst` must be at least 4 bytes long, as this
1353 * function may generate between 1 and 4 bytes of output.
1354 *
1355 * This function returns the first byte _after_ the newly-written UTF-8
1356 * sequence, which is useful for encoding multiple codepoints in a loop, or
1357 * knowing where to write a NULL-terminator character to end the string (in
1358 * either case, plan to have a buffer of _more_ than 4 bytes!).
1359 *
1360 * If `codepoint` is an invalid value (outside the Unicode range, or a UTF-16
1361 * surrogate value, etc), this will use U+FFFD (REPLACEMENT CHARACTER) for the
1362 * codepoint instead, and not set an error.
1363 *
1364 * If `dst` is NULL, this returns NULL immediately without writing to the
1365 * pointer and without setting an error.
1366 *
1367 * \param codepoint a Unicode codepoint to convert to UTF-8.
1368 * \param dst the location to write the encoded UTF-8. Must point to at least
1369 * 4 bytes!
1370 * \returns the first byte past the newly-written UTF-8 sequence.
1371 *
1372 * \threadsafety It is safe to call this function from any thread.
1373 *
1374 * \since This function is available since SDL 3.0.0.
1375 */
1376extern SDL_DECLSPEC char * SDLCALL SDL_UCS4ToUTF8(Uint32 codepoint, char *dst);
1377
1378
1379extern SDL_DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2);
1380extern SDL_DECLSPEC int SDLCALL SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap) SDL_SCANF_VARARG_FUNCV(2);
1381extern SDL_DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... ) SDL_PRINTF_VARARG_FUNC(3);
1382extern SDL_DECLSPEC int SDLCALL SDL_swprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt, ... ) SDL_WPRINTF_VARARG_FUNC(3);
1383extern SDL_DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3);
1384extern SDL_DECLSPEC int SDLCALL SDL_vswprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, const wchar_t *fmt, va_list ap);
1385extern SDL_DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
1386extern SDL_DECLSPEC int SDLCALL SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2);
1387
1388/**
1389 * Seeds the pseudo-random number generator.
1390 *
1391 * Reusing the seed number will cause SDL_rand_*() to repeat the same stream
1392 * of 'random' numbers.
1393 *
1394 * \param seed the value to use as a random number seed, or 0 to use
1395 * SDL_GetPerformanceCounter().
1396 *
1397 * \threadsafety This should be called on the same thread that calls
1398 * SDL_rand*()
1399 *
1400 * \since This function is available since SDL 3.0.0.
1401 *
1402 * \sa SDL_rand
1403 * \sa SDL_rand_bits
1404 * \sa SDL_randf
1405 */
1406extern SDL_DECLSPEC void SDLCALL SDL_srand(Uint64 seed);
1407
1408/**
1409 * Generate a pseudo-random number less than n for positive n
1410 *
1411 * The method used is faster and of better quality than `rand() % n`. Odds are
1412 * roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and
1413 * much worse as n gets bigger.
1414 *
1415 * Example: to simulate a d6 use `SDL_rand(6) + 1` The +1 converts 0..5 to
1416 * 1..6
1417 *
1418 * If you want to generate a pseudo-random number in the full range of Sint32,
1419 * you should use: (Sint32)SDL_rand_bits()
1420 *
1421 * If you want reproducible output, be sure to initialize with SDL_srand()
1422 * first.
1423 *
1424 * There are no guarantees as to the quality of the random sequence produced,
1425 * and this should not be used for security (cryptography, passwords) or where
1426 * money is on the line (loot-boxes, casinos). There are many random number
1427 * libraries available with different characteristics and you should pick one
1428 * of those to meet any serious needs.
1429 *
1430 * \param n the number of possible outcomes. n must be positive.
1431 * \returns a random value in the range of [0 .. n-1].
1432 *
1433 * \threadsafety All calls should be made from a single thread
1434 *
1435 * \since This function is available since SDL 3.0.0.
1436 *
1437 * \sa SDL_srand
1438 * \sa SDL_randf
1439 */
1440extern SDL_DECLSPEC Sint32 SDLCALL SDL_rand(Sint32 n);
1441
1442/**
1443 * Generate a uniform pseudo-random floating point number less than 1.0
1444 *
1445 * If you want reproducible output, be sure to initialize with SDL_srand()
1446 * first.
1447 *
1448 * There are no guarantees as to the quality of the random sequence produced,
1449 * and this should not be used for security (cryptography, passwords) or where
1450 * money is on the line (loot-boxes, casinos). There are many random number
1451 * libraries available with different characteristics and you should pick one
1452 * of those to meet any serious needs.
1453 *
1454 * \returns a random value in the range of [0.0, 1.0).
1455 *
1456 * \threadsafety All calls should be made from a single thread
1457 *
1458 * \since This function is available since SDL 3.0.0.
1459 *
1460 * \sa SDL_srand
1461 * \sa SDL_rand
1462 */
1463extern SDL_DECLSPEC float SDLCALL SDL_randf(void);
1464
1465/**
1466 * Generate 32 pseudo-random bits.
1467 *
1468 * You likely want to use SDL_rand() to get a psuedo-random number instead.
1469 *
1470 * There are no guarantees as to the quality of the random sequence produced,
1471 * and this should not be used for security (cryptography, passwords) or where
1472 * money is on the line (loot-boxes, casinos). There are many random number
1473 * libraries available with different characteristics and you should pick one
1474 * of those to meet any serious needs.
1475 *
1476 * \returns a random value in the range of [0-SDL_MAX_UINT32].
1477 *
1478 * \threadsafety All calls should be made from a single thread
1479 *
1480 * \since This function is available since SDL 3.0.0.
1481 *
1482 * \sa SDL_rand
1483 * \sa SDL_randf
1484 * \sa SDL_srand
1485 */
1486extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_bits(void);
1487
1488/**
1489 * Generate a pseudo-random number less than n for positive n
1490 *
1491 * The method used is faster and of better quality than `rand() % n`. Odds are
1492 * roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and
1493 * much worse as n gets bigger.
1494 *
1495 * Example: to simulate a d6 use `SDL_rand_r(state, 6) + 1` The +1 converts
1496 * 0..5 to 1..6
1497 *
1498 * If you want to generate a pseudo-random number in the full range of Sint32,
1499 * you should use: (Sint32)SDL_rand_bits_r(state)
1500 *
1501 * There are no guarantees as to the quality of the random sequence produced,
1502 * and this should not be used for security (cryptography, passwords) or where
1503 * money is on the line (loot-boxes, casinos). There are many random number
1504 * libraries available with different characteristics and you should pick one
1505 * of those to meet any serious needs.
1506 *
1507 * \param state a pointer to the current random number state, this may not be
1508 * NULL.
1509 * \param n the number of possible outcomes. n must be positive.
1510 * \returns a random value in the range of [0 .. n-1].
1511 *
1512 * \threadsafety This function is thread-safe, as long as the state pointer
1513 * isn't shared between threads.
1514 *
1515 * \since This function is available since SDL 3.0.0.
1516 *
1517 * \sa SDL_rand
1518 * \sa SDL_rand_bits_r
1519 * \sa SDL_randf_r
1520 */
1521extern SDL_DECLSPEC Sint32 SDLCALL SDL_rand_r(Uint64 *state, Sint32 n);
1522
1523/**
1524 * Generate a uniform pseudo-random floating point number less than 1.0
1525 *
1526 * If you want reproducible output, be sure to initialize with SDL_srand()
1527 * first.
1528 *
1529 * There are no guarantees as to the quality of the random sequence produced,
1530 * and this should not be used for security (cryptography, passwords) or where
1531 * money is on the line (loot-boxes, casinos). There are many random number
1532 * libraries available with different characteristics and you should pick one
1533 * of those to meet any serious needs.
1534 *
1535 * \param state a pointer to the current random number state, this may not be
1536 * NULL.
1537 * \returns a random value in the range of [0.0, 1.0).
1538 *
1539 * \threadsafety This function is thread-safe, as long as the state pointer
1540 * isn't shared between threads.
1541 *
1542 * \since This function is available since SDL 3.0.0.
1543 *
1544 * \sa SDL_rand_bits_r
1545 * \sa SDL_rand_r
1546 * \sa SDL_randf
1547 */
1548extern SDL_DECLSPEC float SDLCALL SDL_randf_r(Uint64 *state);
1549
1550/**
1551 * Generate 32 pseudo-random bits.
1552 *
1553 * You likely want to use SDL_rand_r() to get a psuedo-random number instead.
1554 *
1555 * There are no guarantees as to the quality of the random sequence produced,
1556 * and this should not be used for security (cryptography, passwords) or where
1557 * money is on the line (loot-boxes, casinos). There are many random number
1558 * libraries available with different characteristics and you should pick one
1559 * of those to meet any serious needs.
1560 *
1561 * \param state a pointer to the current random number state, this may not be
1562 * NULL.
1563 * \returns a random value in the range of [0-SDL_MAX_UINT32].
1564 *
1565 * \threadsafety This function is thread-safe, as long as the state pointer
1566 * isn't shared between threads.
1567 *
1568 * \since This function is available since SDL 3.0.0.
1569 *
1570 * \sa SDL_rand_r
1571 * \sa SDL_randf_r
1572 */
1573extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_bits_r(Uint64 *state);
1574
1575
1576#ifndef SDL_PI_D
1577#define SDL_PI_D 3.141592653589793238462643383279502884 /**< pi (double) */
1578#endif
1579#ifndef SDL_PI_F
1580#define SDL_PI_F 3.141592653589793238462643383279502884F /**< pi (float) */
1581#endif
1582
1583/**
1584 * Compute the arc cosine of `x`.
1585 *
1586 * The definition of `y = acos(x)` is `x = cos(y)`.
1587 *
1588 * Domain: `-1 <= x <= 1`
1589 *
1590 * Range: `0 <= y <= Pi`
1591 *
1592 * This function operates on double-precision floating point values, use
1593 * SDL_acosf for single-precision floats.
1594 *
1595 * This function may use a different approximation across different versions,
1596 * platforms and configurations. i.e, it can return a different value given
1597 * the same input on different machines or operating systems, or if SDL is
1598 * updated.
1599 *
1600 * \param x floating point value.
1601 * \returns arc cosine of `x`, in radians.
1602 *
1603 * \threadsafety It is safe to call this function from any thread.
1604 *
1605 * \since This function is available since SDL 3.0.0.
1606 *
1607 * \sa SDL_acosf
1608 * \sa SDL_asin
1609 * \sa SDL_cos
1610 */
1611extern SDL_DECLSPEC double SDLCALL SDL_acos(double x);
1612
1613/**
1614 * Compute the arc cosine of `x`.
1615 *
1616 * The definition of `y = acos(x)` is `x = cos(y)`.
1617 *
1618 * Domain: `-1 <= x <= 1`
1619 *
1620 * Range: `0 <= y <= Pi`
1621 *
1622 * This function operates on single-precision floating point values, use
1623 * SDL_acos for double-precision floats.
1624 *
1625 * This function may use a different approximation across different versions,
1626 * platforms and configurations. i.e, it can return a different value given
1627 * the same input on different machines or operating systems, or if SDL is
1628 * updated.
1629 *
1630 * \param x floating point value.
1631 * \returns arc cosine of `x`, in radians.
1632 *
1633 * \threadsafety It is safe to call this function from any thread.
1634 *
1635 * \since This function is available since SDL 3.0.0.
1636 *
1637 * \sa SDL_acos
1638 * \sa SDL_asinf
1639 * \sa SDL_cosf
1640 */
1641extern SDL_DECLSPEC float SDLCALL SDL_acosf(float x);
1642
1643/**
1644 * Compute the arc sine of `x`.
1645 *
1646 * The definition of `y = asin(x)` is `x = sin(y)`.
1647 *
1648 * Domain: `-1 <= x <= 1`
1649 *
1650 * Range: `-Pi/2 <= y <= Pi/2`
1651 *
1652 * This function operates on double-precision floating point values, use
1653 * SDL_asinf for single-precision floats.
1654 *
1655 * This function may use a different approximation across different versions,
1656 * platforms and configurations. i.e, it can return a different value given
1657 * the same input on different machines or operating systems, or if SDL is
1658 * updated.
1659 *
1660 * \param x floating point value.
1661 * \returns arc sine of `x`, in radians.
1662 *
1663 * \threadsafety It is safe to call this function from any thread.
1664 *
1665 * \since This function is available since SDL 3.0.0.
1666 *
1667 * \sa SDL_asinf
1668 * \sa SDL_acos
1669 * \sa SDL_sin
1670 */
1671extern SDL_DECLSPEC double SDLCALL SDL_asin(double x);
1672
1673/**
1674 * Compute the arc sine of `x`.
1675 *
1676 * The definition of `y = asin(x)` is `x = sin(y)`.
1677 *
1678 * Domain: `-1 <= x <= 1`
1679 *
1680 * Range: `-Pi/2 <= y <= Pi/2`
1681 *
1682 * This function operates on single-precision floating point values, use
1683 * SDL_asin for double-precision floats.
1684 *
1685 * This function may use a different approximation across different versions,
1686 * platforms and configurations. i.e, it can return a different value given
1687 * the same input on different machines or operating systems, or if SDL is
1688 * updated.
1689 *
1690 * \param x floating point value.
1691 * \returns arc sine of `x`, in radians.
1692 *
1693 * \threadsafety It is safe to call this function from any thread.
1694 *
1695 * \since This function is available since SDL 3.0.0.
1696 *
1697 * \sa SDL_asin
1698 * \sa SDL_acosf
1699 * \sa SDL_sinf
1700 */
1701extern SDL_DECLSPEC float SDLCALL SDL_asinf(float x);
1702
1703/**
1704 * Compute the arc tangent of `x`.
1705 *
1706 * The definition of `y = atan(x)` is `x = tan(y)`.
1707 *
1708 * Domain: `-INF <= x <= INF`
1709 *
1710 * Range: `-Pi/2 <= y <= Pi/2`
1711 *
1712 * This function operates on double-precision floating point values, use
1713 * SDL_atanf for single-precision floats.
1714 *
1715 * To calculate the arc tangent of y / x, use SDL_atan2.
1716 *
1717 * This function may use a different approximation across different versions,
1718 * platforms and configurations. i.e, it can return a different value given
1719 * the same input on different machines or operating systems, or if SDL is
1720 * updated.
1721 *
1722 * \param x floating point value.
1723 * \returns arc tangent of of `x` in radians, or 0 if `x = 0`.
1724 *
1725 * \threadsafety It is safe to call this function from any thread.
1726 *
1727 * \since This function is available since SDL 3.0.0.
1728 *
1729 * \sa SDL_atanf
1730 * \sa SDL_atan2
1731 * \sa SDL_tan
1732 */
1733extern SDL_DECLSPEC double SDLCALL SDL_atan(double x);
1734
1735/**
1736 * Compute the arc tangent of `x`.
1737 *
1738 * The definition of `y = atan(x)` is `x = tan(y)`.
1739 *
1740 * Domain: `-INF <= x <= INF`
1741 *
1742 * Range: `-Pi/2 <= y <= Pi/2`
1743 *
1744 * This function operates on single-precision floating point values, use
1745 * SDL_atan for dboule-precision floats.
1746 *
1747 * To calculate the arc tangent of y / x, use SDL_atan2f.
1748 *
1749 * This function may use a different approximation across different versions,
1750 * platforms and configurations. i.e, it can return a different value given
1751 * the same input on different machines or operating systems, or if SDL is
1752 * updated.
1753 *
1754 * \param x floating point value.
1755 * \returns arc tangent of of `x` in radians, or 0 if `x = 0`.
1756 *
1757 * \threadsafety It is safe to call this function from any thread.
1758 *
1759 * \since This function is available since SDL 3.0.0.
1760 *
1761 * \sa SDL_atan
1762 * \sa SDL_atan2f
1763 * \sa SDL_tanf
1764 */
1765extern SDL_DECLSPEC float SDLCALL SDL_atanf(float x);
1766
1767/**
1768 * Compute the arc tangent of `y / x`, using the signs of x and y to adjust
1769 * the result's quadrant.
1770 *
1771 * The definition of `z = atan2(x, y)` is `y = x tan(z)`, where the quadrant
1772 * of z is determined based on the signs of x and y.
1773 *
1774 * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
1775 *
1776 * Range: `-Pi/2 <= y <= Pi/2`
1777 *
1778 * This function operates on double-precision floating point values, use
1779 * SDL_atan2f for single-precision floats.
1780 *
1781 * To calculate the arc tangent of a single value, use SDL_atan.
1782 *
1783 * This function may use a different approximation across different versions,
1784 * platforms and configurations. i.e, it can return a different value given
1785 * the same input on different machines or operating systems, or if SDL is
1786 * updated.
1787 *
1788 * \param y floating point value of the numerator (y coordinate).
1789 * \param x floating point value of the denominator (x coordinate).
1790 * \returns arc tangent of of `y / x` in radians, or, if `x = 0`, either
1791 * `-Pi/2`, `0`, or `Pi/2`, depending on the value of `y`.
1792 *
1793 * \threadsafety It is safe to call this function from any thread.
1794 *
1795 * \since This function is available since SDL 3.0.0.
1796 *
1797 * \sa SDL_atan2f
1798 * \sa SDL_atan
1799 * \sa SDL_tan
1800 */
1801extern SDL_DECLSPEC double SDLCALL SDL_atan2(double y, double x);
1802
1803/**
1804 * Compute the arc tangent of `y / x`, using the signs of x and y to adjust
1805 * the result's quadrant.
1806 *
1807 * The definition of `z = atan2(x, y)` is `y = x tan(z)`, where the quadrant
1808 * of z is determined based on the signs of x and y.
1809 *
1810 * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
1811 *
1812 * Range: `-Pi/2 <= y <= Pi/2`
1813 *
1814 * This function operates on single-precision floating point values, use
1815 * SDL_atan2 for double-precision floats.
1816 *
1817 * To calculate the arc tangent of a single value, use SDL_atanf.
1818 *
1819 * This function may use a different approximation across different versions,
1820 * platforms and configurations. i.e, it can return a different value given
1821 * the same input on different machines or operating systems, or if SDL is
1822 * updated.
1823 *
1824 * \param y floating point value of the numerator (y coordinate).
1825 * \param x floating point value of the denominator (x coordinate).
1826 * \returns arc tangent of of `y / x` in radians, or, if `x = 0`, either
1827 * `-Pi/2`, `0`, or `Pi/2`, depending on the value of `y`.
1828 *
1829 * \threadsafety It is safe to call this function from any thread.
1830 *
1831 * \since This function is available since SDL 3.0.0.
1832 *
1833 * \sa SDL_atan2f
1834 * \sa SDL_atan
1835 * \sa SDL_tan
1836 */
1837extern SDL_DECLSPEC float SDLCALL SDL_atan2f(float y, float x);
1838
1839/**
1840 * Compute the ceiling of `x`.
1841 *
1842 * The ceiling of `x` is the smallest integer `y` such that `y > x`, i.e `x`
1843 * rounded up to the nearest integer.
1844 *
1845 * Domain: `-INF <= x <= INF`
1846 *
1847 * Range: `-INF <= y <= INF`, y integer
1848 *
1849 * This function operates on double-precision floating point values, use
1850 * SDL_ceilf for single-precision floats.
1851 *
1852 * \param x floating point value.
1853 * \returns the ceiling of `x`.
1854 *
1855 * \threadsafety It is safe to call this function from any thread.
1856 *
1857 * \since This function is available since SDL 3.0.0.
1858 *
1859 * \sa SDL_ceilf
1860 * \sa SDL_floor
1861 * \sa SDL_trunc
1862 * \sa SDL_round
1863 * \sa SDL_lround
1864 */
1865extern SDL_DECLSPEC double SDLCALL SDL_ceil(double x);
1866
1867/**
1868 * Compute the ceiling of `x`.
1869 *
1870 * The ceiling of `x` is the smallest integer `y` such that `y > x`, i.e `x`
1871 * rounded up to the nearest integer.
1872 *
1873 * Domain: `-INF <= x <= INF`
1874 *
1875 * Range: `-INF <= y <= INF`, y integer
1876 *
1877 * This function operates on single-precision floating point values, use
1878 * SDL_ceil for double-precision floats.
1879 *
1880 * \param x floating point value.
1881 * \returns the ceiling of `x`.
1882 *
1883 * \threadsafety It is safe to call this function from any thread.
1884 *
1885 * \since This function is available since SDL 3.0.0.
1886 *
1887 * \sa SDL_ceil
1888 * \sa SDL_floorf
1889 * \sa SDL_truncf
1890 * \sa SDL_roundf
1891 * \sa SDL_lroundf
1892 */
1893extern SDL_DECLSPEC float SDLCALL SDL_ceilf(float x);
1894
1895/**
1896 * Copy the sign of one floating-point value to another.
1897 *
1898 * The definition of copysign is that ``copysign(x, y) = abs(x) * sign(y)``.
1899 *
1900 * Domain: `-INF <= x <= INF`, ``-INF <= y <= f``
1901 *
1902 * Range: `-INF <= z <= INF`
1903 *
1904 * This function operates on double-precision floating point values, use
1905 * SDL_copysignf for single-precision floats.
1906 *
1907 * \param x floating point value to use as the magnitude.
1908 * \param y floating point value to use as the sign.
1909 * \returns the floating point value with the sign of y and the magnitude of
1910 * x.
1911 *
1912 * \threadsafety It is safe to call this function from any thread.
1913 *
1914 * \since This function is available since SDL 3.0.0.
1915 *
1916 * \sa SDL_copysignf
1917 * \sa SDL_fabs
1918 */
1919extern SDL_DECLSPEC double SDLCALL SDL_copysign(double x, double y);
1920
1921/**
1922 * Copy the sign of one floating-point value to another.
1923 *
1924 * The definition of copysign is that ``copysign(x, y) = abs(x) * sign(y)``.
1925 *
1926 * Domain: `-INF <= x <= INF`, ``-INF <= y <= f``
1927 *
1928 * Range: `-INF <= z <= INF`
1929 *
1930 * This function operates on single-precision floating point values, use
1931 * SDL_copysign for double-precision floats.
1932 *
1933 * \param x floating point value to use as the magnitude.
1934 * \param y floating point value to use as the sign.
1935 * \returns the floating point value with the sign of y and the magnitude of
1936 * x.
1937 *
1938 * \threadsafety It is safe to call this function from any thread.
1939 *
1940 * \since This function is available since SDL 3.0.0.
1941 *
1942 * \sa SDL_copysignf
1943 * \sa SDL_fabsf
1944 */
1945extern SDL_DECLSPEC float SDLCALL SDL_copysignf(float x, float y);
1946
1947/**
1948 * Compute the cosine of `x`.
1949 *
1950 * Domain: `-INF <= x <= INF`
1951 *
1952 * Range: `-1 <= y <= 1`
1953 *
1954 * This function operates on double-precision floating point values, use
1955 * SDL_cosf for single-precision floats.
1956 *
1957 * This function may use a different approximation across different versions,
1958 * platforms and configurations. i.e, it can return a different value given
1959 * the same input on different machines or operating systems, or if SDL is
1960 * updated.
1961 *
1962 * \param x floating point value, in radians.
1963 * \returns cosine of `x`.
1964 *
1965 * \threadsafety It is safe to call this function from any thread.
1966 *
1967 * \since This function is available since SDL 3.0.0.
1968 *
1969 * \sa SDL_cosf
1970 * \sa SDL_acos
1971 * \sa SDL_sin
1972 */
1973extern SDL_DECLSPEC double SDLCALL SDL_cos(double x);
1974
1975/**
1976 * Compute the cosine of `x`.
1977 *
1978 * Domain: `-INF <= x <= INF`
1979 *
1980 * Range: `-1 <= y <= 1`
1981 *
1982 * This function operates on single-precision floating point values, use
1983 * SDL_cos for double-precision floats.
1984 *
1985 * This function may use a different approximation across different versions,
1986 * platforms and configurations. i.e, it can return a different value given
1987 * the same input on different machines or operating systems, or if SDL is
1988 * updated.
1989 *
1990 * \param x floating point value, in radians.
1991 * \returns cosine of `x`.
1992 *
1993 * \threadsafety It is safe to call this function from any thread.
1994 *
1995 * \since This function is available since SDL 3.0.0.
1996 *
1997 * \sa SDL_cos
1998 * \sa SDL_acosf
1999 * \sa SDL_sinf
2000 */
2001extern SDL_DECLSPEC float SDLCALL SDL_cosf(float x);
2002
2003/**
2004 * Compute the exponential of `x`.
2005 *
2006 * The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the
2007 * natural logarithm. The inverse is the natural logarithm, SDL_log.
2008 *
2009 * Domain: `-INF <= x <= INF`
2010 *
2011 * Range: `0 <= y <= INF`
2012 *
2013 * The output will overflow if `exp(x)` is too large to be represented.
2014 *
2015 * This function operates on double-precision floating point values, use
2016 * SDL_expf for single-precision floats.
2017 *
2018 * This function may use a different approximation across different versions,
2019 * platforms and configurations. i.e, it can return a different value given
2020 * the same input on different machines or operating systems, or if SDL is
2021 * updated.
2022 *
2023 * \param x floating point value.
2024 * \returns value of `e^x`.
2025 *
2026 * \threadsafety It is safe to call this function from any thread.
2027 *
2028 * \since This function is available since SDL 3.0.0.
2029 *
2030 * \sa SDL_expf
2031 * \sa SDL_log
2032 */
2033extern SDL_DECLSPEC double SDLCALL SDL_exp(double x);
2034
2035/**
2036 * Compute the exponential of `x`.
2037 *
2038 * The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the
2039 * natural logarithm. The inverse is the natural logarithm, SDL_logf.
2040 *
2041 * Domain: `-INF <= x <= INF`
2042 *
2043 * Range: `0 <= y <= INF`
2044 *
2045 * The output will overflow if `exp(x)` is too large to be represented.
2046 *
2047 * This function operates on single-precision floating point values, use
2048 * SDL_exp for double-precision floats.
2049 *
2050 * This function may use a different approximation across different versions,
2051 * platforms and configurations. i.e, it can return a different value given
2052 * the same input on different machines or operating systems, or if SDL is
2053 * updated.
2054 *
2055 * \param x floating point value.
2056 * \returns value of `e^x`.
2057 *
2058 * \threadsafety It is safe to call this function from any thread.
2059 *
2060 * \since This function is available since SDL 3.0.0.
2061 *
2062 * \sa SDL_exp
2063 * \sa SDL_logf
2064 */
2065extern SDL_DECLSPEC float SDLCALL SDL_expf(float x);
2066
2067/**
2068 * Compute the absolute value of `x`
2069 *
2070 * Domain: `-INF <= x <= INF`
2071 *
2072 * Range: `0 <= y <= INF`
2073 *
2074 * This function operates on double-precision floating point values, use
2075 * SDL_copysignf for single-precision floats.
2076 *
2077 * \param x floating point value to use as the magnitude.
2078 * \returns the absolute value of `x`.
2079 *
2080 * \threadsafety It is safe to call this function from any thread.
2081 *
2082 * \since This function is available since SDL 3.0.0.
2083 *
2084 * \sa SDL_fabsf
2085 */
2086extern SDL_DECLSPEC double SDLCALL SDL_fabs(double x);
2087
2088/**
2089 * Compute the absolute value of `x`
2090 *
2091 * Domain: `-INF <= x <= INF`
2092 *
2093 * Range: `0 <= y <= INF`
2094 *
2095 * This function operates on single-precision floating point values, use
2096 * SDL_copysignf for double-precision floats.
2097 *
2098 * \param x floating point value to use as the magnitude.
2099 * \returns the absolute value of `x`.
2100 *
2101 * \threadsafety It is safe to call this function from any thread.
2102 *
2103 * \since This function is available since SDL 3.0.0.
2104 *
2105 * \sa SDL_fabs
2106 */
2107extern SDL_DECLSPEC float SDLCALL SDL_fabsf(float x);
2108
2109/**
2110 * Compute the floor of `x`.
2111 *
2112 * The floor of `x` is the largest integer `y` such that `y > x`, i.e `x`
2113 * rounded down to the nearest integer.
2114 *
2115 * Domain: `-INF <= x <= INF`
2116 *
2117 * Range: `-INF <= y <= INF`, y integer
2118 *
2119 * This function operates on double-precision floating point values, use
2120 * SDL_floorf for single-precision floats.
2121 *
2122 * \param x floating point value.
2123 * \returns the floor of `x`.
2124 *
2125 * \threadsafety It is safe to call this function from any thread.
2126 *
2127 * \since This function is available since SDL 3.0.0.
2128 *
2129 * \sa SDL_floorf
2130 * \sa SDL_ceil
2131 * \sa SDL_trunc
2132 * \sa SDL_round
2133 * \sa SDL_lround
2134 */
2135extern SDL_DECLSPEC double SDLCALL SDL_floor(double x);
2136
2137/**
2138 * Compute the floor of `x`.
2139 *
2140 * The floor of `x` is the largest integer `y` such that `y > x`, i.e `x`
2141 * rounded down to the nearest integer.
2142 *
2143 * Domain: `-INF <= x <= INF`
2144 *
2145 * Range: `-INF <= y <= INF`, y integer
2146 *
2147 * This function operates on single-precision floating point values, use
2148 * SDL_floorf for double-precision floats.
2149 *
2150 * \param x floating point value.
2151 * \returns the floor of `x`.
2152 *
2153 * \threadsafety It is safe to call this function from any thread.
2154 *
2155 * \since This function is available since SDL 3.0.0.
2156 *
2157 * \sa SDL_floor
2158 * \sa SDL_ceilf
2159 * \sa SDL_truncf
2160 * \sa SDL_roundf
2161 * \sa SDL_lroundf
2162 */
2163extern SDL_DECLSPEC float SDLCALL SDL_floorf(float x);
2164
2165/**
2166 * Truncate `x` to an integer.
2167 *
2168 * Rounds `x` to the next closest integer to 0. This is equivalent to removing
2169 * the fractional part of `x`, leaving only the integer part.
2170 *
2171 * Domain: `-INF <= x <= INF`
2172 *
2173 * Range: `-INF <= y <= INF`, y integer
2174 *
2175 * This function operates on double-precision floating point values, use
2176 * SDL_truncf for single-precision floats.
2177 *
2178 * \param x floating point value.
2179 * \returns `x` truncated to an integer.
2180 *
2181 * \threadsafety It is safe to call this function from any thread.
2182 *
2183 * \since This function is available since SDL 3.0.0.
2184 *
2185 * \sa SDL_truncf
2186 * \sa SDL_fmod
2187 * \sa SDL_ceil
2188 * \sa SDL_floor
2189 * \sa SDL_round
2190 * \sa SDL_lround
2191 */
2192extern SDL_DECLSPEC double SDLCALL SDL_trunc(double x);
2193
2194/**
2195 * Truncate `x` to an integer.
2196 *
2197 * Rounds `x` to the next closest integer to 0. This is equivalent to removing
2198 * the fractional part of `x`, leaving only the integer part.
2199 *
2200 * Domain: `-INF <= x <= INF`
2201 *
2202 * Range: `-INF <= y <= INF`, y integer
2203 *
2204 * This function operates on single-precision floating point values, use
2205 * SDL_truncf for double-precision floats.
2206 *
2207 * \param x floating point value.
2208 * \returns `x` truncated to an integer.
2209 *
2210 * \threadsafety It is safe to call this function from any thread.
2211 *
2212 * \since This function is available since SDL 3.0.0.
2213 *
2214 * \sa SDL_trunc
2215 * \sa SDL_fmodf
2216 * \sa SDL_ceilf
2217 * \sa SDL_floorf
2218 * \sa SDL_roundf
2219 * \sa SDL_lroundf
2220 */
2221extern SDL_DECLSPEC float SDLCALL SDL_truncf(float x);
2222
2223/**
2224 * Return the floating-point remainder of `x / y`
2225 *
2226 * Divides `x` by `y`, and returns the remainder.
2227 *
2228 * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`, `y != 0`
2229 *
2230 * Range: `-y <= z <= y`
2231 *
2232 * This function operates on double-precision floating point values, use
2233 * SDL_fmodf for single-precision floats.
2234 *
2235 * \param x the numerator.
2236 * \param y the denominator. Must not be 0.
2237 * \returns the remainder of `x / y`.
2238 *
2239 * \threadsafety It is safe to call this function from any thread.
2240 *
2241 * \since This function is available since SDL 3.0.0.
2242 *
2243 * \sa SDL_fmodf
2244 * \sa SDL_modf
2245 * \sa SDL_trunc
2246 * \sa SDL_ceil
2247 * \sa SDL_floor
2248 * \sa SDL_round
2249 * \sa SDL_lround
2250 */
2251extern SDL_DECLSPEC double SDLCALL SDL_fmod(double x, double y);
2252
2253/**
2254 * Return the floating-point remainder of `x / y`
2255 *
2256 * Divides `x` by `y`, and returns the remainder.
2257 *
2258 * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`, `y != 0`
2259 *
2260 * Range: `-y <= z <= y`
2261 *
2262 * This function operates on single-precision floating point values, use
2263 * SDL_fmod for single-precision floats.
2264 *
2265 * \param x the numerator.
2266 * \param y the denominator. Must not be 0.
2267 * \returns the remainder of `x / y`.
2268 *
2269 * \threadsafety It is safe to call this function from any thread.
2270 *
2271 * \since This function is available since SDL 3.0.0.
2272 *
2273 * \sa SDL_fmod
2274 * \sa SDL_truncf
2275 * \sa SDL_modff
2276 * \sa SDL_ceilf
2277 * \sa SDL_floorf
2278 * \sa SDL_roundf
2279 * \sa SDL_lroundf
2280 */
2281extern SDL_DECLSPEC float SDLCALL SDL_fmodf(float x, float y);
2282
2283/**
2284 * Return whether the value is infinity.
2285 *
2286 * \param x double-precision floating point value.
2287 * \returns non-zero if the value is infinity, 0 otherwise.
2288 *
2289 * \threadsafety It is safe to call this function from any thread.
2290 *
2291 * \since This function is available since SDL 3.0.0.
2292 *
2293 * \sa SDL_isinff
2294 */
2295extern SDL_DECLSPEC int SDLCALL SDL_isinf(double x);
2296
2297/**
2298 * Return whether the value is infinity.
2299 *
2300 * \param x floating point value.
2301 * \returns non-zero if the value is infinity, 0 otherwise.
2302 *
2303 * \threadsafety It is safe to call this function from any thread.
2304 *
2305 * \since This function is available since SDL 3.0.0.
2306 *
2307 * \sa SDL_isinf
2308 */
2309extern SDL_DECLSPEC int SDLCALL SDL_isinff(float x);
2310
2311/**
2312 * Return whether the value is NaN.
2313 *
2314 * \param x double-precision floating point value.
2315 * \returns non-zero if the value is NaN, 0 otherwise.
2316 *
2317 * \threadsafety It is safe to call this function from any thread.
2318 *
2319 * \since This function is available since SDL 3.0.0.
2320 *
2321 * \sa SDL_isnanf
2322 */
2323extern SDL_DECLSPEC int SDLCALL SDL_isnan(double x);
2324
2325/**
2326 * Return whether the value is NaN.
2327 *
2328 * \param x floating point value.
2329 * \returns non-zero if the value is NaN, 0 otherwise.
2330 *
2331 * \threadsafety It is safe to call this function from any thread.
2332 *
2333 * \since This function is available since SDL 3.0.0.
2334 *
2335 * \sa SDL_isnan
2336 */
2337extern SDL_DECLSPEC int SDLCALL SDL_isnanf(float x);
2338
2339/**
2340 * Compute the natural logarithm of `x`.
2341 *
2342 * Domain: `0 < x <= INF`
2343 *
2344 * Range: `-INF <= y <= INF`
2345 *
2346 * It is an error for `x` to be less than or equal to 0.
2347 *
2348 * This function operates on double-precision floating point values, use
2349 * SDL_logf for single-precision floats.
2350 *
2351 * This function may use a different approximation across different versions,
2352 * platforms and configurations. i.e, it can return a different value given
2353 * the same input on different machines or operating systems, or if SDL is
2354 * updated.
2355 *
2356 * \param x floating point value. Must be greater than 0.
2357 * \returns the natural logarithm of `x`.
2358 *
2359 * \threadsafety It is safe to call this function from any thread.
2360 *
2361 * \since This function is available since SDL 3.0.0.
2362 *
2363 * \sa SDL_logf
2364 * \sa SDL_log10
2365 * \sa SDL_exp
2366 */
2367extern SDL_DECLSPEC double SDLCALL SDL_log(double x);
2368
2369/**
2370 * Compute the natural logarithm of `x`.
2371 *
2372 * Domain: `0 < x <= INF`
2373 *
2374 * Range: `-INF <= y <= INF`
2375 *
2376 * It is an error for `x` to be less than or equal to 0.
2377 *
2378 * This function operates on single-precision floating point values, use
2379 * SDL_log for double-precision floats.
2380 *
2381 * This function may use a different approximation across different versions,
2382 * platforms and configurations. i.e, it can return a different value given
2383 * the same input on different machines or operating systems, or if SDL is
2384 * updated.
2385 *
2386 * \param x floating point value. Must be greater than 0.
2387 * \returns the natural logarithm of `x`.
2388 *
2389 * \threadsafety It is safe to call this function from any thread.
2390 *
2391 * \since This function is available since SDL 3.0.0.
2392 *
2393 * \sa SDL_log
2394 * \sa SDL_expf
2395 */
2396extern SDL_DECLSPEC float SDLCALL SDL_logf(float x);
2397
2398/**
2399 * Compute the base-10 logarithm of `x`.
2400 *
2401 * Domain: `0 < x <= INF`
2402 *
2403 * Range: `-INF <= y <= INF`
2404 *
2405 * It is an error for `x` to be less than or equal to 0.
2406 *
2407 * This function operates on double-precision floating point values, use
2408 * SDL_log10f for single-precision floats.
2409 *
2410 * This function may use a different approximation across different versions,
2411 * platforms and configurations. i.e, it can return a different value given
2412 * the same input on different machines or operating systems, or if SDL is
2413 * updated.
2414 *
2415 * \param x floating point value. Must be greater than 0.
2416 * \returns the logarithm of `x`.
2417 *
2418 * \threadsafety It is safe to call this function from any thread.
2419 *
2420 * \since This function is available since SDL 3.0.0.
2421 *
2422 * \sa SDL_log10f
2423 * \sa SDL_log
2424 * \sa SDL_pow
2425 */
2426extern SDL_DECLSPEC double SDLCALL SDL_log10(double x);
2427
2428/**
2429 * Compute the base-10 logarithm of `x`.
2430 *
2431 * Domain: `0 < x <= INF`
2432 *
2433 * Range: `-INF <= y <= INF`
2434 *
2435 * It is an error for `x` to be less than or equal to 0.
2436 *
2437 * This function operates on single-precision floating point values, use
2438 * SDL_log10 for double-precision floats.
2439 *
2440 * This function may use a different approximation across different versions,
2441 * platforms and configurations. i.e, it can return a different value given
2442 * the same input on different machines or operating systems, or if SDL is
2443 * updated.
2444 *
2445 * \param x floating point value. Must be greater than 0.
2446 * \returns the logarithm of `x`.
2447 *
2448 * \threadsafety It is safe to call this function from any thread.
2449 *
2450 * \since This function is available since SDL 3.0.0.
2451 *
2452 * \sa SDL_log10
2453 * \sa SDL_logf
2454 * \sa SDL_powf
2455 */
2456extern SDL_DECLSPEC float SDLCALL SDL_log10f(float x);
2457
2458/**
2459 * Split `x` into integer and fractional parts
2460 *
2461 * This function operates on double-precision floating point values, use
2462 * SDL_modff for single-precision floats.
2463 *
2464 * \param x floating point value.
2465 * \param y output pointer to store the integer part of `x`.
2466 * \returns the fractional part of `x`.
2467 *
2468 * \threadsafety It is safe to call this function from any thread.
2469 *
2470 * \since This function is available since SDL 3.0.0.
2471 *
2472 * \sa SDL_modff
2473 * \sa SDL_trunc
2474 * \sa SDL_fmod
2475 */
2476extern SDL_DECLSPEC double SDLCALL SDL_modf(double x, double *y);
2477
2478/**
2479 * Split `x` into integer and fractional parts
2480 *
2481 * This function operates on single-precision floating point values, use
2482 * SDL_modf for double-precision floats.
2483 *
2484 * \param x floating point value.
2485 * \param y output pointer to store the integer part of `x`.
2486 * \returns the fractional part of `x`.
2487 *
2488 * \threadsafety It is safe to call this function from any thread.
2489 *
2490 * \since This function is available since SDL 3.0.0.
2491 *
2492 * \sa SDL_modf
2493 * \sa SDL_truncf
2494 * \sa SDL_fmodf
2495 */
2496extern SDL_DECLSPEC float SDLCALL SDL_modff(float x, float *y);
2497
2498/**
2499 * Raise `x` to the power `y`
2500 *
2501 * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
2502 *
2503 * Range: `-INF <= z <= INF`
2504 *
2505 * If `y` is the base of the natural logarithm (e), consider using SDL_exp
2506 * instead.
2507 *
2508 * This function operates on double-precision floating point values, use
2509 * SDL_powf for single-precision floats.
2510 *
2511 * This function may use a different approximation across different versions,
2512 * platforms and configurations. i.e, it can return a different value given
2513 * the same input on different machines or operating systems, or if SDL is
2514 * updated.
2515 *
2516 * \param x the base.
2517 * \param y the exponent.
2518 * \returns `x` raised to the power `y`.
2519 *
2520 * \threadsafety It is safe to call this function from any thread.
2521 *
2522 * \since This function is available since SDL 3.0.0.
2523 *
2524 * \sa SDL_powf
2525 * \sa SDL_exp
2526 * \sa SDL_log
2527 */
2528extern SDL_DECLSPEC double SDLCALL SDL_pow(double x, double y);
2529
2530/**
2531 * Raise `x` to the power `y`
2532 *
2533 * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
2534 *
2535 * Range: `-INF <= z <= INF`
2536 *
2537 * If `y` is the base of the natural logarithm (e), consider using SDL_exp
2538 * instead.
2539 *
2540 * This function operates on single-precision floating point values, use
2541 * SDL_powf for double-precision floats.
2542 *
2543 * This function may use a different approximation across different versions,
2544 * platforms and configurations. i.e, it can return a different value given
2545 * the same input on different machines or operating systems, or if SDL is
2546 * updated.
2547 *
2548 * \param x the base.
2549 * \param y the exponent.
2550 * \returns `x` raised to the power `y`.
2551 *
2552 * \threadsafety It is safe to call this function from any thread.
2553 *
2554 * \since This function is available since SDL 3.0.0.
2555 *
2556 * \sa SDL_pow
2557 * \sa SDL_expf
2558 * \sa SDL_logf
2559 */
2560extern SDL_DECLSPEC float SDLCALL SDL_powf(float x, float y);
2561
2562/**
2563 * Round `x` to the nearest integer.
2564 *
2565 * Rounds `x` to the nearest integer. Values halfway between integers will be
2566 * rounded away from zero.
2567 *
2568 * Domain: `-INF <= x <= INF`
2569 *
2570 * Range: `-INF <= y <= INF`, y integer
2571 *
2572 * This function operates on double-precision floating point values, use
2573 * SDL_roundf for single-precision floats. To get the result as an integer
2574 * type, use SDL_lround.
2575 *
2576 * \param x floating point value.
2577 * \returns the nearest integer to `x`.
2578 *
2579 * \threadsafety It is safe to call this function from any thread.
2580 *
2581 * \since This function is available since SDL 3.0.0.
2582 *
2583 * \sa SDL_roundf
2584 * \sa SDL_lround
2585 * \sa SDL_floor
2586 * \sa SDL_ceil
2587 * \sa SDL_trunc
2588 */
2589extern SDL_DECLSPEC double SDLCALL SDL_round(double x);
2590
2591/**
2592 * Round `x` to the nearest integer.
2593 *
2594 * Rounds `x` to the nearest integer. Values halfway between integers will be
2595 * rounded away from zero.
2596 *
2597 * Domain: `-INF <= x <= INF`
2598 *
2599 * Range: `-INF <= y <= INF`, y integer
2600 *
2601 * This function operates on double-precision floating point values, use
2602 * SDL_roundf for single-precision floats. To get the result as an integer
2603 * type, use SDL_lroundf.
2604 *
2605 * \param x floating point value.
2606 * \returns the nearest integer to `x`.
2607 *
2608 * \threadsafety It is safe to call this function from any thread.
2609 *
2610 * \since This function is available since SDL 3.0.0.
2611 *
2612 * \sa SDL_round
2613 * \sa SDL_lroundf
2614 * \sa SDL_floorf
2615 * \sa SDL_ceilf
2616 * \sa SDL_truncf
2617 */
2618extern SDL_DECLSPEC float SDLCALL SDL_roundf(float x);
2619
2620/**
2621 * Round `x` to the nearest integer representable as a long
2622 *
2623 * Rounds `x` to the nearest integer. Values halfway between integers will be
2624 * rounded away from zero.
2625 *
2626 * Domain: `-INF <= x <= INF`
2627 *
2628 * Range: `MIN_LONG <= y <= MAX_LONG`
2629 *
2630 * This function operates on double-precision floating point values, use
2631 * SDL_lround for single-precision floats. To get the result as a
2632 * floating-point type, use SDL_round.
2633 *
2634 * \param x floating point value.
2635 * \returns the nearest integer to `x`.
2636 *
2637 * \threadsafety It is safe to call this function from any thread.
2638 *
2639 * \since This function is available since SDL 3.0.0.
2640 *
2641 * \sa SDL_lroundf
2642 * \sa SDL_round
2643 * \sa SDL_floor
2644 * \sa SDL_ceil
2645 * \sa SDL_trunc
2646 */
2647extern SDL_DECLSPEC long SDLCALL SDL_lround(double x);
2648
2649/**
2650 * Round `x` to the nearest integer representable as a long
2651 *
2652 * Rounds `x` to the nearest integer. Values halfway between integers will be
2653 * rounded away from zero.
2654 *
2655 * Domain: `-INF <= x <= INF`
2656 *
2657 * Range: `MIN_LONG <= y <= MAX_LONG`
2658 *
2659 * This function operates on single-precision floating point values, use
2660 * SDL_lroundf for double-precision floats. To get the result as a
2661 * floating-point type, use SDL_roundf,
2662 *
2663 * \param x floating point value.
2664 * \returns the nearest integer to `x`.
2665 *
2666 * \threadsafety It is safe to call this function from any thread.
2667 *
2668 * \since This function is available since SDL 3.0.0.
2669 *
2670 * \sa SDL_lround
2671 * \sa SDL_roundf
2672 * \sa SDL_floorf
2673 * \sa SDL_ceilf
2674 * \sa SDL_truncf
2675 */
2676extern SDL_DECLSPEC long SDLCALL SDL_lroundf(float x);
2677
2678/**
2679 * Scale `x` by an integer power of two.
2680 *
2681 * Multiplies `x` by the `n`th power of the floating point radix (always 2).
2682 *
2683 * Domain: `-INF <= x <= INF`, `n` integer
2684 *
2685 * Range: `-INF <= y <= INF`
2686 *
2687 * This function operates on double-precision floating point values, use
2688 * SDL_scalbnf for single-precision floats.
2689 *
2690 * \param x floating point value to be scaled.
2691 * \param n integer exponent.
2692 * \returns `x * 2^n`.
2693 *
2694 * \threadsafety It is safe to call this function from any thread.
2695 *
2696 * \since This function is available since SDL 3.0.0.
2697 *
2698 * \sa SDL_scalbnf
2699 * \sa SDL_pow
2700 */
2701extern SDL_DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
2702
2703/**
2704 * Scale `x` by an integer power of two.
2705 *
2706 * Multiplies `x` by the `n`th power of the floating point radix (always 2).
2707 *
2708 * Domain: `-INF <= x <= INF`, `n` integer
2709 *
2710 * Range: `-INF <= y <= INF`
2711 *
2712 * This function operates on single-precision floating point values, use
2713 * SDL_scalbn for double-precision floats.
2714 *
2715 * \param x floating point value to be scaled.
2716 * \param n integer exponent.
2717 * \returns `x * 2^n`.
2718 *
2719 * \threadsafety It is safe to call this function from any thread.
2720 *
2721 * \since This function is available since SDL 3.0.0.
2722 *
2723 * \sa SDL_scalbn
2724 * \sa SDL_powf
2725 */
2726extern SDL_DECLSPEC float SDLCALL SDL_scalbnf(float x, int n);
2727
2728/**
2729 * Compute the sine of `x`.
2730 *
2731 * Domain: `-INF <= x <= INF`
2732 *
2733 * Range: `-1 <= y <= 1`
2734 *
2735 * This function operates on double-precision floating point values, use
2736 * SDL_sinf for single-precision floats.
2737 *
2738 * This function may use a different approximation across different versions,
2739 * platforms and configurations. i.e, it can return a different value given
2740 * the same input on different machines or operating systems, or if SDL is
2741 * updated.
2742 *
2743 * \param x floating point value, in radians.
2744 * \returns sine of `x`.
2745 *
2746 * \threadsafety It is safe to call this function from any thread.
2747 *
2748 * \since This function is available since SDL 3.0.0.
2749 *
2750 * \sa SDL_sinf
2751 * \sa SDL_asin
2752 * \sa SDL_cos
2753 */
2754extern SDL_DECLSPEC double SDLCALL SDL_sin(double x);
2755
2756/**
2757 * Compute the sine of `x`.
2758 *
2759 * Domain: `-INF <= x <= INF`
2760 *
2761 * Range: `-1 <= y <= 1`
2762 *
2763 * This function operates on single-precision floating point values, use
2764 * SDL_sinf for double-precision floats.
2765 *
2766 * This function may use a different approximation across different versions,
2767 * platforms and configurations. i.e, it can return a different value given
2768 * the same input on different machines or operating systems, or if SDL is
2769 * updated.
2770 *
2771 * \param x floating point value, in radians.
2772 * \returns sine of `x`.
2773 *
2774 * \threadsafety It is safe to call this function from any thread.
2775 *
2776 * \since This function is available since SDL 3.0.0.
2777 *
2778 * \sa SDL_sin
2779 * \sa SDL_asinf
2780 * \sa SDL_cosf
2781 */
2782extern SDL_DECLSPEC float SDLCALL SDL_sinf(float x);
2783
2784/**
2785 * Compute the square root of `x`.
2786 *
2787 * Domain: `0 <= x <= INF`
2788 *
2789 * Range: `0 <= y <= INF`
2790 *
2791 * This function operates on double-precision floating point values, use
2792 * SDL_sqrtf for single-precision floats.
2793 *
2794 * This function may use a different approximation across different versions,
2795 * platforms and configurations. i.e, it can return a different value given
2796 * the same input on different machines or operating systems, or if SDL is
2797 * updated.
2798 *
2799 * \param x floating point value. Must be greater than or equal to 0.
2800 * \returns square root of `x`.
2801 *
2802 * \threadsafety It is safe to call this function from any thread.
2803 *
2804 * \since This function is available since SDL 3.0.0.
2805 *
2806 * \sa SDL_sqrtf
2807 */
2808extern SDL_DECLSPEC double SDLCALL SDL_sqrt(double x);
2809
2810/**
2811 * Compute the square root of `x`.
2812 *
2813 * Domain: `0 <= x <= INF`
2814 *
2815 * Range: `0 <= y <= INF`
2816 *
2817 * This function operates on single-precision floating point values, use
2818 * SDL_sqrt for double-precision floats.
2819 *
2820 * This function may use a different approximation across different versions,
2821 * platforms and configurations. i.e, it can return a different value given
2822 * the same input on different machines or operating systems, or if SDL is
2823 * updated.
2824 *
2825 * \param x floating point value. Must be greater than or equal to 0.
2826 * \returns square root of `x`.
2827 *
2828 * \threadsafety It is safe to call this function from any thread.
2829 *
2830 * \since This function is available since SDL 3.0.0.
2831 *
2832 * \sa SDL_sqrt
2833 */
2834extern SDL_DECLSPEC float SDLCALL SDL_sqrtf(float x);
2835
2836/**
2837 * Compute the tangent of `x`.
2838 *
2839 * Domain: `-INF <= x <= INF`
2840 *
2841 * Range: `-INF <= y <= INF`
2842 *
2843 * This function operates on double-precision floating point values, use
2844 * SDL_tanf for single-precision floats.
2845 *
2846 * This function may use a different approximation across different versions,
2847 * platforms and configurations. i.e, it can return a different value given
2848 * the same input on different machines or operating systems, or if SDL is
2849 * updated.
2850 *
2851 * \param x floating point value, in radians.
2852 * \returns tangent of `x`.
2853 *
2854 * \threadsafety It is safe to call this function from any thread.
2855 *
2856 * \since This function is available since SDL 3.0.0.
2857 *
2858 * \sa SDL_tanf
2859 * \sa SDL_sin
2860 * \sa SDL_cos
2861 * \sa SDL_atan
2862 * \sa SDL_atan2
2863 */
2864extern SDL_DECLSPEC double SDLCALL SDL_tan(double x);
2865
2866/**
2867 * Compute the tangent of `x`.
2868 *
2869 * Domain: `-INF <= x <= INF`
2870 *
2871 * Range: `-INF <= y <= INF`
2872 *
2873 * This function operates on single-precision floating point values, use
2874 * SDL_tanf for double-precision floats.
2875 *
2876 * This function may use a different approximation across different versions,
2877 * platforms and configurations. i.e, it can return a different value given
2878 * the same input on different machines or operating systems, or if SDL is
2879 * updated.
2880 *
2881 * \param x floating point value, in radians.
2882 * \returns tangent of `x`.
2883 *
2884 * \threadsafety It is safe to call this function from any thread.
2885 *
2886 * \since This function is available since SDL 3.0.0.
2887 *
2888 * \sa SDL_tan
2889 * \sa SDL_sinf
2890 * \sa SDL_cosf
2891 * \sa SDL_atanf
2892 * \sa SDL_atan2f
2893 */
2894extern SDL_DECLSPEC float SDLCALL SDL_tanf(float x);
2895
2896/* The SDL implementation of iconv() returns these error codes */
2897#define SDL_ICONV_ERROR (size_t)-1
2898#define SDL_ICONV_E2BIG (size_t)-2
2899#define SDL_ICONV_EILSEQ (size_t)-3
2900#define SDL_ICONV_EINVAL (size_t)-4
2901
2902/* SDL_iconv_* are now always real symbols/types, not macros or inlined. */
2903typedef struct SDL_iconv_data_t *SDL_iconv_t;
2904extern SDL_DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
2905 const char *fromcode);
2906extern SDL_DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
2907extern SDL_DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
2908 size_t * inbytesleft, char **outbuf,
2909 size_t * outbytesleft);
2910
2911/**
2912 * Helper function to convert a string's encoding in one call.
2913 *
2914 * This function converts a buffer or string between encodings in one pass.
2915 *
2916 * The string does not need to be NULL-terminated; this function operates on
2917 * the number of bytes specified in `inbytesleft` whether there is a NULL
2918 * character anywhere in the buffer.
2919 *
2920 * The returned string is owned by the caller, and should be passed to
2921 * SDL_free when no longer needed.
2922 *
2923 * \param tocode the character encoding of the output string. Examples are
2924 * "UTF-8", "UCS-4", etc.
2925 * \param fromcode the character encoding of data in `inbuf`.
2926 * \param inbuf the string to convert to a different encoding.
2927 * \param inbytesleft the size of the input string _in bytes_.
2928 * \returns a new string, converted to the new encoding, or NULL on error.
2929 *
2930 * \since This function is available since SDL 3.0.0.
2931 */
2932extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode,
2933 const char *fromcode,
2934 const char *inbuf,
2935 size_t inbytesleft);
2936
2937/* Some helper macros for common cases... */
2938#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
2939#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
2940#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
2941#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t))
2942
2943/* force builds using Clang's static analysis tools to use literal C runtime
2944 here, since there are possibly tests that are ineffective otherwise. */
2945#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
2946
2947/* The analyzer knows about strlcpy even when the system doesn't provide it */
2948#if !defined(HAVE_STRLCPY) && !defined(strlcpy)
2949size_t strlcpy(char *dst, const char *src, size_t size);
2950#endif
2951
2952/* The analyzer knows about strlcat even when the system doesn't provide it */
2953#if !defined(HAVE_STRLCAT) && !defined(strlcat)
2954size_t strlcat(char *dst, const char *src, size_t size);
2955#endif
2956
2957#if !defined(HAVE_WCSLCPY) && !defined(wcslcpy)
2958size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
2959#endif
2960
2961#if !defined(HAVE_WCSLCAT) && !defined(wcslcat)
2962size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
2963#endif
2964
2965/* Starting LLVM 16, the analyser errors out if these functions do not have
2966 their prototype defined (clang-diagnostic-implicit-function-declaration) */
2967#include <stdio.h>
2968#include <stdlib.h>
2969#include <strings.h>
2970
2971#define SDL_malloc malloc
2972#define SDL_calloc calloc
2973#define SDL_realloc realloc
2974#define SDL_free free
2975#ifndef SDL_memcpy
2976#define SDL_memcpy memcpy
2977#endif
2978#ifndef SDL_memmove
2979#define SDL_memmove memmove
2980#endif
2981#ifndef SDL_memset
2982#define SDL_memset memset
2983#endif
2984#define SDL_memcmp memcmp
2985#define SDL_strlcpy strlcpy
2986#define SDL_strlcat strlcat
2987#define SDL_strlen strlen
2988#define SDL_wcslen wcslen
2989#define SDL_wcslcpy wcslcpy
2990#define SDL_wcslcat wcslcat
2991#define SDL_strdup strdup
2992#define SDL_wcsdup wcsdup
2993#define SDL_strchr strchr
2994#define SDL_strrchr strrchr
2995#define SDL_strstr strstr
2996#define SDL_wcsstr wcsstr
2997#define SDL_strtok_r strtok_r
2998#define SDL_strcmp strcmp
2999#define SDL_wcscmp wcscmp
3000#define SDL_strncmp strncmp
3001#define SDL_wcsncmp wcsncmp
3002#define SDL_strcasecmp strcasecmp
3003#define SDL_strncasecmp strncasecmp
3004#define SDL_sscanf sscanf
3005#define SDL_vsscanf vsscanf
3006#define SDL_snprintf snprintf
3007#define SDL_vsnprintf vsnprintf
3008#endif
3009
3010/**
3011 * Multiply two integers, checking for overflow.
3012 *
3013 * If `a * b` would overflow, return -1.
3014 *
3015 * Otherwise store `a * b` via ret and return 0.
3016 *
3017 * \param a the multiplicand.
3018 * \param b the multiplier.
3019 * \param ret on non-overflow output, stores the multiplication result. May
3020 * not be NULL.
3021 * \returns -1 on overflow, 0 if result doesn't overflow.
3022 *
3023 * \threadsafety It is safe to call this function from any thread.
3024 *
3025 * \since This function is available since SDL 3.0.0.
3026 */
3028 size_t b,
3029 size_t *ret)
3030{
3031 if (a != 0 && b > SDL_SIZE_MAX / a) {
3032 return -1;
3033 }
3034 *ret = a * b;
3035 return 0;
3036}
3037
3038#ifndef SDL_WIKI_DOCUMENTATION_SECTION
3039#if SDL_HAS_BUILTIN(__builtin_mul_overflow)
3040/* This needs to be wrapped in an inline rather than being a direct #define,
3041 * because __builtin_mul_overflow() is type-generic, but we want to be
3042 * consistent about interpreting a and b as size_t. */
3043SDL_FORCE_INLINE int SDL_size_mul_overflow_builtin (size_t a,
3044 size_t b,
3045 size_t *ret)
3046{
3047 return __builtin_mul_overflow(a, b, ret) == 0 ? 0 : -1;
3048}
3049#define SDL_size_mul_overflow(a, b, ret) (SDL_size_mul_overflow_builtin(a, b, ret))
3050#endif
3051#endif
3052
3053/**
3054 * Add two integers, checking for overflow.
3055 *
3056 * If `a + b` would overflow, return -1.
3057 *
3058 * Otherwise store `a + b` via ret and return 0.
3059 *
3060 * \param a the first addend.
3061 * \param b the second addend.
3062 * \param ret on non-overflow output, stores the addition result. May not be
3063 * NULL.
3064 * \returns -1 on overflow, 0 if result doesn't overflow.
3065 *
3066 * \threadsafety It is safe to call this function from any thread.
3067 *
3068 * \since This function is available since SDL 3.0.0.
3069 */
3071 size_t b,
3072 size_t *ret)
3073{
3074 if (b > SDL_SIZE_MAX - a) {
3075 return -1;
3076 }
3077 *ret = a + b;
3078 return 0;
3079}
3080
3081#ifndef SDL_WIKI_DOCUMENTATION_SECTION
3082#if SDL_HAS_BUILTIN(__builtin_add_overflow)
3083/* This needs to be wrapped in an inline rather than being a direct #define,
3084 * the same as the call to __builtin_mul_overflow() above. */
3085SDL_FORCE_INLINE int SDL_size_add_overflow_builtin (size_t a,
3086 size_t b,
3087 size_t *ret)
3088{
3089 return __builtin_add_overflow(a, b, ret) == 0 ? 0 : -1;
3090}
3091#define SDL_size_add_overflow(a, b, ret) (SDL_size_add_overflow_builtin(a, b, ret))
3092#endif
3093#endif
3094
3095/* This is a generic function pointer which should be cast to the type you expect */
3096#ifdef SDL_FUNCTION_POINTER_IS_VOID_POINTER
3097typedef void *SDL_FunctionPointer;
3098#else
3099typedef void (*SDL_FunctionPointer)(void);
3100#endif
3101
3102/* Ends C function definitions when using C++ */
3103#ifdef __cplusplus
3104}
3105#endif
3106#include <SDL3/SDL_close_code.h>
3107
3108#endif /* SDL_stdinc_h_ */
#define SDL_ALLOC_SIZE(p)
#define SDL_ALLOC_SIZE2(p1, p2)
#define SDL_FORCE_INLINE
#define SDL_MALLOC
wchar_t * SDL_wcsdup(const wchar_t *wstr)
double SDL_sqrt(double x)
int SDL_atoi(const char *str)
#define SDL_memset
Definition SDL_stdinc.h:956
SDL_iconv_t SDL_iconv_open(const char *tocode, const char *fromcode)
float SDL_tanf(float x)
char * SDL_strtok_r(char *s1, const char *s2, char **saveptr)
int SDL_isspace(int x)
int SDL_isalnum(int x)
char * SDL_strlwr(char *str)
struct SDL_iconv_data_t * SDL_iconv_t
wchar_t * SDL_wcsnstr(const wchar_t *haystack, const wchar_t *needle, size_t maxlen)
int SDL_tolower(int x)
float SDL_modff(float x, float *y)
double SDL_modf(double x, double *y)
int SDL_abs(int x)
size_t SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Sint32 SDL_rand_r(Uint64 *state, Sint32 n)
double SDL_tan(double x)
char * SDL_ltoa(long value, char *str, int radix)
void SDL_qsort(void *base, size_t nmemb, size_t size, SDL_CompareCallback compare)
int SDL_isxdigit(int x)
Uint32 SDL_StepUTF8(const char **pstr, size_t *pslen)
float SDL_ceilf(float x)
int64_t Sint64
Definition SDL_stdinc.h:276
void SDL_GetOriginalMemoryFunctions(SDL_malloc_func *malloc_func, SDL_calloc_func *calloc_func, SDL_realloc_func *realloc_func, SDL_free_func *free_func)
void *(* SDL_malloc_func)(size_t size)
Definition SDL_stdinc.h:535
int(* SDL_CompareCallback_r)(void *userdata, const void *a, const void *b)
Definition SDL_stdinc.h:674
#define SDL_OUT_BYTECAP(x)
Definition SDL_stdinc.h:442
char * SDL_strrchr(const char *str, int c)
#define SDL_SIZE_MAX
Definition SDL_stdinc.h:77
int SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
uint16_t Uint16
Definition SDL_stdinc.h:247
int SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt,...) SDL_SCANF_VARARG_FUNC(2)
float SDL_atanf(float x)
int SDL_isprint(int x)
#define SDL_PRINTF_VARARG_FUNCV(fmtargnumber)
Definition SDL_stdinc.h:456
int SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
void SDL_qsort_r(void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata)
char * SDL_itoa(int value, char *str, int radix)
float SDL_copysignf(float x, float y)
SDL_MALLOC char * SDL_strndup(const char *str, size_t maxlen)
char * SDL_strupr(char *str)
float SDL_acosf(float x)
int SDL_SetMemoryFunctions(SDL_malloc_func malloc_func, SDL_calloc_func calloc_func, SDL_realloc_func realloc_func, SDL_free_func free_func)
size_t SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
SDL_FORCE_INLINE int SDL_size_mul_overflow(size_t a, size_t b, size_t *ret)
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
char * SDL_strchr(const char *str, int c)
SDL_MALLOC void * SDL_aligned_alloc(size_t alignment, size_t size)
#define SDL_IN_BYTECAP(x)
Definition SDL_stdinc.h:438
int SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2)
float SDL_randf(void)
Sint32 SDL_rand(Sint32 n)
char * SDL_uitoa(unsigned int value, char *str, int radix)
int SDL_isalpha(int x)
double SDL_round(double x)
long SDL_lround(double x)
int SDL_isdigit(int x)
int SDL_isblank(int x)
size_t SDL_strnlen(const char *str, size_t maxlen)
int SDL_iconv_close(SDL_iconv_t cd)
int SDL_isinff(float x)
double SDL_sin(double x)
char * SDL_strcasestr(const char *haystack, const char *needle)
float SDL_scalbnf(float x, int n)
double SDL_pow(double x, double y)
size_t SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes)
float SDL_asinf(float x)
double SDL_asin(double x)
double SDL_acos(double x)
wchar_t * SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle)
int(* SDL_CompareCallback)(const void *a, const void *b)
Definition SDL_stdinc.h:670
float SDL_sinf(float x)
int SDL_swprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt,...) SDL_WPRINTF_VARARG_FUNC(3)
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3)
#define SDL_SCANF_VARARG_FUNCV(fmtargnumber)
Definition SDL_stdinc.h:458
void SDL_srand(Uint64 seed)
Uint32 SDL_rand_bits_r(Uint64 *state)
double SDL_ceil(double x)
size_t SDL_utf8strnlen(const char *str, size_t bytes)
int SDL_strcasecmp(const char *str1, const char *str2)
void * SDL_memset4(void *dst, Uint32 val, size_t dwords)
#define SDL_SCANF_FORMAT_STRING
Definition SDL_stdinc.h:445
char * SDL_strstr(const char *haystack, const char *needle)
int SDL_GetNumAllocations(void)
double SDL_exp(double x)
char * SDL_UCS4ToUTF8(Uint32 codepoint, char *dst)
size_t SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
double SDL_atan(double x)
float SDL_sqrtf(float x)
size_t SDL_wcslen(const wchar_t *wstr)
int32_t Sint32
Definition SDL_stdinc.h:256
int SDL_setenv(const char *name, const char *value, int overwrite)
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
#define SDL_INOUT_Z_CAP(x)
Definition SDL_stdinc.h:439
double SDL_scalbn(double x, int n)
int SDL_unsetenv(const char *name)
char * SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft)
int SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2)
double SDL_fmod(double x, double y)
char * SDL_lltoa(Sint64 value, char *str, int radix)
double SDL_fabs(double x)
Sint64 SDL_strtoll(const char *str, char **endp, int base)
int SDL_ispunct(int x)
float SDL_truncf(float x)
double SDL_log10(double x)
SDL_MALLOC size_t size
Definition SDL_stdinc.h:531
float SDL_expf(float x)
char * SDL_strrev(char *str)
double SDL_floor(double x)
int SDL_wcscmp(const wchar_t *str1, const wchar_t *str2)
long SDL_strtol(const char *str, char **endp, int base)
Uint32 SDL_crc32(Uint32 crc, const void *data, size_t len)
int SDL_islower(int x)
void SDL_aligned_free(void *mem)
float SDL_logf(float x)
int SDL_isnan(double x)
int SDL_isinf(double x)
float SDL_log10f(float x)
void(* SDL_free_func)(void *mem)
Definition SDL_stdinc.h:538
int SDL_memcmp(const void *s1, const void *s2, size_t len)
char * SDL_ulltoa(Uint64 value, char *str, int radix)
const char * SDL_getenv(const char *name)
float SDL_roundf(float x)
double SDL_strtod(const char *str, char **endp)
long SDL_lroundf(float x)
char * SDL_ultoa(unsigned long value, char *str, int radix)
double SDL_atof(const char *str)
char * SDL_strnstr(const char *haystack, const char *needle, size_t maxlen)
Uint32 SDL_rand_bits(void)
size_t SDL_wcsnlen(const wchar_t *wstr, size_t maxlen)
unsigned long SDL_strtoul(const char *str, char **endp, int base)
float SDL_floorf(float x)
int SDL_strcmp(const char *str1, const char *str2)
SDL_FORCE_INLINE int SDL_size_add_overflow(size_t a, size_t b, size_t *ret)
double SDL_cos(double x)
#define SDL_PRINTF_FORMAT_STRING
Definition SDL_stdinc.h:444
float SDL_fmodf(float x, float y)
int SDL_vswprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, const wchar_t *fmt, va_list ap)
void SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func, SDL_calloc_func *calloc_func, SDL_realloc_func *realloc_func, SDL_free_func *free_func)
SDL_MALLOC void * SDL_malloc(size_t size)
#define SDL_PRINTF_VARARG_FUNC(fmtargnumber)
Definition SDL_stdinc.h:455
#define SDL_COMPILE_TIME_ASSERT(name, x)
Definition SDL_stdinc.h:479
float SDL_atan2f(float y, float x)
int SDL_isupper(int x)
long SDL_wcstol(const wchar_t *str, wchar_t **endp, int base)
float SDL_fabsf(float x)
uint64_t Uint64
Definition SDL_stdinc.h:287
SDL_MALLOC char * SDL_strdup(const char *str)
int SDL_iscntrl(int x)
void * SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback compare)
#define SDL_memcpy
Definition SDL_stdinc.h:931
void SDL_free(void *mem)
void * SDL_bsearch_r(const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata)
void *(* SDL_calloc_func)(size_t nmemb, size_t size)
Definition SDL_stdinc.h:536
#define SDL_SCANF_VARARG_FUNC(fmtargnumber)
Definition SDL_stdinc.h:457
double SDL_atan2(double y, double x)
double SDL_log(double x)
void(* SDL_FunctionPointer)(void)
int SDL_isnanf(float x)
int SDL_toupper(int x)
uint32_t Uint32
Definition SDL_stdinc.h:265
float SDL_powf(float x, float y)
size_t SDL_strlen(const char *str)
#define SDL_memmove
Definition SDL_stdinc.h:945
Uint16 SDL_crc16(Uint16 crc, const void *data, size_t len)
int SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(3)
float SDL_cosf(float x)
int SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen)
size_t SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
double SDL_copysign(double x, double y)
int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap) SDL_SCANF_VARARG_FUNCV(2)
void *(* SDL_realloc_func)(void *mem, size_t size)
Definition SDL_stdinc.h:537
size_t SDL_utf8strlen(const char *str)
int SDL_isgraph(int x)
float SDL_randf_r(Uint64 *state)
int SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(2)
#define SDL_OUT_Z_CAP(x)
Definition SDL_stdinc.h:440
#define SDL_WPRINTF_VARARG_FUNC(fmtargnumber)
Definition SDL_stdinc.h:459
Uint64 SDL_strtoull(const char *str, char **endp, int base)
double SDL_trunc(double x)

◆ SDL_const_cast

#define SDL_const_cast (   type,
  expression 
)    ((type)(expression))

Definition at line 129 of file SDL_stdinc.h.

◆ SDL_copyp

#define SDL_copyp (   dst,
  src 
)
Value:
{ SDL_COMPILE_TIME_ASSERT(SDL_copyp, sizeof (*(dst)) == sizeof (*(src))); } \
SDL_memcpy((dst), (src), sizeof(*(src)))
#define SDL_copyp(dst, src)
Definition SDL_stdinc.h:934

Definition at line 934 of file SDL_stdinc.h.

935 { SDL_COMPILE_TIME_ASSERT(SDL_copyp, sizeof (*(dst)) == sizeof (*(src))); } \
936 SDL_memcpy((dst), (src), sizeof(*(src)))

◆ SDL_FALSE

#define SDL_FALSE   0

A boolean false.

Since
This macro is available since SDL 3.0.0.
See also
SDL_bool

Definition at line 194 of file SDL_stdinc.h.

◆ SDL_FLT_EPSILON

#define SDL_FLT_EPSILON   1.1920928955078125e-07F /* 0x0.000002p0 */

Epsilon constant, used for comparing floating-point numbers.

Equals by default to platform-defined FLT_EPSILON, or 1.1920928955078125e-07F if that's not available.

Since
This macro is available since SDL 3.0.0.

Definition at line 327 of file SDL_stdinc.h.

◆ SDL_FOURCC

#define SDL_FOURCC (   A,
  B,
  C,
 
)
Value:
uint8_t Uint8
Definition SDL_stdinc.h:229
#define SDL_static_cast(type, expression)
Definition SDL_stdinc.h:128

Definition at line 134 of file SDL_stdinc.h.

◆ SDL_HAS_BUILTIN

#define SDL_HAS_BUILTIN (   x)    0

Check if the compiler supports a given builtin. Supported by virtually all clang versions and recent gcc. Use this instead of checking the clang version if possible.

Definition at line 88 of file SDL_stdinc.h.

◆ SDL_ICONV_E2BIG

#define SDL_ICONV_E2BIG   (size_t)-2

Definition at line 2898 of file SDL_stdinc.h.

◆ SDL_ICONV_EILSEQ

#define SDL_ICONV_EILSEQ   (size_t)-3

Definition at line 2899 of file SDL_stdinc.h.

◆ SDL_ICONV_EINVAL

#define SDL_ICONV_EINVAL   (size_t)-4

Definition at line 2900 of file SDL_stdinc.h.

◆ SDL_ICONV_ERROR

#define SDL_ICONV_ERROR   (size_t)-1

Definition at line 2897 of file SDL_stdinc.h.

◆ SDL_iconv_utf8_locale

#define SDL_iconv_utf8_locale (   S)    SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)

Definition at line 2938 of file SDL_stdinc.h.

◆ SDL_iconv_utf8_ucs2

#define SDL_iconv_utf8_ucs2 (   S)    (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)

Definition at line 2939 of file SDL_stdinc.h.

◆ SDL_iconv_utf8_ucs4

#define SDL_iconv_utf8_ucs4 (   S)    (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)

Definition at line 2940 of file SDL_stdinc.h.

◆ SDL_iconv_wchar_utf8

#define SDL_iconv_wchar_utf8 (   S)    SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t))

Definition at line 2941 of file SDL_stdinc.h.

◆ SDL_IN_BYTECAP

#define SDL_IN_BYTECAP (   x)

Definition at line 438 of file SDL_stdinc.h.

◆ SDL_INOUT_Z_CAP

#define SDL_INOUT_Z_CAP (   x)

Definition at line 439 of file SDL_stdinc.h.

◆ SDL_INVALID_UNICODE_CODEPOINT

#define SDL_INVALID_UNICODE_CODEPOINT   0xFFFD

The Unicode REPLACEMENT CHARACTER codepoint.

SDL_StepUTF8() reports this codepoint when it encounters a UTF-8 string with encoding errors.

This tends to render as something like a question mark in most places.

Since
This macro is available since SDL 3.0.0.
See also
SDL_StepUTF8

Definition at line 1302 of file SDL_stdinc.h.

◆ SDL_max

#define SDL_max (   x,
 
)    (((x) > (y)) ? (x) : (y))

Definition at line 682 of file SDL_stdinc.h.

◆ SDL_MAX_SINT16

#define SDL_MAX_SINT16   ((Sint16)0x7FFF) /* 32767 */

Definition at line 239 of file SDL_stdinc.h.

◆ SDL_MAX_SINT32

#define SDL_MAX_SINT32   ((Sint32)0x7FFFFFFF) /* 2147483647 */

Definition at line 257 of file SDL_stdinc.h.

◆ SDL_MAX_SINT64

#define SDL_MAX_SINT64   SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* 9223372036854775807 */

Definition at line 277 of file SDL_stdinc.h.

◆ SDL_MAX_SINT8

#define SDL_MAX_SINT8   ((Sint8)0x7F) /* 127 */

Definition at line 221 of file SDL_stdinc.h.

◆ SDL_MAX_TIME

#define SDL_MAX_TIME   SDL_MAX_SINT64

Definition at line 305 of file SDL_stdinc.h.

◆ SDL_MAX_UINT16

#define SDL_MAX_UINT16   ((Uint16)0xFFFF) /* 65535 */

Definition at line 248 of file SDL_stdinc.h.

◆ SDL_MAX_UINT32

#define SDL_MAX_UINT32   ((Uint32)0xFFFFFFFFu) /* 4294967295 */

Definition at line 266 of file SDL_stdinc.h.

◆ SDL_MAX_UINT64

#define SDL_MAX_UINT64   SDL_UINT64_C(0xFFFFFFFFFFFFFFFF) /* 18446744073709551615 */

Definition at line 288 of file SDL_stdinc.h.

◆ SDL_MAX_UINT8

#define SDL_MAX_UINT8   ((Uint8)0xFF) /* 255 */

Definition at line 230 of file SDL_stdinc.h.

◆ SDL_memcpy

#define SDL_memcpy   memcpy

Definition at line 931 of file SDL_stdinc.h.

◆ SDL_memmove

#define SDL_memmove   memmove

Definition at line 945 of file SDL_stdinc.h.

◆ SDL_memset

#define SDL_memset   memset

Definition at line 956 of file SDL_stdinc.h.

◆ SDL_min

#define SDL_min (   x,
 
)    (((x) < (y)) ? (x) : (y))

Definition at line 681 of file SDL_stdinc.h.

◆ SDL_MIN_SINT16

#define SDL_MIN_SINT16   ((Sint16)(~0x7FFF)) /* -32768 */

Definition at line 240 of file SDL_stdinc.h.

◆ SDL_MIN_SINT32

#define SDL_MIN_SINT32   ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */

Definition at line 258 of file SDL_stdinc.h.

◆ SDL_MIN_SINT64

#define SDL_MIN_SINT64   ~SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* -9223372036854775808 */

Definition at line 278 of file SDL_stdinc.h.

◆ SDL_MIN_SINT8

#define SDL_MIN_SINT8   ((Sint8)(~0x7F)) /* -128 */

Definition at line 222 of file SDL_stdinc.h.

◆ SDL_MIN_TIME

#define SDL_MIN_TIME   SDL_MIN_SINT64

Definition at line 306 of file SDL_stdinc.h.

◆ SDL_MIN_UINT16

#define SDL_MIN_UINT16   ((Uint16)0x0000) /* 0 */

Definition at line 249 of file SDL_stdinc.h.

◆ SDL_MIN_UINT32

#define SDL_MIN_UINT32   ((Uint32)0x00000000) /* 0 */

Definition at line 267 of file SDL_stdinc.h.

◆ SDL_MIN_UINT64

#define SDL_MIN_UINT64   SDL_UINT64_C(0x0000000000000000) /* 0 */

Definition at line 289 of file SDL_stdinc.h.

◆ SDL_MIN_UINT8

#define SDL_MIN_UINT8   ((Uint8)0x00) /* 0 */

Definition at line 231 of file SDL_stdinc.h.

◆ SDL_OUT_BYTECAP

#define SDL_OUT_BYTECAP (   x)

Definition at line 442 of file SDL_stdinc.h.

◆ SDL_OUT_CAP

#define SDL_OUT_CAP (   x)

Definition at line 441 of file SDL_stdinc.h.

◆ SDL_OUT_Z_BYTECAP

#define SDL_OUT_Z_BYTECAP (   x)

Definition at line 443 of file SDL_stdinc.h.

◆ SDL_OUT_Z_CAP

#define SDL_OUT_Z_CAP (   x)

Definition at line 440 of file SDL_stdinc.h.

◆ SDL_PI_D

#define SDL_PI_D   3.141592653589793238462643383279502884

pi (double)

Definition at line 1577 of file SDL_stdinc.h.

◆ SDL_PI_F

#define SDL_PI_F   3.141592653589793238462643383279502884F

pi (float)

Definition at line 1580 of file SDL_stdinc.h.

◆ SDL_PRINTF_FORMAT_STRING

#define SDL_PRINTF_FORMAT_STRING

Definition at line 444 of file SDL_stdinc.h.

◆ SDL_PRINTF_VARARG_FUNC

#define SDL_PRINTF_VARARG_FUNC (   fmtargnumber)

Definition at line 455 of file SDL_stdinc.h.

◆ SDL_PRINTF_VARARG_FUNCV

#define SDL_PRINTF_VARARG_FUNCV (   fmtargnumber)

Definition at line 456 of file SDL_stdinc.h.

◆ SDL_PRIs32

#define SDL_PRIs32   "d"

Definition at line 383 of file SDL_stdinc.h.

◆ SDL_PRIs64

#define SDL_PRIs64   "lld"

Definition at line 343 of file SDL_stdinc.h.

◆ SDL_PRIu32

#define SDL_PRIu32   "u"

Definition at line 390 of file SDL_stdinc.h.

◆ SDL_PRIu64

#define SDL_PRIu64   "llu"

Definition at line 354 of file SDL_stdinc.h.

◆ SDL_PRIx32

#define SDL_PRIx32   "x"

Definition at line 397 of file SDL_stdinc.h.

◆ SDL_PRIX32

#define SDL_PRIX32   "X"

Definition at line 404 of file SDL_stdinc.h.

◆ SDL_PRIx64

#define SDL_PRIx64   "llx"

Definition at line 365 of file SDL_stdinc.h.

◆ SDL_PRIX64

#define SDL_PRIX64   "llX"

Definition at line 376 of file SDL_stdinc.h.

◆ SDL_reinterpret_cast

#define SDL_reinterpret_cast (   type,
  expression 
)    ((type)(expression))

Definition at line 127 of file SDL_stdinc.h.

◆ SDL_SCANF_FORMAT_STRING

#define SDL_SCANF_FORMAT_STRING

Definition at line 445 of file SDL_stdinc.h.

◆ SDL_SCANF_VARARG_FUNC

#define SDL_SCANF_VARARG_FUNC (   fmtargnumber)

Definition at line 457 of file SDL_stdinc.h.

◆ SDL_SCANF_VARARG_FUNCV

#define SDL_SCANF_VARARG_FUNCV (   fmtargnumber)

Definition at line 458 of file SDL_stdinc.h.

◆ SDL_SINT64_C

#define SDL_SINT64_C (   c)    c ## LL

Definition at line 178 of file SDL_stdinc.h.

◆ SDL_SIZE_MAX

#define SDL_SIZE_MAX   ((size_t) -1)

Definition at line 77 of file SDL_stdinc.h.

◆ SDL_stack_alloc

#define SDL_stack_alloc (   type,
  count 
)    (type*)alloca(sizeof(type)*(count))

Definition at line 523 of file SDL_stdinc.h.

◆ SDL_stack_free

#define SDL_stack_free (   data)

Definition at line 524 of file SDL_stdinc.h.

◆ SDL_static_cast

#define SDL_static_cast (   type,
  expression 
)    ((type)(expression))

Definition at line 128 of file SDL_stdinc.h.

◆ SDL_STRINGIFY_ARG

#define SDL_STRINGIFY_ARG (   arg)    #arg

Macro useful for building other macros with strings in them.

For example:

#define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(__FUNCTION__) ": " X "\n")`
Since
This macro is available since SDL 3.0.0.

Definition at line 113 of file SDL_stdinc.h.

◆ SDL_TRUE

#define SDL_TRUE   1

A boolean true.

Since
This macro is available since SDL 3.0.0.
See also
SDL_bool

Definition at line 203 of file SDL_stdinc.h.

◆ SDL_UINT64_C

#define SDL_UINT64_C (   c)    c ## ULL

Definition at line 179 of file SDL_stdinc.h.

◆ SDL_WPRINTF_VARARG_FUNC

#define SDL_WPRINTF_VARARG_FUNC (   fmtargnumber)

Definition at line 459 of file SDL_stdinc.h.

◆ SDL_WSCANF_VARARG_FUNC

#define SDL_WSCANF_VARARG_FUNC (   fmtargnumber)

Definition at line 460 of file SDL_stdinc.h.

◆ SDL_zero

#define SDL_zero (   x)    SDL_memset(&(x), 0, sizeof((x)))

Definition at line 959 of file SDL_stdinc.h.

◆ SDL_zeroa

#define SDL_zeroa (   x)    SDL_memset((x), 0, sizeof((x)))

Definition at line 961 of file SDL_stdinc.h.

◆ SDL_zerop

#define SDL_zerop (   x)    SDL_memset((x), 0, sizeof(*(x)))

Definition at line 960 of file SDL_stdinc.h.

Typedef Documentation

◆ SDL_bool

typedef int SDL_bool

A boolean type: true or false.

Since
This datatype is available since SDL 3.0.0.
See also
SDL_TRUE
SDL_FALSE

Definition at line 213 of file SDL_stdinc.h.

◆ SDL_calloc_func

typedef void *(* SDL_calloc_func) (size_t nmemb, size_t size)

Definition at line 536 of file SDL_stdinc.h.

◆ SDL_CompareCallback

typedef int(* SDL_CompareCallback) (const void *a, const void *b)

Definition at line 670 of file SDL_stdinc.h.

◆ SDL_CompareCallback_r

typedef int(* SDL_CompareCallback_r) (void *userdata, const void *a, const void *b)

Definition at line 674 of file SDL_stdinc.h.

◆ SDL_free_func

typedef void(* SDL_free_func) (void *mem)

Definition at line 538 of file SDL_stdinc.h.

◆ SDL_FunctionPointer

typedef void(* SDL_FunctionPointer) (void)

Definition at line 3099 of file SDL_stdinc.h.

◆ SDL_iconv_t

typedef struct SDL_iconv_data_t* SDL_iconv_t

Definition at line 2903 of file SDL_stdinc.h.

◆ SDL_malloc_func

typedef void *(* SDL_malloc_func) (size_t size)

Definition at line 535 of file SDL_stdinc.h.

◆ SDL_realloc_func

typedef void *(* SDL_realloc_func) (void *mem, size_t size)

Definition at line 537 of file SDL_stdinc.h.

◆ SDL_Time

typedef Sint64 SDL_Time

SDL times are signed, 64-bit integers representing nanoseconds since the Unix epoch (Jan 1, 1970).

They can be converted between POSIX time_t values with SDL_NS_TO_SECONDS() and SDL_SECONDS_TO_NS(), and between Windows FILETIME values with SDL_TimeToWindows() and SDL_TimeFromWindows().

Since
This macro is available since SDL 3.0.0.
See also
SDL_MAX_SINT64
SDL_MIN_SINT64

Definition at line 304 of file SDL_stdinc.h.

◆ Sint16

typedef int16_t Sint16

A signed 16-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 238 of file SDL_stdinc.h.

◆ Sint32

typedef int32_t Sint32

A signed 32-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 256 of file SDL_stdinc.h.

◆ Sint64

typedef int64_t Sint64

A signed 64-bit integer type.

Since
This macro is available since SDL 3.0.0.
See also
SDL_SINT64_C

Definition at line 276 of file SDL_stdinc.h.

◆ Sint8

typedef int8_t Sint8

A signed 8-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 220 of file SDL_stdinc.h.

◆ Uint16

typedef uint16_t Uint16

An unsigned 16-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 247 of file SDL_stdinc.h.

◆ Uint32

typedef uint32_t Uint32

An unsigned 32-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 265 of file SDL_stdinc.h.

◆ Uint64

typedef uint64_t Uint64

An unsigned 64-bit integer type.

Since
This macro is available since SDL 3.0.0.
See also
SDL_UINT64_C

Definition at line 287 of file SDL_stdinc.h.

◆ Uint8

typedef uint8_t Uint8

An unsigned 8-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 229 of file SDL_stdinc.h.

Function Documentation

◆ alloca()

void * alloca ( size_t  )

CategoryStdinc

This is a general header that includes C language support. It implements a subset of the C runtime: these should all behave the same way as their C runtime equivalents, but with an SDL_ prefix.

◆ SDL_abs()

int SDL_abs ( int  x)
extern

◆ SDL_acos()

double SDL_acos ( double  x)
extern

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.

Parameters
xfloating point value.
Returns
arc cosine of x, in radians.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_acosf
SDL_asin
SDL_cos

◆ SDL_acosf()

float SDL_acosf ( float  x)
extern

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.

Parameters
xfloating point value.
Returns
arc cosine of x, in radians.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_acos
SDL_asinf
SDL_cosf

◆ SDL_aligned_alloc()

SDL_MALLOC void * SDL_aligned_alloc ( size_t  alignment,
size_t  size 
)
extern

Allocate memory aligned to a specific value.

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

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

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

Parameters
alignmentthe alignment requested.
sizethe size to allocate.
Returns
a pointer to the aligned memory.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_aligned_free

◆ SDL_aligned_free()

void SDL_aligned_free ( void *  mem)
extern

Free memory allocated by SDL_aligned_alloc().

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

Parameters
mema pointer previously returned by SDL_aligned_alloc.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_aligned_alloc

◆ SDL_ALLOC_SIZE()

SDL_ALLOC_SIZE ( )
extern

◆ SDL_ALLOC_SIZE2()

SDL_MALLOC SDL_ALLOC_SIZE2 ( ,
 
)
extern

◆ SDL_asin()

double SDL_asin ( double  x)
extern

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.

Parameters
xfloating point value.
Returns
arc sine of x, in radians.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_asinf
SDL_acos
SDL_sin

◆ SDL_asinf()

float SDL_asinf ( float  x)
extern

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.

Parameters
xfloating point value.
Returns
arc sine of x, in radians.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_asin
SDL_acosf
SDL_sinf

◆ SDL_asprintf()

int SDL_asprintf ( char **  strp,
SDL_PRINTF_FORMAT_STRING const char *  fmt,
  ... 
)
extern

◆ SDL_atan()

double SDL_atan ( double  x)
extern

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.

Parameters
xfloating point value.
Returns
arc tangent of of x in radians, or 0 if x = 0.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_atanf
SDL_atan2
SDL_tan

◆ SDL_atan2()

double SDL_atan2 ( double  y,
double  x 
)
extern

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/2 <= y <= Pi/2

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.

Parameters
yfloating point value of the numerator (y coordinate).
xfloating point value of the denominator (x coordinate).
Returns
arc tangent of of y / x in radians, or, if x = 0, either -Pi/2, 0, or Pi/2, depending on the value of y.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_atan2f
SDL_atan
SDL_tan

◆ SDL_atan2f()

float SDL_atan2f ( float  y,
float  x 
)
extern

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/2 <= y <= Pi/2

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.

Parameters
yfloating point value of the numerator (y coordinate).
xfloating point value of the denominator (x coordinate).
Returns
arc tangent of of y / x in radians, or, if x = 0, either -Pi/2, 0, or Pi/2, depending on the value of y.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_atan2f
SDL_atan
SDL_tan

◆ SDL_atanf()

float SDL_atanf ( float  x)
extern

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.

Parameters
xfloating point value.
Returns
arc tangent of of x in radians, or 0 if x = 0.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_atan
SDL_atan2f
SDL_tanf

◆ SDL_atof()

double SDL_atof ( const char *  str)
extern

◆ SDL_atoi()

int SDL_atoi ( const char *  str)
extern

◆ SDL_bsearch()

void * SDL_bsearch ( const void *  key,
const void *  base,
size_t  nmemb,
size_t  size,
SDL_CompareCallback  compare 
)
extern

◆ SDL_bsearch_r()

void * SDL_bsearch_r ( const void *  key,
const void *  base,
size_t  nmemb,
size_t  size,
SDL_CompareCallback_r  compare,
void *  userdata 
)
extern

◆ SDL_ceil()

double SDL_ceil ( double  x)
extern

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.

Parameters
xfloating point value.
Returns
the ceiling of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_ceilf
SDL_floor
SDL_trunc
SDL_round
SDL_lround

◆ SDL_ceilf()

float SDL_ceilf ( float  x)
extern

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.

Parameters
xfloating point value.
Returns
the ceiling of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_ceil
SDL_floorf
SDL_truncf
SDL_roundf
SDL_lroundf

◆ SDL_copysign()

double SDL_copysign ( double  x,
double  y 
)
extern

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.

Parameters
xfloating point value to use as the magnitude.
yfloating point value to use as the sign.
Returns
the floating point value with the sign of y and the magnitude of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_copysignf
SDL_fabs

◆ SDL_copysignf()

float SDL_copysignf ( float  x,
float  y 
)
extern

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.

Parameters
xfloating point value to use as the magnitude.
yfloating point value to use as the sign.
Returns
the floating point value with the sign of y and the magnitude of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_copysignf
SDL_fabsf

◆ SDL_cos()

double SDL_cos ( double  x)
extern

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.

Parameters
xfloating point value, in radians.
Returns
cosine of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_cosf
SDL_acos
SDL_sin

◆ SDL_cosf()

float SDL_cosf ( float  x)
extern

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.

Parameters
xfloating point value, in radians.
Returns
cosine of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_cos
SDL_acosf
SDL_sinf

◆ SDL_crc16()

Uint16 SDL_crc16 ( Uint16  crc,
const void *  data,
size_t  len 
)
extern

◆ SDL_crc32()

Uint32 SDL_crc32 ( Uint32  crc,
const void *  data,
size_t  len 
)
extern

◆ SDL_exp()

double SDL_exp ( double  x)
extern

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.

Parameters
xfloating point value.
Returns
value of e^x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_expf
SDL_log

◆ SDL_expf()

float SDL_expf ( float  x)
extern

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.

Parameters
xfloating point value.
Returns
value of e^x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_exp
SDL_logf

◆ SDL_fabs()

double SDL_fabs ( double  x)
extern

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_copysignf for single-precision floats.

Parameters
xfloating point value to use as the magnitude.
Returns
the absolute value of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_fabsf

◆ SDL_fabsf()

float SDL_fabsf ( float  x)
extern

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_copysignf for double-precision floats.

Parameters
xfloating point value to use as the magnitude.
Returns
the absolute value of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_fabs

Referenced by SDL_RectsEqualEpsilon().

◆ SDL_floor()

double SDL_floor ( double  x)
extern

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.

Parameters
xfloating point value.
Returns
the floor of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_floorf
SDL_ceil
SDL_trunc
SDL_round
SDL_lround

◆ SDL_floorf()

float SDL_floorf ( float  x)
extern

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_floorf for double-precision floats.

Parameters
xfloating point value.
Returns
the floor of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_floor
SDL_ceilf
SDL_truncf
SDL_roundf
SDL_lroundf

◆ SDL_fmod()

double SDL_fmod ( double  x,
double  y 
)
extern

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.

Parameters
xthe numerator.
ythe denominator. Must not be 0.
Returns
the remainder of x / y.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_fmodf
SDL_modf
SDL_trunc
SDL_ceil
SDL_floor
SDL_round
SDL_lround

◆ SDL_fmodf()

float SDL_fmodf ( float  x,
float  y 
)
extern

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 single-precision floats.

Parameters
xthe numerator.
ythe denominator. Must not be 0.
Returns
the remainder of x / y.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_fmod
SDL_truncf
SDL_modff
SDL_ceilf
SDL_floorf
SDL_roundf
SDL_lroundf

◆ SDL_free()

void SDL_free ( void *  mem)
extern

◆ SDL_getenv()

const char * SDL_getenv ( const char *  name)
extern

◆ SDL_GetMemoryFunctions()

void SDL_GetMemoryFunctions ( SDL_malloc_func malloc_func,
SDL_calloc_func calloc_func,
SDL_realloc_func realloc_func,
SDL_free_func free_func 
)
extern

Get the current set of SDL memory functions.

Parameters
malloc_funcfilled with malloc function.
calloc_funcfilled with calloc function.
realloc_funcfilled with realloc function.
free_funcfilled with free function.

\threadsafety This does not hold a lock, so do not call this in the unlikely event of a background thread calling SDL_SetMemoryFunctions simultaneously.

Since
This function is available since SDL 3.0.0.
See also
SDL_SetMemoryFunctions
SDL_GetOriginalMemoryFunctions

◆ SDL_GetNumAllocations()

int SDL_GetNumAllocations ( void  )
extern

Get the number of outstanding (unfreed) allocations.

Returns
the number of allocations.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_GetOriginalMemoryFunctions()

void SDL_GetOriginalMemoryFunctions ( SDL_malloc_func malloc_func,
SDL_calloc_func calloc_func,
SDL_realloc_func realloc_func,
SDL_free_func free_func 
)
extern

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.

Parameters
malloc_funcfilled with malloc function.
calloc_funcfilled with calloc function.
realloc_funcfilled with realloc function.
free_funcfilled with free function.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_iconv()

size_t SDL_iconv ( SDL_iconv_t  cd,
const char **  inbuf,
size_t *  inbytesleft,
char **  outbuf,
size_t *  outbytesleft 
)
extern

◆ SDL_iconv_close()

int SDL_iconv_close ( SDL_iconv_t  cd)
extern

◆ SDL_iconv_open()

SDL_iconv_t SDL_iconv_open ( const char *  tocode,
const char *  fromcode 
)
extern

◆ SDL_iconv_string()

char * SDL_iconv_string ( const char *  tocode,
const char *  fromcode,
const char *  inbuf,
size_t  inbytesleft 
)
extern

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.

Parameters
tocodethe character encoding of the output string. Examples are "UTF-8", "UCS-4", etc.
fromcodethe character encoding of data in inbuf.
inbufthe string to convert to a different encoding.
inbytesleftthe size of the input string in bytes.
Returns
a new string, converted to the new encoding, or NULL on error.
Since
This function is available since SDL 3.0.0.

◆ SDL_isalnum()

int SDL_isalnum ( int  x)
extern

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.

Parameters
xcharacter value to check.
Returns
non-zero if x falls within the character class, zero otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_isalpha()

int SDL_isalpha ( int  x)
extern

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.

Parameters
xcharacter value to check.
Returns
non-zero if x falls within the character class, zero otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_isblank()

int SDL_isblank ( int  x)
extern

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.

Parameters
xcharacter value to check.
Returns
non-zero if x falls within the character class, zero otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_iscntrl()

int SDL_iscntrl ( int  x)
extern

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.

Parameters
xcharacter value to check.
Returns
non-zero if x falls within the character class, zero otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_isdigit()

int SDL_isdigit ( int  x)
extern

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.

Parameters
xcharacter value to check.
Returns
non-zero if x falls within the character class, zero otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_isgraph()

int SDL_isgraph ( int  x)
extern

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

Parameters
xcharacter value to check.
Returns
non-zero if x falls within the character class, zero otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_isprint

◆ SDL_isinf()

int SDL_isinf ( double  x)
extern

Return whether the value is infinity.

Parameters
xdouble-precision floating point value.
Returns
non-zero if the value is infinity, 0 otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_isinff

◆ SDL_isinff()

int SDL_isinff ( float  x)
extern

Return whether the value is infinity.

Parameters
xfloating point value.
Returns
non-zero if the value is infinity, 0 otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_isinf

◆ SDL_islower()

int SDL_islower ( int  x)
extern

Report if a character is lower case.

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

Parameters
xcharacter value to check.
Returns
non-zero if x falls within the character class, zero otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_isnan()

int SDL_isnan ( double  x)
extern

Return whether the value is NaN.

Parameters
xdouble-precision floating point value.
Returns
non-zero if the value is NaN, 0 otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_isnanf

◆ SDL_isnanf()

int SDL_isnanf ( float  x)
extern

Return whether the value is NaN.

Parameters
xfloating point value.
Returns
non-zero if the value is NaN, 0 otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_isnan

◆ SDL_isprint()

int SDL_isprint ( int  x)
extern

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.

Parameters
xcharacter value to check.
Returns
non-zero if x falls within the character class, zero otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_ispunct()

int SDL_ispunct ( int  x)
extern

Report if a character is a punctuation mark.

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

Parameters
xcharacter value to check.
Returns
non-zero if x falls within the character class, zero otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_isgraph
SDL_isalnum

◆ SDL_isspace()

int SDL_isspace ( int  x)
extern

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)
Parameters
xcharacter value to check.
Returns
non-zero if x falls within the character class, zero otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_isupper()

int SDL_isupper ( int  x)
extern

Report if a character is upper case.

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

Parameters
xcharacter value to check.
Returns
non-zero if x falls within the character class, zero otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_isxdigit()

int SDL_isxdigit ( int  x)
extern

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.

Parameters
xcharacter value to check.
Returns
non-zero if x falls within the character class, zero otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_itoa()

char * SDL_itoa ( int  value,
char *  str,
int  radix 
)
extern

◆ SDL_lltoa()

char * SDL_lltoa ( Sint64  value,
char *  str,
int  radix 
)
extern

◆ SDL_log()

double SDL_log ( double  x)
extern

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.

Parameters
xfloating point value. Must be greater than 0.
Returns
the natural logarithm of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_logf
SDL_log10
SDL_exp

◆ SDL_log10()

double SDL_log10 ( double  x)
extern

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.

Parameters
xfloating point value. Must be greater than 0.
Returns
the logarithm of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_log10f
SDL_log
SDL_pow

◆ SDL_log10f()

float SDL_log10f ( float  x)
extern

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.

Parameters
xfloating point value. Must be greater than 0.
Returns
the logarithm of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_log10
SDL_logf
SDL_powf

◆ SDL_logf()

float SDL_logf ( float  x)
extern

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.

Parameters
xfloating point value. Must be greater than 0.
Returns
the natural logarithm of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_log
SDL_expf

◆ SDL_lround()

long SDL_lround ( double  x)
extern

Round x to the nearest integer representable as a long

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

Domain: -INF <= x <= INF

Range: MIN_LONG <= y <= MAX_LONG

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

Parameters
xfloating point value.
Returns
the nearest integer to x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_lroundf
SDL_round
SDL_floor
SDL_ceil
SDL_trunc

◆ SDL_lroundf()

long SDL_lroundf ( float  x)
extern

Round x to the nearest integer representable as a long

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

Domain: -INF <= x <= INF

Range: MIN_LONG <= y <= MAX_LONG

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

Parameters
xfloating point value.
Returns
the nearest integer to x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_lround
SDL_roundf
SDL_floorf
SDL_ceilf
SDL_truncf

◆ SDL_ltoa()

char * SDL_ltoa ( long  value,
char *  str,
int  radix 
)
extern

◆ SDL_malloc()

SDL_MALLOC void * SDL_malloc ( size_t  size)
extern

◆ SDL_memcmp()

int SDL_memcmp ( const void *  s1,
const void *  s2,
size_t  len 
)
extern

◆ SDL_memcpy()

void * SDL_memcpy ( SDL_OUT_BYTECAP(len) void *  dst,
SDL_IN_BYTECAP(len) const void *  src,
size_t  len 
)
extern

◆ SDL_memmove()

void * SDL_memmove ( SDL_OUT_BYTECAP(len) void *  dst,
SDL_IN_BYTECAP(len) const void *  src,
size_t  len 
)
extern

◆ SDL_memset()

void * SDL_memset ( SDL_OUT_BYTECAP(len) void *  dst,
int  c,
size_t  len 
)
extern

◆ SDL_memset4()

void * SDL_memset4 ( void *  dst,
Uint32  val,
size_t  dwords 
)
extern

◆ SDL_modf()

double SDL_modf ( double  x,
double *  y 
)
extern

Split x into integer and fractional parts

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

Parameters
xfloating point value.
youtput pointer to store the integer part of x.
Returns
the fractional part of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_modff
SDL_trunc
SDL_fmod

◆ SDL_modff()

float SDL_modff ( float  x,
float *  y 
)
extern

Split x into integer and fractional parts

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

Parameters
xfloating point value.
youtput pointer to store the integer part of x.
Returns
the fractional part of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_modf
SDL_truncf
SDL_fmodf

◆ SDL_pow()

double SDL_pow ( double  x,
double  y 
)
extern

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.

Parameters
xthe base.
ythe exponent.
Returns
x raised to the power y.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_powf
SDL_exp
SDL_log

◆ SDL_powf()

float SDL_powf ( float  x,
float  y 
)
extern

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

Parameters
xthe base.
ythe exponent.
Returns
x raised to the power y.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_pow
SDL_expf
SDL_logf

◆ SDL_qsort()

void SDL_qsort ( void *  base,
size_t  nmemb,
size_t  size,
SDL_CompareCallback  compare 
)
extern

◆ SDL_qsort_r()

void SDL_qsort_r ( void *  base,
size_t  nmemb,
size_t  size,
SDL_CompareCallback_r  compare,
void *  userdata 
)
extern

◆ SDL_rand()

Sint32 SDL_rand ( Sint32  n)
extern

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.

Parameters
nthe number of possible outcomes. n must be positive.
Returns
a random value in the range of [0 .. n-1].

\threadsafety All calls should be made from a single thread

Since
This function is available since SDL 3.0.0.
See also
SDL_srand
SDL_randf

◆ SDL_rand_bits()

Uint32 SDL_rand_bits ( void  )
extern

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

\threadsafety All calls should be made from a single thread

Since
This function is available since SDL 3.0.0.
See also
SDL_rand
SDL_randf
SDL_srand

◆ SDL_rand_bits_r()

Uint32 SDL_rand_bits_r ( Uint64 state)
extern

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.

Parameters
statea pointer to the current random number state, this may not be NULL.
Returns
a random value in the range of [0-SDL_MAX_UINT32].

\threadsafety This function is thread-safe, as long as the state pointer isn't shared between threads.

Since
This function is available since SDL 3.0.0.
See also
SDL_rand_r
SDL_randf_r

◆ SDL_rand_r()

Sint32 SDL_rand_r ( Uint64 state,
Sint32  n 
)
extern

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.

Parameters
statea pointer to the current random number state, this may not be NULL.
nthe number of possible outcomes. n must be positive.
Returns
a random value in the range of [0 .. n-1].

\threadsafety This function is thread-safe, as long as the state pointer isn't shared between threads.

Since
This function is available since SDL 3.0.0.
See also
SDL_rand
SDL_rand_bits_r
SDL_randf_r

◆ SDL_randf()

float SDL_randf ( void  )
extern

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

\threadsafety All calls should be made from a single thread

Since
This function is available since SDL 3.0.0.
See also
SDL_srand
SDL_rand

◆ SDL_randf_r()

float SDL_randf_r ( Uint64 state)
extern

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.

Parameters
statea pointer to the current random number state, this may not be NULL.
Returns
a random value in the range of [0.0, 1.0).

\threadsafety This function is thread-safe, as long as the state pointer isn't shared between threads.

Since
This function is available since SDL 3.0.0.
See also
SDL_rand_bits_r
SDL_rand_r
SDL_randf

◆ SDL_round()

double SDL_round ( double  x)
extern

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.

Parameters
xfloating point value.
Returns
the nearest integer to x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_roundf
SDL_lround
SDL_floor
SDL_ceil
SDL_trunc

◆ SDL_roundf()

float SDL_roundf ( float  x)
extern

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

Parameters
xfloating point value.
Returns
the nearest integer to x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_round
SDL_lroundf
SDL_floorf
SDL_ceilf
SDL_truncf

◆ SDL_scalbn()

double SDL_scalbn ( double  x,
int  n 
)
extern

Scale x by an integer power of two.

Multiplies x by the nth 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.

Parameters
xfloating point value to be scaled.
ninteger exponent.
Returns
x * 2^n.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_scalbnf
SDL_pow

◆ SDL_scalbnf()

float SDL_scalbnf ( float  x,
int  n 
)
extern

Scale x by an integer power of two.

Multiplies x by the nth 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.

Parameters
xfloating point value to be scaled.
ninteger exponent.
Returns
x * 2^n.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_scalbn
SDL_powf

◆ SDL_setenv()

int SDL_setenv ( const char *  name,
const char *  value,
int  overwrite 
)
extern

◆ SDL_SetMemoryFunctions()

int SDL_SetMemoryFunctions ( SDL_malloc_func  malloc_func,
SDL_calloc_func  calloc_func,
SDL_realloc_func  realloc_func,
SDL_free_func  free_func 
)
extern

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.

Parameters
malloc_funccustom malloc function.
calloc_funccustom calloc function.
realloc_funccustom realloc function.
free_funccustom free function.
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread, but one should not replace the memory functions once any allocations are made!

Since
This function is available since SDL 3.0.0.
See also
SDL_GetMemoryFunctions
SDL_GetOriginalMemoryFunctions

◆ SDL_sin()

double SDL_sin ( double  x)
extern

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.

Parameters
xfloating point value, in radians.
Returns
sine of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_sinf
SDL_asin
SDL_cos

◆ SDL_sinf()

float SDL_sinf ( float  x)
extern

Compute the sine of x.

Domain: -INF <= x <= INF

Range: -1 <= y <= 1

This function operates on single-precision floating point values, use SDL_sinf 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.

Parameters
xfloating point value, in radians.
Returns
sine of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_sin
SDL_asinf
SDL_cosf

◆ SDL_size_add_overflow()

SDL_FORCE_INLINE int SDL_size_add_overflow ( size_t  a,
size_t  b,
size_t *  ret 
)

Add two integers, checking for overflow.

If a + b would overflow, return -1.

Otherwise store a + b via ret and return 0.

Parameters
athe first addend.
bthe second addend.
reton non-overflow output, stores the addition result. May not be NULL.
Returns
-1 on overflow, 0 if result doesn't overflow.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

Definition at line 3070 of file SDL_stdinc.h.

3073{
3074 if (b > SDL_SIZE_MAX - a) {
3075 return -1;
3076 }
3077 *ret = a + b;
3078 return 0;
3079}

References SDL_SIZE_MAX.

◆ SDL_size_mul_overflow()

SDL_FORCE_INLINE int SDL_size_mul_overflow ( size_t  a,
size_t  b,
size_t *  ret 
)

Multiply two integers, checking for overflow.

If a * b would overflow, return -1.

Otherwise store a * b via ret and return 0.

Parameters
athe multiplicand.
bthe multiplier.
reton non-overflow output, stores the multiplication result. May not be NULL.
Returns
-1 on overflow, 0 if result doesn't overflow.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

Definition at line 3027 of file SDL_stdinc.h.

3030{
3031 if (a != 0 && b > SDL_SIZE_MAX / a) {
3032 return -1;
3033 }
3034 *ret = a * b;
3035 return 0;
3036}

References SDL_SIZE_MAX.

◆ SDL_snprintf()

int SDL_snprintf ( SDL_OUT_Z_CAP(maxlen) char *  text,
size_t  maxlen,
SDL_PRINTF_FORMAT_STRING const char *  fmt,
  ... 
)
extern

◆ SDL_sqrt()

double SDL_sqrt ( double  x)
extern

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.

Parameters
xfloating point value. Must be greater than or equal to 0.
Returns
square root of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_sqrtf

◆ SDL_sqrtf()

float SDL_sqrtf ( float  x)
extern

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.

Parameters
xfloating point value. Must be greater than or equal to 0.
Returns
square root of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_sqrt

◆ SDL_srand()

void SDL_srand ( Uint64  seed)
extern

Seeds the pseudo-random number generator.

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

Parameters
seedthe value to use as a random number seed, or 0 to use SDL_GetPerformanceCounter().

\threadsafety This should be called on the same thread that calls SDL_rand*()

Since
This function is available since SDL 3.0.0.
See also
SDL_rand
SDL_rand_bits
SDL_randf

◆ SDL_sscanf()

int SDL_sscanf ( const char *  text,
SDL_SCANF_FORMAT_STRING const char *  fmt,
  ... 
)
extern

◆ SDL_StepUTF8()

Uint32 SDL_StepUTF8 ( const char **  pstr,
size_t *  pslen 
)
extern

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.

Parameters
pstra pointer to a UTF-8 string pointer to be read and adjusted.
pslena pointer to the number of bytes in the string, to be read and adjusted. NULL is allowed.
Returns
the first Unicode codepoint in the string.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_strcasecmp()

int SDL_strcasecmp ( const char *  str1,
const char *  str2 
)
extern

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.

Parameters
str1the first string to compare. NULL is not permitted!
str2the second string to compare. NULL is not permitted!
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_strcasestr()

char * SDL_strcasestr ( const char *  haystack,
const char *  needle 
)
extern

◆ SDL_strchr()

char * SDL_strchr ( const char *  str,
int  c 
)
extern

◆ SDL_strcmp()

int SDL_strcmp ( const char *  str1,
const char *  str2 
)
extern

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.

Parameters
str1the first string to compare. NULL is not permitted!
str2the second string to compare. NULL is not permitted!
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_strdup()

SDL_MALLOC char * SDL_strdup ( const char *  str)
extern

◆ SDL_strlcat()

size_t SDL_strlcat ( SDL_INOUT_Z_CAP(maxlen) char *  dst,
const char *  src,
size_t  maxlen 
)
extern

◆ SDL_strlcpy()

size_t SDL_strlcpy ( SDL_OUT_Z_CAP(maxlen) char *  dst,
const char *  src,
size_t  maxlen 
)
extern

◆ SDL_strlen()

size_t SDL_strlen ( const char *  str)
extern

◆ SDL_strlwr()

char * SDL_strlwr ( char *  str)
extern

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.

Parameters
strthe string to convert in-place. Can not be NULL.
Returns
the str pointer passed into this function.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_strupr

◆ SDL_strncasecmp()

int SDL_strncasecmp ( const char *  str1,
const char *  str2,
size_t  maxlen 
)
extern

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.

Parameters
str1the first string to compare. NULL is not permitted!
str2the second string to compare. NULL is not permitted!
maxlenthe maximum number of bytes to compare.
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_strncmp()

int SDL_strncmp ( const char *  str1,
const char *  str2,
size_t  maxlen 
)
extern

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.

Parameters
str1the first string to compare. NULL is not permitted!
str2the second string to compare. NULL is not permitted!
maxlenthe maximum number of bytes to compare.
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_strndup()

SDL_MALLOC char * SDL_strndup ( const char *  str,
size_t  maxlen 
)
extern

◆ SDL_strnlen()

size_t SDL_strnlen ( const char *  str,
size_t  maxlen 
)
extern

◆ SDL_strnstr()

char * SDL_strnstr ( const char *  haystack,
const char *  needle,
size_t  maxlen 
)
extern

◆ SDL_strrchr()

char * SDL_strrchr ( const char *  str,
int  c 
)
extern

◆ SDL_strrev()

char * SDL_strrev ( char *  str)
extern

◆ SDL_strstr()

char * SDL_strstr ( const char *  haystack,
const char *  needle 
)
extern

◆ SDL_strtod()

double SDL_strtod ( const char *  str,
char **  endp 
)
extern

◆ SDL_strtok_r()

char * SDL_strtok_r ( char *  s1,
const char *  s2,
char **  saveptr 
)
extern

◆ SDL_strtol()

long SDL_strtol ( const char *  str,
char **  endp,
int  base 
)
extern

◆ SDL_strtoll()

Sint64 SDL_strtoll ( const char *  str,
char **  endp,
int  base 
)
extern

◆ SDL_strtoul()

unsigned long SDL_strtoul ( const char *  str,
char **  endp,
int  base 
)
extern

◆ SDL_strtoull()

Uint64 SDL_strtoull ( const char *  str,
char **  endp,
int  base 
)
extern

◆ SDL_strupr()

char * SDL_strupr ( char *  str)
extern

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.

Parameters
strthe string to convert in-place. Can not be NULL.
Returns
the str pointer passed into this function.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_strlwr

◆ SDL_swprintf()

int SDL_swprintf ( SDL_OUT_Z_CAP(maxlen) wchar_t *  text,
size_t  maxlen,
SDL_PRINTF_FORMAT_STRING const wchar_t *  fmt,
  ... 
)
extern

◆ SDL_tan()

double SDL_tan ( double  x)
extern

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.

Parameters
xfloating point value, in radians.
Returns
tangent of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_tanf
SDL_sin
SDL_cos
SDL_atan
SDL_atan2

◆ SDL_tanf()

float SDL_tanf ( float  x)
extern

Compute the tangent of x.

Domain: -INF <= x <= INF

Range: -INF <= y <= INF

This function operates on single-precision floating point values, use SDL_tanf 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.

Parameters
xfloating point value, in radians.
Returns
tangent of x.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_tan
SDL_sinf
SDL_cosf
SDL_atanf
SDL_atan2f

◆ SDL_tolower()

int SDL_tolower ( int  x)
extern

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.

Parameters
xcharacter value to check.
Returns
lowercase version of x, or x if no conversion available.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_toupper()

int SDL_toupper ( int  x)
extern

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.

Parameters
xcharacter value to check.
Returns
capitalized version of x, or x if no conversion available.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_trunc()

double SDL_trunc ( double  x)
extern

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.

Parameters
xfloating point value.
Returns
x truncated to an integer.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_truncf
SDL_fmod
SDL_ceil
SDL_floor
SDL_round
SDL_lround

◆ SDL_truncf()

float SDL_truncf ( float  x)
extern

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_truncf for double-precision floats.

Parameters
xfloating point value.
Returns
x truncated to an integer.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.
See also
SDL_trunc
SDL_fmodf
SDL_ceilf
SDL_floorf
SDL_roundf
SDL_lroundf

◆ SDL_UCS4ToUTF8()

char * SDL_UCS4ToUTF8 ( Uint32  codepoint,
char *  dst 
)
extern

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.

Parameters
codepointa Unicode codepoint to convert to UTF-8.
dstthe location to write the encoded UTF-8. Must point to at least 4 bytes!
Returns
the first byte past the newly-written UTF-8 sequence.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_uitoa()

char * SDL_uitoa ( unsigned int  value,
char *  str,
int  radix 
)
extern

◆ SDL_ulltoa()

char * SDL_ulltoa ( Uint64  value,
char *  str,
int  radix 
)
extern

◆ SDL_ultoa()

char * SDL_ultoa ( unsigned long  value,
char *  str,
int  radix 
)
extern

◆ SDL_unsetenv()

int SDL_unsetenv ( const char *  name)
extern

◆ SDL_utf8strlcpy()

size_t SDL_utf8strlcpy ( SDL_OUT_Z_CAP(dst_bytes) char *  dst,
const char *  src,
size_t  dst_bytes 
)
extern

◆ SDL_utf8strlen()

size_t SDL_utf8strlen ( const char *  str)
extern

◆ SDL_utf8strnlen()

size_t SDL_utf8strnlen ( const char *  str,
size_t  bytes 
)
extern

◆ SDL_vasprintf()

int SDL_vasprintf ( char **  strp,
SDL_PRINTF_FORMAT_STRING const char *  fmt,
va_list  ap 
)
extern

◆ SDL_vsnprintf()

int SDL_vsnprintf ( SDL_OUT_Z_CAP(maxlen) char *  text,
size_t  maxlen,
SDL_PRINTF_FORMAT_STRING const char *  fmt,
va_list  ap 
)
extern

◆ SDL_vsscanf()

int SDL_vsscanf ( const char *  text,
SDL_SCANF_FORMAT_STRING const char *  fmt,
va_list  ap 
)
extern

◆ SDL_vswprintf()

int SDL_vswprintf ( SDL_OUT_Z_CAP(maxlen) wchar_t *  text,
size_t  maxlen,
const wchar_t *  fmt,
va_list  ap 
)
extern

◆ SDL_wcscasecmp()

int SDL_wcscasecmp ( const wchar_t *  str1,
const wchar_t *  str2 
)
extern

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.

Parameters
str1the first string to compare. NULL is not permitted!
str2the second string to compare. NULL is not permitted!
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_wcscmp()

int SDL_wcscmp ( const wchar_t *  str1,
const wchar_t *  str2 
)
extern

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.

Parameters
str1the first string to compare. NULL is not permitted!
str2the second string to compare. NULL is not permitted!
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_wcsdup()

wchar_t * SDL_wcsdup ( const wchar_t *  wstr)
extern

◆ SDL_wcslcat()

size_t SDL_wcslcat ( SDL_INOUT_Z_CAP(maxlen) wchar_t *  dst,
const wchar_t *  src,
size_t  maxlen 
)
extern

◆ SDL_wcslcpy()

size_t SDL_wcslcpy ( SDL_OUT_Z_CAP(maxlen) wchar_t *  dst,
const wchar_t *  src,
size_t  maxlen 
)
extern

◆ SDL_wcslen()

size_t SDL_wcslen ( const wchar_t *  wstr)
extern

◆ SDL_wcsncasecmp()

int SDL_wcsncasecmp ( const wchar_t *  str1,
const wchar_t *  str2,
size_t  maxlen 
)
extern

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.

Parameters
str1the first string to compare. NULL is not permitted!
str2the second string to compare. NULL is not permitted!
maxlenthe maximum number of wchar_t values to compare.
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_wcsncmp()

int SDL_wcsncmp ( const wchar_t *  str1,
const wchar_t *  str2,
size_t  maxlen 
)
extern

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.

Parameters
str1the first string to compare. NULL is not permitted!
str2the second string to compare. NULL is not permitted!
maxlenthe maximum number of wchar_t to compare.
Returns
less than zero if str1 is "less than" str2, greater than zero if str1 is "greater than" str2, and zero if the strings match exactly.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.0.0.

◆ SDL_wcsnlen()

size_t SDL_wcsnlen ( const wchar_t *  wstr,
size_t  maxlen 
)
extern

◆ SDL_wcsnstr()

wchar_t * SDL_wcsnstr ( const wchar_t *  haystack,
const wchar_t *  needle,
size_t  maxlen 
)
extern

◆ SDL_wcsstr()

wchar_t * SDL_wcsstr ( const wchar_t *  haystack,
const wchar_t *  needle 
)
extern

◆ SDL_wcstol()

long SDL_wcstol ( const wchar_t *  str,
wchar_t **  endp,
int  base 
)
extern

Variable Documentation

◆ size

size_t size

Definition at line 531 of file SDL_stdinc.h.