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)
 

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   ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */
 
#define SDL_MIN_SINT64   ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */
 
#define SDL_MAX_UINT64   ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */
 
#define SDL_MIN_UINT64   ((Uint64)(0x0000000000000000ull)) /* 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_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 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)
 
char * SDL_getenv (const char *name)
 
int SDL_setenv (const char *name, const char *value, int overwrite)
 
void SDL_qsort (void *base, size_t nmemb, size_t size, int(*compare)(const void *, const void *))
 
void * SDL_bsearch (const void *key, const void *base, size_t nmemb, size_t size, int(*compare)(const void *, const void *))
 
void SDL_qsort_r (void *base, size_t nmemb, size_t size, int(*compare)(void *, const void *, const void *), void *userdata)
 
void * SDL_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size, int(*compare)(void *, const void *, const void *), 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)
 
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)
 
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)
 
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)
 

Detailed Description

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.

Definition in file SDL_stdinc.h.

Macro Definition Documentation

◆ SDL_arraysize

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

The number of elements in an array.

NOTE: This macro double-evaluates the argument, so you should never have side effects in the parameter.

Since
This macro is available since SDL 3.0.0.

Definition at line 99 of file SDL_stdinc.h.

◆ SDL_clamp

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

Definition at line 578 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 417 of file SDL_stdinc.h.

445{
446 DUMMY_ENUM_VALUE
447} SDL_DUMMY_ENUM;
448
449SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
450#endif
451#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
452/** \endcond */
453
454#include <SDL3/SDL_begin_code.h>
455/* Set up for C function definitions, even when using C++ */
456#ifdef __cplusplus
457extern "C" {
458#endif
459
460#ifndef SDL_DISABLE_ALLOCA
461#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count))
462#define SDL_stack_free(data)
463#else
464#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count))
465#define SDL_stack_free(data) SDL_free(data)
466#endif
467
468extern DECLSPEC SDL_MALLOC void *SDLCALL SDL_malloc(size_t size);
469extern DECLSPEC SDL_MALLOC SDL_ALLOC_SIZE2(1, 2) void *SDLCALL SDL_calloc(size_t nmemb, size_t size);
470extern DECLSPEC SDL_ALLOC_SIZE(2) void *SDLCALL SDL_realloc(void *mem, size_t size);
471extern DECLSPEC void SDLCALL SDL_free(void *mem);
472
473typedef void *(SDLCALL *SDL_malloc_func)(size_t size);
474typedef void *(SDLCALL *SDL_calloc_func)(size_t nmemb, size_t size);
475typedef void *(SDLCALL *SDL_realloc_func)(void *mem, size_t size);
476typedef void (SDLCALL *SDL_free_func)(void *mem);
477
478/**
479 * Get the original set of SDL memory functions.
480 *
481 * \param malloc_func filled with malloc function
482 * \param calloc_func filled with calloc function
483 * \param realloc_func filled with realloc function
484 * \param free_func filled with free function
485 *
486 * \since This function is available since SDL 3.0.0.
487 */
488extern DECLSPEC void SDLCALL SDL_GetOriginalMemoryFunctions(SDL_malloc_func *malloc_func,
489 SDL_calloc_func *calloc_func,
490 SDL_realloc_func *realloc_func,
491 SDL_free_func *free_func);
492
493/**
494 * Get the current set of SDL memory functions.
495 *
496 * \param malloc_func filled with malloc function
497 * \param calloc_func filled with calloc function
498 * \param realloc_func filled with realloc function
499 * \param free_func filled with free function
500 *
501 * \since This function is available since SDL 3.0.0.
502 */
503extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func,
504 SDL_calloc_func *calloc_func,
505 SDL_realloc_func *realloc_func,
506 SDL_free_func *free_func);
507
508/**
509 * Replace SDL's memory allocation functions with a custom set.
510 *
511 * \param malloc_func custom malloc function
512 * \param calloc_func custom calloc function
513 * \param realloc_func custom realloc function
514 * \param free_func custom free function
515 * \returns 0 on success or a negative error code on failure; call
516 * SDL_GetError() for more information.
517 *
518 * \since This function is available since SDL 3.0.0.
519 */
520extern DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
521 SDL_calloc_func calloc_func,
522 SDL_realloc_func realloc_func,
523 SDL_free_func free_func);
524
525/**
526 * Allocate memory aligned to a specific value.
527 *
528 * If `alignment` is less than the size of `void *`, then it will be increased
529 * to match that.
530 *
531 * The returned memory address will be a multiple of the alignment value, and
532 * the amount of memory allocated will be a multiple of the alignment value.
533 *
534 * The memory returned by this function must be freed with SDL_aligned_free()
535 *
536 * \param alignment the alignment requested
537 * \param size the size to allocate
538 * \returns a pointer to the aligned memory
539 *
540 * \since This function is available since SDL 3.0.0.
541 *
542 * \sa SDL_aligned_free
543 */
544extern DECLSPEC SDL_MALLOC void *SDLCALL SDL_aligned_alloc(size_t alignment, size_t size);
545
546/**
547 * Free memory allocated by SDL_aligned_alloc().
548 *
549 * \since This function is available since SDL 3.0.0.
550 *
551 * \sa SDL_aligned_alloc
552 */
553extern DECLSPEC void SDLCALL SDL_aligned_free(void *mem);
554
555/**
556 * Get the number of outstanding (unfreed) allocations.
557 *
558 * \returns the number of allocations
559 *
560 * \since This function is available since SDL 3.0.0.
561 */
562extern DECLSPEC int SDLCALL SDL_GetNumAllocations(void);
563
564extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
565extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
566
567extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *));
568extern DECLSPEC void * SDLCALL SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *));
569
570extern DECLSPEC void SDLCALL SDL_qsort_r(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (void *, const void *, const void *), void *userdata);
571extern DECLSPEC void * SDLCALL SDL_bsearch_r(const void *key, const void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (void *, const void *, const void *), void *userdata);
572
573extern DECLSPEC int SDLCALL SDL_abs(int x);
574
575/* NOTE: these double-evaluate their arguments, so you should never have side effects in the parameters */
576#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
577#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
578#define SDL_clamp(x, a, b) (((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x)))
579
580/**
581 * Query if a character is alphabetic (a letter).
582 *
583 * **WARNING**: Regardless of system locale, this will only treat ASCII values
584 * for English 'a-z' and 'A-Z' as true.
585 *
586 * \param x character value to check.
587 * \returns non-zero if x falls within the character class, zero otherwise.
588 *
589 * \threadsafety It is safe to call this function from any thread.
590 *
591 * \since This function is available since SDL 3.0.0.
592 */
593extern DECLSPEC int SDLCALL SDL_isalpha(int x);
594
595/**
596 * Query if a character is alphabetic (a letter) or a number.
597 *
598 * **WARNING**: Regardless of system locale, this will only treat ASCII values
599 * for English 'a-z', 'A-Z', and '0-9' as true.
600 *
601 * \param x character value to check.
602 * \returns non-zero if x falls within the character class, zero otherwise.
603 *
604 * \threadsafety It is safe to call this function from any thread.
605 *
606 * \since This function is available since SDL 3.0.0.
607 */
608extern DECLSPEC int SDLCALL SDL_isalnum(int x);
609
610/**
611 * Report if a character is blank (a space or tab).
612 *
613 * **WARNING**: Regardless of system locale, this will only treat ASCII values
614 * 0x20 (space) or 0x9 (tab) as true.
615 *
616 * \param x character value to check.
617 * \returns non-zero if x falls within the character class, zero otherwise.
618 *
619 * \threadsafety It is safe to call this function from any thread.
620 *
621 * \since This function is available since SDL 3.0.0.
622 */
623extern DECLSPEC int SDLCALL SDL_isblank(int x);
624
625/**
626 * Report if a character is a control character.
627 *
628 * **WARNING**: Regardless of system locale, this will only treat ASCII values
629 * 0 through 0x1F, and 0x7F, as true.
630 *
631 * \param x character value to check.
632 * \returns non-zero if x falls within the character class, zero otherwise.
633 *
634 * \threadsafety It is safe to call this function from any thread.
635 *
636 * \since This function is available since SDL 3.0.0.
637 */
638extern DECLSPEC int SDLCALL SDL_iscntrl(int x);
639
640/**
641 * Report if a character is a numeric digit.
642 *
643 * **WARNING**: Regardless of system locale, this will only treat ASCII values
644 * '0' (0x30) through '9' (0x39), as true.
645 *
646 * \param x character value to check.
647 * \returns non-zero if x falls within the character class, zero otherwise.
648 *
649 * \threadsafety It is safe to call this function from any thread.
650 *
651 * \since This function is available since SDL 3.0.0.
652 */
653extern DECLSPEC int SDLCALL SDL_isdigit(int x);
654
655/**
656 * Report if a character is a hexadecimal digit.
657 *
658 * **WARNING**: Regardless of system locale, this will only treat ASCII values
659 * 'A' through 'F', 'a' through 'f', and '0' through '9', as true.
660 *
661 * \param x character value to check.
662 * \returns non-zero if x falls within the character class, zero otherwise.
663 *
664 * \threadsafety It is safe to call this function from any thread.
665 *
666 * \since This function is available since SDL 3.0.0.
667 */
668extern DECLSPEC int SDLCALL SDL_isxdigit(int x);
669
670/**
671 * Report if a character is a punctuation mark.
672 *
673 * **WARNING**: Regardless of system locale, this is equivalent to
674 * `((SDL_isgraph(x)) && (!SDL_isalnum(x)))`.
675 *
676 * \param x character value to check.
677 * \returns non-zero if x falls within the character class, zero otherwise.
678 *
679 * \threadsafety It is safe to call this function from any thread.
680 *
681 * \since This function is available since SDL 3.0.0.
682 *
683 * \sa SDL_isgraph
684 * \sa SDL_isalnum
685 */
686extern DECLSPEC int SDLCALL SDL_ispunct(int x);
687
688/**
689 * Report if a character is whitespace.
690 *
691 * **WARNING**: Regardless of system locale, this will only treat the
692 * following ASCII values as true:
693 *
694 * - space (0x20)
695 * - tab (0x09)
696 * - newline (0x0A)
697 * - vertical tab (0x0B)
698 * - form feed (0x0C)
699 * - return (0x0D)
700 *
701 * \param x character value to check.
702 * \returns non-zero if x falls within the character class, zero otherwise.
703 *
704 * \threadsafety It is safe to call this function from any thread.
705 *
706 * \since This function is available since SDL 3.0.0.
707 */
708extern DECLSPEC int SDLCALL SDL_isspace(int x);
709
710/**
711 * Report if a character is upper case.
712 *
713 * **WARNING**: Regardless of system locale, this will only treat ASCII values
714 * 'A' through 'Z' as true.
715 *
716 * \param x character value to check.
717 * \returns non-zero if x falls within the character class, zero otherwise.
718 *
719 * \threadsafety It is safe to call this function from any thread.
720 *
721 * \since This function is available since SDL 3.0.0.
722 */
723extern DECLSPEC int SDLCALL SDL_isupper(int x);
724
725/**
726 * Report if a character is lower case.
727 *
728 * **WARNING**: Regardless of system locale, this will only treat ASCII values
729 * 'a' through 'z' as true.
730 *
731 * \param x character value to check.
732 * \returns non-zero if x falls within the character class, zero otherwise.
733 *
734 * \threadsafety It is safe to call this function from any thread.
735 *
736 * \since This function is available since SDL 3.0.0.
737 */
738extern DECLSPEC int SDLCALL SDL_islower(int x);
739
740/**
741 * Report if a character is "printable".
742 *
743 * Be advised that "printable" has a definition that goes back to text
744 * terminals from the dawn of computing, making this a sort of special case
745 * function that is not suitable for Unicode (or most any) text management.
746 *
747 * **WARNING**: Regardless of system locale, this will only treat ASCII values
748 * ' ' (0x20) through '~' (0x7E) as true.
749 *
750 * \param x character value to check.
751 * \returns non-zero if x falls within the character class, zero otherwise.
752 *
753 * \threadsafety It is safe to call this function from any thread.
754 *
755 * \since This function is available since SDL 3.0.0.
756 */
757extern DECLSPEC int SDLCALL SDL_isprint(int x);
758
759/**
760 * Report if a character is any "printable" except space.
761 *
762 * Be advised that "printable" has a definition that goes back to text
763 * terminals from the dawn of computing, making this a sort of special case
764 * function that is not suitable for Unicode (or most any) text management.
765 *
766 * **WARNING**: Regardless of system locale, this is equivalent to
767 * `(SDL_isprint(x)) && ((x) != ' ')`.
768 *
769 * \param x character value to check.
770 * \returns non-zero if x falls within the character class, zero otherwise.
771 *
772 * \threadsafety It is safe to call this function from any thread.
773 *
774 * \since This function is available since SDL 3.0.0.
775 *
776 * \sa SDL_isprint
777 */
778extern DECLSPEC int SDLCALL SDL_isgraph(int x);
779
780/**
781 * Convert low-ASCII English letters to uppercase.
782 *
783 * **WARNING**: Regardless of system locale, this will only convert ASCII
784 * values 'a' through 'z' to uppercase.
785 *
786 * This function returns the uppercase equivalent of `x`. If a character
787 * cannot be converted, or is already uppercase, this function returns `x`.
788 *
789 * \param x character value to check.
790 * \returns Capitalized version of x, or x if no conversion available.
791 *
792 * \threadsafety It is safe to call this function from any thread.
793 *
794 * \since This function is available since SDL 3.0.0.
795 */
796extern DECLSPEC int SDLCALL SDL_toupper(int x);
797
798/**
799 * Convert low-ASCII English letters to lowercase.
800 *
801 * **WARNING**: Regardless of system locale, this will only convert ASCII
802 * values 'A' through 'Z' to lowercase.
803 *
804 * This function returns the lowercase equivalent of `x`. If a character
805 * cannot be converted, or is already lowercase, this function returns `x`.
806 *
807 * \param x character value to check.
808 * \returns Lowercase version of x, or x if no conversion available.
809 *
810 * \threadsafety It is safe to call this function from any thread.
811 *
812 * \since This function is available since SDL 3.0.0.
813 */
814extern DECLSPEC int SDLCALL SDL_tolower(int x);
815
816extern DECLSPEC Uint16 SDLCALL SDL_crc16(Uint16 crc, const void *data, size_t len);
817extern DECLSPEC Uint32 SDLCALL SDL_crc32(Uint32 crc, const void *data, size_t len);
818
819extern DECLSPEC void *SDLCALL SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
820
821/* Take advantage of compiler optimizations for memcpy */
822#ifndef SDL_SLOW_MEMCPY
823#ifdef SDL_memcpy
824#undef SDL_memcpy
825#endif
826#define SDL_memcpy memcpy
827#endif
828
829#define SDL_copyp(dst, src) \
830 { SDL_COMPILE_TIME_ASSERT(SDL_copyp, sizeof (*(dst)) == sizeof (*(src))); } \
831 SDL_memcpy((dst), (src), sizeof(*(src)))
832
833extern DECLSPEC void *SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
834
835/* Take advantage of compiler optimizations for memmove */
836#ifndef SDL_SLOW_MEMMOVE
837#ifdef SDL_memmove
838#undef SDL_memmove
839#endif
840#define SDL_memmove memmove
841#endif
842
843extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len);
844extern DECLSPEC void *SDLCALL SDL_memset4(void *dst, Uint32 val, size_t dwords);
845
846/* Take advantage of compiler optimizations for memset */
847#ifndef SDL_SLOW_MEMSET
848#ifdef SDL_memset
849#undef SDL_memset
850#endif
851#define SDL_memset memset
852#endif
853
854#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
855#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
856#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x)))
857
858extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
859
860extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr);
861extern DECLSPEC size_t SDLCALL SDL_wcsnlen(const wchar_t *wstr, size_t maxlen);
862extern DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen);
863extern DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen);
864extern DECLSPEC wchar_t *SDLCALL SDL_wcsdup(const wchar_t *wstr);
865extern DECLSPEC wchar_t *SDLCALL SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle);
866extern DECLSPEC wchar_t *SDLCALL SDL_wcsnstr(const wchar_t *haystack, const wchar_t *needle, size_t maxlen);
867
868/**
869 * Compare two null-terminated wide strings.
870 *
871 * This only compares wchar_t values until it hits a null-terminating
872 * character; it does not care if the string is well-formed UTF-16 (or UTF-32,
873 * depending on your platform's wchar_t size), or uses valid Unicode values.
874 *
875 * \param str1 The first string to compare. NULL is not permitted!
876 * \param str2 The second string to compare. NULL is not permitted!
877 * \returns less than zero if str1 is "less than" str2, greater than zero if
878 * str1 is "greater than" str2, and zero if the strings match
879 * exactly.
880 *
881 * \threadsafety It is safe to call this function from any thread.
882 *
883 * \since This function is available since SDL 3.0.0.
884 */
885extern DECLSPEC int SDLCALL SDL_wcscmp(const wchar_t *str1, const wchar_t *str2);
886
887/**
888 * Compare two wide strings up to a number of wchar_t values.
889 *
890 * This only compares wchar_t values; it does not care if the string is
891 * well-formed UTF-16 (or UTF-32, depending on your platform's wchar_t size),
892 * or uses valid Unicode values.
893 *
894 * Note that while this function is intended to be used with UTF-16 (or
895 * UTF-32, depending on your platform's definition of wchar_t), it is
896 * comparing raw wchar_t values and not Unicode codepoints: `maxlen` specifies
897 * a wchar_t limit! If the limit lands in the middle of a multi-wchar UTF-16
898 * sequence, it will only compare a portion of the final character.
899 *
900 * `maxlen` specifies a maximum number of wchar_t to compare; if the strings
901 * match to this number of wide chars (or both have matched to a
902 * null-terminator character before this count), they will be considered
903 * equal.
904 *
905 * \param str1 The first string to compare. NULL is not permitted!
906 * \param str2 The second string to compare. NULL is not permitted!
907 * \param maxlen The maximum number of wchar_t to compare.
908 * \returns less than zero if str1 is "less than" str2, greater than zero if
909 * str1 is "greater than" str2, and zero if the strings match
910 * exactly.
911 *
912 * \threadsafety It is safe to call this function from any thread.
913 *
914 * \since This function is available since SDL 3.0.0.
915 */
916extern DECLSPEC int SDLCALL SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen);
917
918/**
919 * Compare two null-terminated wide strings, case-insensitively.
920 *
921 * This will work with Unicode strings, using a technique called
922 * "case-folding" to handle the vast majority of case-sensitive human
923 * languages regardless of system locale. It can deal with expanding values: a
924 * German Eszett character can compare against two ASCII 's' chars and be
925 * considered a match, for example. A notable exception: it does not handle
926 * the Turkish 'i' character; human language is complicated!
927 *
928 * Depending on your platform, "wchar_t" might be 2 bytes, and expected to be
929 * UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this
930 * handles Unicode, it expects the string to be well-formed and not a
931 * null-terminated string of arbitrary bytes. Characters that are not valid
932 * UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT
933 * CHARACTER), which is to say two strings of random bits may turn out to
934 * match if they convert to the same amount of replacement characters.
935 *
936 * \param str1 The first string to compare. NULL is not permitted!
937 * \param str2 The second string to compare. NULL is not permitted!
938 * \returns less than zero if str1 is "less than" str2, greater than zero if
939 * str1 is "greater than" str2, and zero if the strings match
940 * exactly.
941 *
942 * \threadsafety It is safe to call this function from any thread.
943 *
944 * \since This function is available since SDL 3.0.0.
945 */
946extern DECLSPEC int SDLCALL SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2);
947
948/**
949 * Compare two wide strings, case-insensitively, up to a number of wchar_t.
950 *
951 * This will work with Unicode strings, using a technique called
952 * "case-folding" to handle the vast majority of case-sensitive human
953 * languages regardless of system locale. It can deal with expanding values: a
954 * German Eszett character can compare against two ASCII 's' chars and be
955 * considered a match, for example. A notable exception: it does not handle
956 * the Turkish 'i' character; human language is complicated!
957 *
958 * Depending on your platform, "wchar_t" might be 2 bytes, and expected to be
959 * UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this
960 * handles Unicode, it expects the string to be well-formed and not a
961 * null-terminated string of arbitrary bytes. Characters that are not valid
962 * UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT
963 * CHARACTER), which is to say two strings of random bits may turn out to
964 * match if they convert to the same amount of replacement characters.
965 *
966 * Note that while this function might deal with variable-sized characters,
967 * `maxlen` specifies a _wchar_ limit! If the limit lands in the middle of a
968 * multi-byte UTF-16 sequence, it may convert a portion of the final character
969 * to one or more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not
970 * to overflow a buffer.
971 *
972 * `maxlen` specifies a maximum number of wchar_t values to compare; if the
973 * strings match to this number of wchar_t (or both have matched to a
974 * null-terminator character before this number of bytes), they will be
975 * considered equal.
976 *
977 * \param str1 The first string to compare. NULL is not permitted!
978 * \param str2 The second string to compare. NULL is not permitted!
979 * \param maxlen The maximum number of wchar_t values to compare.
980 * \returns less than zero if str1 is "less than" str2, greater than zero if
981 * str1 is "greater than" str2, and zero if the strings match
982 * exactly.
983 *
984 * \threadsafety It is safe to call this function from any thread.
985 *
986 * \since This function is available since SDL 3.0.0.
987 */
988extern DECLSPEC int SDLCALL SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen);
989
990extern DECLSPEC long SDLCALL SDL_wcstol(const wchar_t *str, wchar_t **endp, int base);
991
992extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str);
993extern DECLSPEC size_t SDLCALL SDL_strnlen(const char *str, size_t maxlen);
994extern DECLSPEC size_t SDLCALL SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen);
995extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes);
996extern DECLSPEC size_t SDLCALL SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen);
997extern DECLSPEC SDL_MALLOC char *SDLCALL SDL_strdup(const char *str);
998extern DECLSPEC SDL_MALLOC char *SDLCALL SDL_strndup(const char *str, size_t maxlen);
999extern DECLSPEC char *SDLCALL SDL_strrev(char *str);
1000
1001/**
1002 * Convert a string to uppercase.
1003 *
1004 * **WARNING**: Regardless of system locale, this will only convert ASCII
1005 * values 'A' through 'Z' to uppercase.
1006 *
1007 * This function operates on a null-terminated string of bytes--even if it is
1008 * malformed UTF-8!--and converts ASCII characters 'a' through 'z' to their
1009 * uppercase equivalents in-place, returning the original `str` pointer.
1010 *
1011 * \threadsafety It is safe to call this function from any thread.
1012 *
1013 * \since This function is available since SDL 3.0.0.
1014 *
1015 * \sa SDL_strlwr
1016 */
1017extern DECLSPEC char *SDLCALL SDL_strupr(char *str);
1018
1019/**
1020 * Convert a string to lowercase.
1021 *
1022 * **WARNING**: Regardless of system locale, this will only convert ASCII
1023 * values 'A' through 'Z' to lowercase.
1024 *
1025 * This function operates on a null-terminated string of bytes--even if it is
1026 * malformed UTF-8!--and converts ASCII characters 'A' through 'Z' to their
1027 * lowercase equivalents in-place, returning the original `str` pointer.
1028 *
1029 * \param str The string to convert in-place.
1030 * \returns The `str` pointer passed into this function.
1031 *
1032 * \threadsafety It is safe to call this function from any thread.
1033 *
1034 * \since This function is available since SDL 3.0.0.
1035 *
1036 * \sa SDL_strupr
1037 */
1038extern DECLSPEC char *SDLCALL SDL_strlwr(char *str);
1039
1040extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
1041extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
1042extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
1043extern DECLSPEC char *SDLCALL SDL_strnstr(const char *haystack, const char *needle, size_t maxlen);
1044extern DECLSPEC char *SDLCALL SDL_strcasestr(const char *haystack, const char *needle);
1045extern DECLSPEC char *SDLCALL SDL_strtok_r(char *s1, const char *s2, char **saveptr);
1046extern DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str);
1047extern DECLSPEC size_t SDLCALL SDL_utf8strnlen(const char *str, size_t bytes);
1048
1049extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix);
1050extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix);
1051extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix);
1052extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *str, int radix);
1053extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *str, int radix);
1054extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix);
1055
1056extern DECLSPEC int SDLCALL SDL_atoi(const char *str);
1057extern DECLSPEC double SDLCALL SDL_atof(const char *str);
1058extern DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base);
1059extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base);
1060extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base);
1061extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base);
1062extern DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp);
1063
1064/**
1065 * Compare two null-terminated UTF-8 strings.
1066 *
1067 * Due to the nature of UTF-8 encoding, this will work with Unicode strings,
1068 * since effectively this function just compares bytes until it hits a
1069 * null-terminating character. Also due to the nature of UTF-8, this can be
1070 * used with SDL_qsort() to put strings in (roughly) alphabetical order.
1071 *
1072 * \param str1 The first string to compare. NULL is not permitted!
1073 * \param str2 The second string to compare. NULL is not permitted!
1074 * \returns less than zero if str1 is "less than" str2, greater than zero if
1075 * str1 is "greater than" str2, and zero if the strings match
1076 * exactly.
1077 *
1078 * \threadsafety It is safe to call this function from any thread.
1079 *
1080 * \since This function is available since SDL 3.0.0.
1081 */
1082extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
1083
1084/**
1085 * Compare two UTF-8 strings up to a number of bytes.
1086 *
1087 * Due to the nature of UTF-8 encoding, this will work with Unicode strings,
1088 * since effectively this function just compares bytes until it hits a
1089 * null-terminating character. Also due to the nature of UTF-8, this can be
1090 * used with SDL_qsort() to put strings in (roughly) alphabetical order.
1091 *
1092 * Note that while this function is intended to be used with UTF-8, it is
1093 * doing a bytewise comparison, and `maxlen` specifies a _byte_ limit! If the
1094 * limit lands in the middle of a multi-byte UTF-8 sequence, it will only
1095 * compare a portion of the final character.
1096 *
1097 * `maxlen` specifies a maximum number of bytes to compare; if the strings
1098 * match to this number of bytes (or both have matched to a null-terminator
1099 * character before this number of bytes), they will be considered equal.
1100 *
1101 * \param str1 The first string to compare. NULL is not permitted!
1102 * \param str2 The second string to compare. NULL is not permitted!
1103 * \param maxlen The maximum number of _bytes_ to compare.
1104 * \returns less than zero if str1 is "less than" str2, greater than zero if
1105 * str1 is "greater than" str2, and zero if the strings match
1106 * exactly.
1107 *
1108 * \threadsafety It is safe to call this function from any thread.
1109 *
1110 * \since This function is available since SDL 3.0.0.
1111 */
1112extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
1113
1114/**
1115 * Compare two null-terminated UTF-8 strings, case-insensitively.
1116 *
1117 * This will work with Unicode strings, using a technique called
1118 * "case-folding" to handle the vast majority of case-sensitive human
1119 * languages regardless of system locale. It can deal with expanding values: a
1120 * German Eszett character can compare against two ASCII 's' chars and be
1121 * considered a match, for example. A notable exception: it does not handle
1122 * the Turkish 'i' character; human language is complicated!
1123 *
1124 * Since this handles Unicode, it expects the string to be well-formed UTF-8
1125 * and not a null-terminated string of arbitrary bytes. Bytes that are not
1126 * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT
1127 * CHARACTER), which is to say two strings of random bits may turn out to
1128 * match if they convert to the same amount of replacement characters.
1129 *
1130 * \param str1 The first string to compare. NULL is not permitted!
1131 * \param str2 The second string to compare. NULL is not permitted!
1132 * \returns less than zero if str1 is "less than" str2, greater than zero if
1133 * str1 is "greater than" str2, and zero if the strings match
1134 * exactly.
1135 *
1136 * \threadsafety It is safe to call this function from any thread.
1137 *
1138 * \since This function is available since SDL 3.0.0.
1139 */
1140extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
1141
1142
1143/**
1144 * Compare two UTF-8 strings, case-insensitively, up to a number of bytes.
1145 *
1146 * This will work with Unicode strings, using a technique called
1147 * "case-folding" to handle the vast majority of case-sensitive human
1148 * languages regardless of system locale. It can deal with expanding values: a
1149 * German Eszett character can compare against two ASCII 's' chars and be
1150 * considered a match, for example. A notable exception: it does not handle
1151 * the Turkish 'i' character; human language is complicated!
1152 *
1153 * Since this handles Unicode, it expects the string to be well-formed UTF-8
1154 * and not a null-terminated string of arbitrary bytes. Bytes that are not
1155 * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT
1156 * CHARACTER), which is to say two strings of random bits may turn out to
1157 * match if they convert to the same amount of replacement characters.
1158 *
1159 * Note that while this function is intended to be used with UTF-8, `maxlen`
1160 * specifies a _byte_ limit! If the limit lands in the middle of a multi-byte
1161 * UTF-8 sequence, it may convert a portion of the final character to one or
1162 * more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not to overflow
1163 * a buffer.
1164 *
1165 * `maxlen` specifies a maximum number of bytes to compare; if the strings
1166 * match to this number of bytes (or both have matched to a null-terminator
1167 * character before this number of bytes), they will be considered equal.
1168 *
1169 * \param str1 The first string to compare. NULL is not permitted!
1170 * \param str2 The second string to compare. NULL is not permitted!
1171 * \param maxlen The maximum number of bytes to compare.
1172 * \returns less than zero if str1 is "less than" str2, greater than zero if
1173 * str1 is "greater than" str2, and zero if the strings match
1174 * exactly.
1175 *
1176 * \threadsafety It is safe to call this function from any thread.
1177 *
1178 * \since This function is available since SDL 3.0.0.
1179 */
1180extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen);
1181
1182extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2);
1183extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap) SDL_SCANF_VARARG_FUNCV(2);
1184extern 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);
1185extern 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);
1186extern 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);
1187extern DECLSPEC int SDLCALL SDL_vswprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, const wchar_t *fmt, va_list ap);
1188extern DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
1189extern DECLSPEC int SDLCALL SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2);
1190
1191#ifndef SDL_PI_D
1192#define SDL_PI_D 3.141592653589793238462643383279502884 /**< pi (double) */
1193#endif
1194#ifndef SDL_PI_F
1195#define SDL_PI_F 3.141592653589793238462643383279502884F /**< pi (float) */
1196#endif
1197
1198/**
1199 * Compute the arc cosine of `x`.
1200 *
1201 * The definition of `y = acos(x)` is `x = cos(y)`.
1202 *
1203 * Domain: `-1 <= x <= 1`
1204 *
1205 * Range: `0 <= y <= Pi`
1206 *
1207 * This function operates on double-precision floating point values, use
1208 * SDL_acosf for single-precision floats.
1209 *
1210 * This function may use a different approximation across different versions,
1211 * platforms and configurations. i.e, it can return a different value given
1212 * the same input on different machines or operating systems, or if SDL is
1213 * updated.
1214 *
1215 * \param x floating point value
1216 * \returns arc cosine of `x`, in radians
1217 *
1218 * \threadsafety It is safe to call this function from any thread.
1219 *
1220 * \since This function is available since SDL 3.0.0.
1221 *
1222 * \sa SDL_acosf
1223 * \sa SDL_asin
1224 * \sa SDL_cos
1225 */
1226extern DECLSPEC double SDLCALL SDL_acos(double x);
1227
1228/**
1229 * Compute the arc cosine of `x`.
1230 *
1231 * The definition of `y = acos(x)` is `x = cos(y)`.
1232 *
1233 * Domain: `-1 <= x <= 1`
1234 *
1235 * Range: `0 <= y <= Pi`
1236 *
1237 * This function operates on single-precision floating point values, use
1238 * SDL_acos for double-precision floats.
1239 *
1240 * This function may use a different approximation across different versions,
1241 * platforms and configurations. i.e, it can return a different value given
1242 * the same input on different machines or operating systems, or if SDL is
1243 * updated.
1244 *
1245 * \param x floating point value.
1246 * \returns arc cosine of `x`, in radians
1247 *
1248 * \since This function is available since SDL 3.0.0.
1249 *
1250 * \sa SDL_acos
1251 * \sa SDL_asinf
1252 * \sa SDL_cosf
1253 */
1254extern DECLSPEC float SDLCALL SDL_acosf(float x);
1255
1256/**
1257 * Compute the arc sine of `x`.
1258 *
1259 * The definition of `y = asin(x)` is `x = sin(y)`.
1260 *
1261 * Domain: `-1 <= x <= 1`
1262 *
1263 * Range: `-Pi/2 <= y <= Pi/2`
1264 *
1265 * This function operates on double-precision floating point values, use
1266 * SDL_asinf for single-precision floats.
1267 *
1268 * This function may use a different approximation across different versions,
1269 * platforms and configurations. i.e, it can return a different value given
1270 * the same input on different machines or operating systems, or if SDL is
1271 * updated.
1272 *
1273 * \param x floating point value.
1274 * \returns arc sine of `x`, in radians.
1275 *
1276 * \since This function is available since SDL 3.0.0.
1277 *
1278 * \sa SDL_asinf
1279 * \sa SDL_acos
1280 * \sa SDL_sin
1281 */
1282extern DECLSPEC double SDLCALL SDL_asin(double x);
1283
1284/**
1285 * Compute the arc sine of `x`.
1286 *
1287 * The definition of `y = asin(x)` is `x = sin(y)`.
1288 *
1289 * Domain: `-1 <= x <= 1`
1290 *
1291 * Range: `-Pi/2 <= y <= Pi/2`
1292 *
1293 * This function operates on single-precision floating point values, use
1294 * SDL_asin for double-precision floats.
1295 *
1296 * This function may use a different approximation across different versions,
1297 * platforms and configurations. i.e, it can return a different value given
1298 * the same input on different machines or operating systems, or if SDL is
1299 * updated.
1300 *
1301 * \param x floating point value.
1302 * \returns arc sine of `x`, in radians.
1303 *
1304 * \since This function is available since SDL 3.0.0.
1305 *
1306 * \sa SDL_asin
1307 * \sa SDL_acosf
1308 * \sa SDL_sinf
1309 */
1310extern DECLSPEC float SDLCALL SDL_asinf(float x);
1311
1312/**
1313 * Compute the arc tangent of `x`.
1314 *
1315 * The definition of `y = atan(x)` is `x = tan(y)`.
1316 *
1317 * Domain: `-INF <= x <= INF`
1318 *
1319 * Range: `-Pi/2 <= y <= Pi/2`
1320 *
1321 * This function operates on double-precision floating point values, use
1322 * SDL_atanf for single-precision floats.
1323 *
1324 * To calculate the arc tangent of y / x, use SDL_atan2.
1325 *
1326 * This function may use a different approximation across different versions,
1327 * platforms and configurations. i.e, it can return a different value given
1328 * the same input on different machines or operating systems, or if SDL is
1329 * updated.
1330 *
1331 * \param x floating point value.
1332 * \returns arc tangent of of `x` in radians, or 0 if `x = 0`.
1333 *
1334 * \since This function is available since SDL 3.0.0.
1335 *
1336 * \sa SDL_atanf
1337 * \sa SDL_atan2
1338 * \sa SDL_tan
1339 */
1340extern DECLSPEC double SDLCALL SDL_atan(double x);
1341
1342/**
1343 * Compute the arc tangent of `x`.
1344 *
1345 * The definition of `y = atan(x)` is `x = tan(y)`.
1346 *
1347 * Domain: `-INF <= x <= INF`
1348 *
1349 * Range: `-Pi/2 <= y <= Pi/2`
1350 *
1351 * This function operates on single-precision floating point values, use
1352 * SDL_atan for dboule-precision floats.
1353 *
1354 * To calculate the arc tangent of y / x, use SDL_atan2f.
1355 *
1356 * This function may use a different approximation across different versions,
1357 * platforms and configurations. i.e, it can return a different value given
1358 * the same input on different machines or operating systems, or if SDL is
1359 * updated.
1360 *
1361 * \param x floating point value.
1362 * \returns arc tangent of of `x` in radians, or 0 if `x = 0`
1363 *
1364 * \since This function is available since SDL 3.0.0.
1365 *
1366 * \sa SDL_atan
1367 * \sa SDL_atan2f
1368 * \sa SDL_tanf
1369 */
1370extern DECLSPEC float SDLCALL SDL_atanf(float x);
1371
1372/**
1373 * Compute the arc tangent of `y / x`, using the signs of x and y to adjust
1374 * the result's quadrant.
1375 *
1376 * The definition of `z = atan2(x, y)` is `y = x tan(z)`, where the quadrant
1377 * of z is determined based on the signs of x and y.
1378 *
1379 * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
1380 *
1381 * Range: `-Pi/2 <= y <= Pi/2`
1382 *
1383 * This function operates on double-precision floating point values, use
1384 * SDL_atan2f for single-precision floats.
1385 *
1386 * To calculate the arc tangent of a single value, use SDL_atan.
1387 *
1388 * This function may use a different approximation across different versions,
1389 * platforms and configurations. i.e, it can return a different value given
1390 * the same input on different machines or operating systems, or if SDL is
1391 * updated.
1392 *
1393 * \param x floating point value of the denominator (x coordinate).
1394 * \param y floating point value of the numerator (y coordinate)
1395 * \returns arc tangent of of `y / x` in radians, or, if `x = 0`, either
1396 * `-Pi/2`, `0`, or `Pi/2`, depending on the value of `y`.
1397 *
1398 * \since This function is available since SDL 3.0.0.
1399 *
1400 * \sa SDL_atan2f
1401 * \sa SDL_atan
1402 * \sa SDL_tan
1403 */
1404extern DECLSPEC double SDLCALL SDL_atan2(double y, double x);
1405
1406/**
1407 * Compute the arc tangent of `y / x`, using the signs of x and y to adjust
1408 * the result's quadrant.
1409 *
1410 * The definition of `z = atan2(x, y)` is `y = x tan(z)`, where the quadrant
1411 * of z is determined based on the signs of x and y.
1412 *
1413 * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
1414 *
1415 * Range: `-Pi/2 <= y <= Pi/2`
1416 *
1417 * This function operates on single-precision floating point values, use
1418 * SDL_atan2 for double-precision floats.
1419 *
1420 * To calculate the arc tangent of a single value, use SDL_atanf.
1421 *
1422 * This function may use a different approximation across different versions,
1423 * platforms and configurations. i.e, it can return a different value given
1424 * the same input on different machines or operating systems, or if SDL is
1425 * updated.
1426 *
1427 * \param x floating point value of the denominator (x coordinate).
1428 * \param y floating point value of the numerator (y coordinate)
1429 * \returns arc tangent of of `y / x` in radians, or, if `x = 0`, either
1430 * `-Pi/2`, `0`, or `Pi/2`, depending on the value of `y`.
1431 *
1432 * \since This function is available since SDL 3.0.0.
1433 *
1434 * \sa SDL_atan2f
1435 * \sa SDL_atan
1436 * \sa SDL_tan
1437 */
1438extern DECLSPEC float SDLCALL SDL_atan2f(float y, float x);
1439
1440/**
1441 * Compute the ceiling of `x`.
1442 *
1443 * The ceiling of `x` is the smallest integer `y` such that `y > x`, i.e `x`
1444 * rounded up to the nearest integer.
1445 *
1446 * Domain: `-INF <= x <= INF`
1447 *
1448 * Range: `-INF <= y <= INF`, y integer
1449 *
1450 * This function operates on double-precision floating point values, use
1451 * SDL_ceilf for single-precision floats.
1452 *
1453 * \param x floating point value
1454 * \returns the ceiling of `x`
1455 *
1456 * \since This function is available since SDL 3.0.0.
1457 *
1458 * \sa SDL_ceilf
1459 * \sa SDL_floor
1460 * \sa SDL_trunc
1461 * \sa SDL_round
1462 * \sa SDL_lround
1463 */
1464extern DECLSPEC double SDLCALL SDL_ceil(double x);
1465
1466/**
1467 * Compute the ceiling of `x`.
1468 *
1469 * The ceiling of `x` is the smallest integer `y` such that `y > x`, i.e `x`
1470 * rounded up to the nearest integer.
1471 *
1472 * Domain: `-INF <= x <= INF`
1473 *
1474 * Range: `-INF <= y <= INF`, y integer
1475 *
1476 * This function operates on single-precision floating point values, use
1477 * SDL_ceil for double-precision floats.
1478 *
1479 * \param x floating point value
1480 * \returns the ceiling of `x`
1481 *
1482 * \since This function is available since SDL 3.0.0.
1483 *
1484 * \sa SDL_ceil
1485 * \sa SDL_floorf
1486 * \sa SDL_truncf
1487 * \sa SDL_roundf
1488 * \sa SDL_lroundf
1489 */
1490extern DECLSPEC float SDLCALL SDL_ceilf(float x);
1491
1492/**
1493 * Copy the sign of one floating-point value to another.
1494 *
1495 * The definition of copysign is that ``copysign(x, y) = abs(x) * sign(y)``.
1496 *
1497 * Domain: `-INF <= x <= INF`, ``-INF <= y <= f``
1498 *
1499 * Range: `-INF <= z <= INF`
1500 *
1501 * This function operates on double-precision floating point values, use
1502 * SDL_copysignf for single-precision floats.
1503 *
1504 * \param x floating point value to use as the magnitude
1505 * \param y floating point value to use as the sign
1506 * \returns the floating point value with the sign of y and the magnitude of x
1507 *
1508 * \since This function is available since SDL 3.0.0.
1509 *
1510 * \sa SDL_copysignf
1511 * \sa SDL_fabs
1512 */
1513extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
1514
1515/**
1516 * Copy the sign of one floating-point value to another.
1517 *
1518 * The definition of copysign is that ``copysign(x, y) = abs(x) * sign(y)``.
1519 *
1520 * Domain: `-INF <= x <= INF`, ``-INF <= y <= f``
1521 *
1522 * Range: `-INF <= z <= INF`
1523 *
1524 * This function operates on single-precision floating point values, use
1525 * SDL_copysign for double-precision floats.
1526 *
1527 * \param x floating point value to use as the magnitude
1528 * \param y floating point value to use as the sign
1529 * \returns the floating point value with the sign of y and the magnitude of x
1530 *
1531 * \since This function is available since SDL 3.0.0.
1532 *
1533 * \sa SDL_copysignf
1534 * \sa SDL_fabsf
1535 */
1536extern DECLSPEC float SDLCALL SDL_copysignf(float x, float y);
1537
1538/**
1539 * Compute the cosine of `x`.
1540 *
1541 * Domain: `-INF <= x <= INF`
1542 *
1543 * Range: `-1 <= y <= 1`
1544 *
1545 * This function operates on double-precision floating point values, use
1546 * SDL_cosf for single-precision floats.
1547 *
1548 * This function may use a different approximation across different versions,
1549 * platforms and configurations. i.e, it can return a different value given
1550 * the same input on different machines or operating systems, or if SDL is
1551 * updated.
1552 *
1553 * \param x floating point value, in radians
1554 * \returns cosine of `x`
1555 *
1556 * \since This function is available since SDL 3.0.0.
1557 *
1558 * \sa SDL_cosf
1559 * \sa SDL_acos
1560 * \sa SDL_sin
1561 */
1562extern DECLSPEC double SDLCALL SDL_cos(double x);
1563
1564/**
1565 * Compute the cosine of `x`.
1566 *
1567 * Domain: `-INF <= x <= INF`
1568 *
1569 * Range: `-1 <= y <= 1`
1570 *
1571 * This function operates on single-precision floating point values, use
1572 * SDL_cos for double-precision floats.
1573 *
1574 * This function may use a different approximation across different versions,
1575 * platforms and configurations. i.e, it can return a different value given
1576 * the same input on different machines or operating systems, or if SDL is
1577 * updated.
1578 *
1579 * \param x floating point value, in radians
1580 * \returns cosine of `x`
1581 *
1582 * \since This function is available since SDL 3.0.0.
1583 *
1584 * \sa SDL_cos
1585 * \sa SDL_acosf
1586 * \sa SDL_sinf
1587 */
1588extern DECLSPEC float SDLCALL SDL_cosf(float x);
1589
1590/**
1591 * Compute the exponential of `x`.
1592 *
1593 * The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the
1594 * natural logarithm. The inverse is the natural logarithm, SDL_log.
1595 *
1596 * Domain: `-INF <= x <= INF`
1597 *
1598 * Range: `0 <= y <= INF`
1599 *
1600 * The output will overflow if `exp(x)` is too large to be represented.
1601 *
1602 * This function operates on double-precision floating point values, use
1603 * SDL_expf for single-precision floats.
1604 *
1605 * This function may use a different approximation across different versions,
1606 * platforms and configurations. i.e, it can return a different value given
1607 * the same input on different machines or operating systems, or if SDL is
1608 * updated.
1609 *
1610 * \param x floating point value
1611 * \returns value of `e^x`
1612 *
1613 * \since This function is available since SDL 3.0.0.
1614 *
1615 * \sa SDL_expf
1616 * \sa SDL_log
1617 */
1618extern DECLSPEC double SDLCALL SDL_exp(double x);
1619
1620/**
1621 * Compute the exponential of `x`.
1622 *
1623 * The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the
1624 * natural logarithm. The inverse is the natural logarithm, SDL_logf.
1625 *
1626 * Domain: `-INF <= x <= INF`
1627 *
1628 * Range: `0 <= y <= INF`
1629 *
1630 * The output will overflow if `exp(x)` is too large to be represented.
1631 *
1632 * This function operates on single-precision floating point values, use
1633 * SDL_exp for double-precision floats.
1634 *
1635 * This function may use a different approximation across different versions,
1636 * platforms and configurations. i.e, it can return a different value given
1637 * the same input on different machines or operating systems, or if SDL is
1638 * updated.
1639 *
1640 * \param x floating point value
1641 * \returns value of `e^x`
1642 *
1643 * \since This function is available since SDL 3.0.0.
1644 *
1645 * \sa SDL_exp
1646 * \sa SDL_logf
1647 */
1648extern DECLSPEC float SDLCALL SDL_expf(float x);
1649
1650/**
1651 * Compute the absolute value of `x`
1652 *
1653 * Domain: `-INF <= x <= INF`
1654 *
1655 * Range: `0 <= y <= INF`
1656 *
1657 * This function operates on double-precision floating point values, use
1658 * SDL_copysignf for single-precision floats.
1659 *
1660 * \param x floating point value to use as the magnitude
1661 * \returns the absolute value of `x`
1662 *
1663 * \since This function is available since SDL 3.0.0.
1664 *
1665 * \sa SDL_fabsf
1666 */
1667extern DECLSPEC double SDLCALL SDL_fabs(double x);
1668
1669/**
1670 * Compute the absolute value of `x`
1671 *
1672 * Domain: `-INF <= x <= INF`
1673 *
1674 * Range: `0 <= y <= INF`
1675 *
1676 * This function operates on single-precision floating point values, use
1677 * SDL_copysignf for double-precision floats.
1678 *
1679 * \param x floating point value to use as the magnitude
1680 * \returns the absolute value of `x`
1681 *
1682 * \since This function is available since SDL 3.0.0.
1683 *
1684 * \sa SDL_fabs
1685 */
1686extern DECLSPEC float SDLCALL SDL_fabsf(float x);
1687
1688/**
1689 * Compute the floor of `x`.
1690 *
1691 * The floor of `x` is the largest integer `y` such that `y > x`, i.e `x`
1692 * rounded down to the nearest integer.
1693 *
1694 * Domain: `-INF <= x <= INF`
1695 *
1696 * Range: `-INF <= y <= INF`, y integer
1697 *
1698 * This function operates on double-precision floating point values, use
1699 * SDL_floorf for single-precision floats.
1700 *
1701 * \param x floating point value
1702 * \returns the floor of `x`
1703 *
1704 * \since This function is available since SDL 3.0.0.
1705 *
1706 * \sa SDL_floorf
1707 * \sa SDL_ceil
1708 * \sa SDL_trunc
1709 * \sa SDL_round
1710 * \sa SDL_lround
1711 */
1712extern DECLSPEC double SDLCALL SDL_floor(double x);
1713
1714/**
1715 * Compute the floor of `x`.
1716 *
1717 * The floor of `x` is the largest integer `y` such that `y > x`, i.e `x`
1718 * rounded down to the nearest integer.
1719 *
1720 * Domain: `-INF <= x <= INF`
1721 *
1722 * Range: `-INF <= y <= INF`, y integer
1723 *
1724 * This function operates on single-precision floating point values, use
1725 * SDL_floorf for double-precision floats.
1726 *
1727 * \param x floating point value
1728 * \returns the floor of `x`
1729 *
1730 * \since This function is available since SDL 3.0.0.
1731 *
1732 * \sa SDL_floor
1733 * \sa SDL_ceilf
1734 * \sa SDL_truncf
1735 * \sa SDL_roundf
1736 * \sa SDL_lroundf
1737 */
1738extern DECLSPEC float SDLCALL SDL_floorf(float x);
1739
1740/**
1741 * Truncate `x` to an integer.
1742 *
1743 * Rounds `x` to the next closest integer to 0. This is equivalent to removing
1744 * the fractional part of `x`, leaving only the integer part.
1745 *
1746 * Domain: `-INF <= x <= INF`
1747 *
1748 * Range: `-INF <= y <= INF`, y integer
1749 *
1750 * This function operates on double-precision floating point values, use
1751 * SDL_truncf for single-precision floats.
1752 *
1753 * \param x floating point value
1754 * \returns `x` truncated to an integer
1755 *
1756 * \since This function is available since SDL 3.0.0.
1757 *
1758 * \sa SDL_truncf
1759 * \sa SDL_fmod
1760 * \sa SDL_ceil
1761 * \sa SDL_floor
1762 * \sa SDL_round
1763 * \sa SDL_lround
1764 */
1765extern DECLSPEC double SDLCALL SDL_trunc(double x);
1766
1767/**
1768 * Truncate `x` to an integer.
1769 *
1770 * Rounds `x` to the next closest integer to 0. This is equivalent to removing
1771 * the fractional part of `x`, leaving only the integer part.
1772 *
1773 * Domain: `-INF <= x <= INF`
1774 *
1775 * Range: `-INF <= y <= INF`, y integer
1776 *
1777 * This function operates on single-precision floating point values, use
1778 * SDL_truncf for double-precision floats.
1779 *
1780 * \param x floating point value
1781 * \returns `x` truncated to an integer
1782 *
1783 * \since This function is available since SDL 3.0.0.
1784 *
1785 * \sa SDL_trunc
1786 * \sa SDL_fmodf
1787 * \sa SDL_ceilf
1788 * \sa SDL_floorf
1789 * \sa SDL_roundf
1790 * \sa SDL_lroundf
1791 */
1792extern DECLSPEC float SDLCALL SDL_truncf(float x);
1793
1794/**
1795 * Return the floating-point remainder of `x / y`
1796 *
1797 * Divides `x` by `y`, and returns the remainder.
1798 *
1799 * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`, `y != 0`
1800 *
1801 * Range: `-y <= z <= y`
1802 *
1803 * This function operates on double-precision floating point values, use
1804 * SDL_fmodf for single-precision floats.
1805 *
1806 * \param x the numerator
1807 * \param y the denominator. Must not be 0.
1808 * \returns the remainder of `x / y`
1809 *
1810 * \since This function is available since SDL 3.0.0.
1811 *
1812 * \sa SDL_fmodf
1813 * \sa SDL_modf
1814 * \sa SDL_trunc
1815 * \sa SDL_ceil
1816 * \sa SDL_floor
1817 * \sa SDL_round
1818 * \sa SDL_lround
1819 */
1820extern DECLSPEC double SDLCALL SDL_fmod(double x, double y);
1821
1822/**
1823 * Return the floating-point remainder of `x / y`
1824 *
1825 * Divides `x` by `y`, and returns the remainder.
1826 *
1827 * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`, `y != 0`
1828 *
1829 * Range: `-y <= z <= y`
1830 *
1831 * This function operates on single-precision floating point values, use
1832 * SDL_fmod for single-precision floats.
1833 *
1834 * \param x the numerator
1835 * \param y the denominator. Must not be 0.
1836 * \returns the remainder of `x / y`
1837 *
1838 * \since This function is available since SDL 3.0.0.
1839 *
1840 * \sa SDL_fmod
1841 * \sa SDL_truncf
1842 * \sa SDL_modff
1843 * \sa SDL_ceilf
1844 * \sa SDL_floorf
1845 * \sa SDL_roundf
1846 * \sa SDL_lroundf
1847 */
1848extern DECLSPEC float SDLCALL SDL_fmodf(float x, float y);
1849
1850/**
1851 * Compute the natural logarithm of `x`.
1852 *
1853 * Domain: `0 < x <= INF`
1854 *
1855 * Range: `-INF <= y <= INF`
1856 *
1857 * It is an error for `x` to be less than or equal to 0.
1858 *
1859 * This function operates on double-precision floating point values, use
1860 * SDL_logf for single-precision floats.
1861 *
1862 * This function may use a different approximation across different versions,
1863 * platforms and configurations. i.e, it can return a different value given
1864 * the same input on different machines or operating systems, or if SDL is
1865 * updated.
1866 *
1867 * \param x floating point value. Must be greater than 0.
1868 * \returns the natural logarithm of `x`
1869 *
1870 * \since This function is available since SDL 3.0.0.
1871 *
1872 * \sa SDL_logf
1873 * \sa SDL_log10
1874 * \sa SDL_exp
1875 */
1876extern DECLSPEC double SDLCALL SDL_log(double x);
1877
1878/**
1879 * Compute the natural logarithm of `x`.
1880 *
1881 * Domain: `0 < x <= INF`
1882 *
1883 * Range: `-INF <= y <= INF`
1884 *
1885 * It is an error for `x` to be less than or equal to 0.
1886 *
1887 * This function operates on single-precision floating point values, use
1888 * SDL_log for double-precision floats.
1889 *
1890 * This function may use a different approximation across different versions,
1891 * platforms and configurations. i.e, it can return a different value given
1892 * the same input on different machines or operating systems, or if SDL is
1893 * updated.
1894 *
1895 * \param x floating point value. Must be greater than 0.
1896 * \returns the natural logarithm of `x`
1897 *
1898 * \since This function is available since SDL 3.0.0.
1899 *
1900 * \sa SDL_log
1901 * \sa SDL_expf
1902 */
1903extern DECLSPEC float SDLCALL SDL_logf(float x);
1904
1905/**
1906 * Compute the base-10 logarithm of `x`.
1907 *
1908 * Domain: `0 < x <= INF`
1909 *
1910 * Range: `-INF <= y <= INF`
1911 *
1912 * It is an error for `x` to be less than or equal to 0.
1913 *
1914 * This function operates on double-precision floating point values, use
1915 * SDL_log10f for single-precision floats.
1916 *
1917 * This function may use a different approximation across different versions,
1918 * platforms and configurations. i.e, it can return a different value given
1919 * the same input on different machines or operating systems, or if SDL is
1920 * updated.
1921 *
1922 * \param x floating point value. Must be greater than 0.
1923 * \returns the logarithm of `x`
1924 *
1925 * \since This function is available since SDL 3.0.0.
1926 *
1927 * \sa SDL_log10f
1928 * \sa SDL_log
1929 * \sa SDL_pow
1930 */
1931extern DECLSPEC double SDLCALL SDL_log10(double x);
1932
1933/**
1934 * Compute the base-10 logarithm of `x`.
1935 *
1936 * Domain: `0 < x <= INF`
1937 *
1938 * Range: `-INF <= y <= INF`
1939 *
1940 * It is an error for `x` to be less than or equal to 0.
1941 *
1942 * This function operates on single-precision floating point values, use
1943 * SDL_log10 for double-precision floats.
1944 *
1945 * This function may use a different approximation across different versions,
1946 * platforms and configurations. i.e, it can return a different value given
1947 * the same input on different machines or operating systems, or if SDL is
1948 * updated.
1949 *
1950 * \param x floating point value. Must be greater than 0.
1951 * \returns the logarithm of `x`
1952 *
1953 * \since This function is available since SDL 3.0.0.
1954 *
1955 * \sa SDL_log10
1956 * \sa SDL_logf
1957 * \sa SDL_powf
1958 */
1959extern DECLSPEC float SDLCALL SDL_log10f(float x);
1960
1961/**
1962 * Split `x` into integer and fractional parts
1963 *
1964 * This function operates on double-precision floating point values, use
1965 * SDL_modff for single-precision floats.
1966 *
1967 * \param x floating point value
1968 * \param y output pointer to store the integer part of `x`
1969 * \returns the fractional part of `x`
1970 *
1971 * \since This function is available since SDL 3.0.0.
1972 *
1973 * \sa SDL_modff
1974 * \sa SDL_trunc
1975 * \sa SDL_fmod
1976 */
1977extern DECLSPEC double SDLCALL SDL_modf(double x, double *y);
1978
1979/**
1980 * Split `x` into integer and fractional parts
1981 *
1982 * This function operates on single-precision floating point values, use
1983 * SDL_modf for double-precision floats.
1984 *
1985 * \param x floating point value
1986 * \param y output pointer to store the integer part of `x`
1987 * \returns the fractional part of `x`
1988 *
1989 * \since This function is available since SDL 3.0.0.
1990 *
1991 * \sa SDL_modf
1992 * \sa SDL_truncf
1993 * \sa SDL_fmodf
1994 */
1995extern DECLSPEC float SDLCALL SDL_modff(float x, float *y);
1996
1997/**
1998 * Raise `x` to the power `y`
1999 *
2000 * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
2001 *
2002 * Range: `-INF <= z <= INF`
2003 *
2004 * If `y` is the base of the natural logarithm (e), consider using SDL_exp
2005 * instead.
2006 *
2007 * This function operates on double-precision floating point values, use
2008 * SDL_powf for single-precision floats.
2009 *
2010 * This function may use a different approximation across different versions,
2011 * platforms and configurations. i.e, it can return a different value given
2012 * the same input on different machines or operating systems, or if SDL is
2013 * updated.
2014 *
2015 * \param x the base
2016 * \param y the exponent
2017 * \returns `x` raised to the power `y`
2018 *
2019 * \since This function is available since SDL 3.0.0.
2020 *
2021 * \sa SDL_powf
2022 * \sa SDL_exp
2023 * \sa SDL_log
2024 */
2025extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
2026
2027/**
2028 * Raise `x` to the power `y`
2029 *
2030 * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`
2031 *
2032 * Range: `-INF <= z <= INF`
2033 *
2034 * If `y` is the base of the natural logarithm (e), consider using SDL_exp
2035 * instead.
2036 *
2037 * This function operates on single-precision floating point values, use
2038 * SDL_powf for double-precision floats.
2039 *
2040 * This function may use a different approximation across different versions,
2041 * platforms and configurations. i.e, it can return a different value given
2042 * the same input on different machines or operating systems, or if SDL is
2043 * updated.
2044 *
2045 * \param x the base
2046 * \param y the exponent
2047 * \returns `x` raised to the power `y`
2048 *
2049 * \since This function is available since SDL 3.0.0.
2050 *
2051 * \sa SDL_pow
2052 * \sa SDL_expf
2053 * \sa SDL_logf
2054 */
2055extern DECLSPEC float SDLCALL SDL_powf(float x, float y);
2056
2057/**
2058 * Round `x` to the nearest integer.
2059 *
2060 * Rounds `x` to the nearest integer. Values halfway between integers will be
2061 * rounded away from zero.
2062 *
2063 * Domain: `-INF <= x <= INF`
2064 *
2065 * Range: `-INF <= y <= INF`, y integer
2066 *
2067 * This function operates on double-precision floating point values, use
2068 * SDL_roundf for single-precision floats. To get the result as an integer
2069 * type, use SDL_lround.
2070 *
2071 * \param x floating point value
2072 * \returns the nearest integer to `x`
2073 *
2074 * \since This function is available since SDL 3.0.0.
2075 *
2076 * \sa SDL_roundf
2077 * \sa SDL_lround
2078 * \sa SDL_floor
2079 * \sa SDL_ceil
2080 * \sa SDL_trunc
2081 */
2082extern DECLSPEC double SDLCALL SDL_round(double x);
2083
2084/**
2085 * Round `x` to the nearest integer.
2086 *
2087 * Rounds `x` to the nearest integer. Values halfway between integers will be
2088 * rounded away from zero.
2089 *
2090 * Domain: `-INF <= x <= INF`
2091 *
2092 * Range: `-INF <= y <= INF`, y integer
2093 *
2094 * This function operates on double-precision floating point values, use
2095 * SDL_roundf for single-precision floats. To get the result as an integer
2096 * type, use SDL_lroundf.
2097 *
2098 * \param x floating point value
2099 * \returns the nearest integer to `x`
2100 *
2101 * \since This function is available since SDL 3.0.0.
2102 *
2103 * \sa SDL_round
2104 * \sa SDL_lroundf
2105 * \sa SDL_floorf
2106 * \sa SDL_ceilf
2107 * \sa SDL_truncf
2108 */
2109extern DECLSPEC float SDLCALL SDL_roundf(float x);
2110
2111/**
2112 * Round `x` to the nearest integer representable as a long
2113 *
2114 * Rounds `x` to the nearest integer. Values halfway between integers will be
2115 * rounded away from zero.
2116 *
2117 * Domain: `-INF <= x <= INF`
2118 *
2119 * Range: `MIN_LONG <= y <= MAX_LONG`
2120 *
2121 * This function operates on double-precision floating point values, use
2122 * SDL_lround for single-precision floats. To get the result as a
2123 * floating-point type, use SDL_round.
2124 *
2125 * \param x floating point value
2126 * \returns the nearest integer to `x`
2127 *
2128 * \since This function is available since SDL 3.0.0.
2129 *
2130 * \sa SDL_lroundf
2131 * \sa SDL_round
2132 * \sa SDL_floor
2133 * \sa SDL_ceil
2134 * \sa SDL_trunc
2135 */
2136extern DECLSPEC long SDLCALL SDL_lround(double x);
2137
2138/**
2139 * Round `x` to the nearest integer representable as a long
2140 *
2141 * Rounds `x` to the nearest integer. Values halfway between integers will be
2142 * rounded away from zero.
2143 *
2144 * Domain: `-INF <= x <= INF`
2145 *
2146 * Range: `MIN_LONG <= y <= MAX_LONG`
2147 *
2148 * This function operates on single-precision floating point values, use
2149 * SDL_lroundf for double-precision floats. To get the result as a
2150 * floating-point type, use SDL_roundf,
2151 *
2152 * \param x floating point value
2153 * \returns the nearest integer to `x`
2154 *
2155 * \since This function is available since SDL 3.0.0.
2156 *
2157 * \sa SDL_lround
2158 * \sa SDL_roundf
2159 * \sa SDL_floorf
2160 * \sa SDL_ceilf
2161 * \sa SDL_truncf
2162 */
2163extern DECLSPEC long SDLCALL SDL_lroundf(float x);
2164
2165/**
2166 * Scale `x` by an integer power of two.
2167 *
2168 * Multiplies `x` by the `n`th power of the floating point radix (always 2).
2169 *
2170 * Domain: `-INF <= x <= INF`, `n` integer
2171 *
2172 * Range: `-INF <= y <= INF`
2173 *
2174 * This function operates on double-precision floating point values, use
2175 * SDL_scalbnf for single-precision floats.
2176 *
2177 * \param x floating point value to be scaled
2178 * \param n integer exponent
2179 * \returns `x * 2^n`
2180 *
2181 * \since This function is available since SDL 3.0.0.
2182 *
2183 * \sa SDL_scalbnf
2184 * \sa SDL_pow
2185 */
2186extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
2187
2188/**
2189 * Scale `x` by an integer power of two.
2190 *
2191 * Multiplies `x` by the `n`th power of the floating point radix (always 2).
2192 *
2193 * Domain: `-INF <= x <= INF`, `n` integer
2194 *
2195 * Range: `-INF <= y <= INF`
2196 *
2197 * This function operates on single-precision floating point values, use
2198 * SDL_scalbn for double-precision floats.
2199 *
2200 * \param x floating point value to be scaled
2201 * \param n integer exponent
2202 * \returns `x * 2^n`
2203 *
2204 * \since This function is available since SDL 3.0.0.
2205 *
2206 * \sa SDL_scalbn
2207 * \sa SDL_powf
2208 */
2209extern DECLSPEC float SDLCALL SDL_scalbnf(float x, int n);
2210
2211/**
2212 * Compute the sine of `x`.
2213 *
2214 * Domain: `-INF <= x <= INF`
2215 *
2216 * Range: `-1 <= y <= 1`
2217 *
2218 * This function operates on double-precision floating point values, use
2219 * SDL_sinf for single-precision floats.
2220 *
2221 * This function may use a different approximation across different versions,
2222 * platforms and configurations. i.e, it can return a different value given
2223 * the same input on different machines or operating systems, or if SDL is
2224 * updated.
2225 *
2226 * \param x floating point value, in radians
2227 * \returns sine of `x`
2228 *
2229 * \since This function is available since SDL 3.0.0.
2230 *
2231 * \sa SDL_sinf
2232 * \sa SDL_asin
2233 * \sa SDL_cos
2234 */
2235extern DECLSPEC double SDLCALL SDL_sin(double x);
2236
2237/**
2238 * Compute the sine of `x`.
2239 *
2240 * Domain: `-INF <= x <= INF`
2241 *
2242 * Range: `-1 <= y <= 1`
2243 *
2244 * This function operates on single-precision floating point values, use
2245 * SDL_sinf for double-precision floats.
2246 *
2247 * This function may use a different approximation across different versions,
2248 * platforms and configurations. i.e, it can return a different value given
2249 * the same input on different machines or operating systems, or if SDL is
2250 * updated.
2251 *
2252 * \param x floating point value, in radians
2253 * \returns sine of `x`
2254 *
2255 * \since This function is available since SDL 3.0.0.
2256 *
2257 * \sa SDL_sin
2258 * \sa SDL_asinf
2259 * \sa SDL_cosf
2260 */
2261extern DECLSPEC float SDLCALL SDL_sinf(float x);
2262
2263/**
2264 * Compute the square root of `x`.
2265 *
2266 * Domain: `0 <= x <= INF`
2267 *
2268 * Range: `0 <= y <= INF`
2269 *
2270 * This function operates on double-precision floating point values, use
2271 * SDL_sqrtf for single-precision floats.
2272 *
2273 * This function may use a different approximation across different versions,
2274 * platforms and configurations. i.e, it can return a different value given
2275 * the same input on different machines or operating systems, or if SDL is
2276 * updated.
2277 *
2278 * \param x floating point value. Must be greater than or equal to 0.
2279 * \returns square root of `x`
2280 *
2281 * \since This function is available since SDL 3.0.0.
2282 *
2283 * \sa SDL_sqrtf
2284 */
2285extern DECLSPEC double SDLCALL SDL_sqrt(double x);
2286
2287/**
2288 * Compute the square root of `x`.
2289 *
2290 * Domain: `0 <= x <= INF`
2291 *
2292 * Range: `0 <= y <= INF`
2293 *
2294 * This function operates on single-precision floating point values, use
2295 * SDL_sqrt for double-precision floats.
2296 *
2297 * This function may use a different approximation across different versions,
2298 * platforms and configurations. i.e, it can return a different value given
2299 * the same input on different machines or operating systems, or if SDL is
2300 * updated.
2301 *
2302 * \param x floating point value. Must be greater than or equal to 0.
2303 * \returns square root of `x`
2304 *
2305 * \since This function is available since SDL 3.0.0.
2306 *
2307 * \sa SDL_sqrt
2308 */
2309extern DECLSPEC float SDLCALL SDL_sqrtf(float x);
2310
2311/**
2312 * Compute the tangent of `x`.
2313 *
2314 * Domain: `-INF <= x <= INF`
2315 *
2316 * Range: `-INF <= y <= INF`
2317 *
2318 * This function operates on double-precision floating point values, use
2319 * SDL_tanf for single-precision floats.
2320 *
2321 * This function may use a different approximation across different versions,
2322 * platforms and configurations. i.e, it can return a different value given
2323 * the same input on different machines or operating systems, or if SDL is
2324 * updated.
2325 *
2326 * \param x floating point value, in radians
2327 * \returns tangent of `x`
2328 *
2329 * \since This function is available since SDL 3.0.0.
2330 *
2331 * \sa SDL_tanf
2332 * \sa SDL_sin
2333 * \sa SDL_cos
2334 * \sa SDL_atan
2335 * \sa SDL_atan2
2336 */
2337extern DECLSPEC double SDLCALL SDL_tan(double x);
2338
2339/**
2340 * Compute the tangent of `x`.
2341 *
2342 * Domain: `-INF <= x <= INF`
2343 *
2344 * Range: `-INF <= y <= INF`
2345 *
2346 * This function operates on single-precision floating point values, use
2347 * SDL_tanf for double-precision floats.
2348 *
2349 * This function may use a different approximation across different versions,
2350 * platforms and configurations. i.e, it can return a different value given
2351 * the same input on different machines or operating systems, or if SDL is
2352 * updated.
2353 *
2354 * \param x floating point value, in radians
2355 * \returns tangent of `x`
2356 *
2357 * \since This function is available since SDL 3.0.0.
2358 *
2359 * \sa SDL_tan
2360 * \sa SDL_sinf
2361 * \sa SDL_cosf
2362 * \sa SDL_atanf
2363 * \sa SDL_atan2f
2364 */
2365extern DECLSPEC float SDLCALL SDL_tanf(float x);
2366
2367/* The SDL implementation of iconv() returns these error codes */
2368#define SDL_ICONV_ERROR (size_t)-1
2369#define SDL_ICONV_E2BIG (size_t)-2
2370#define SDL_ICONV_EILSEQ (size_t)-3
2371#define SDL_ICONV_EINVAL (size_t)-4
2372
2373/* SDL_iconv_* are now always real symbols/types, not macros or inlined. */
2374typedef struct SDL_iconv_data_t *SDL_iconv_t;
2375extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
2376 const char *fromcode);
2377extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
2378extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
2379 size_t * inbytesleft, char **outbuf,
2380 size_t * outbytesleft);
2381
2382/**
2383 * This function converts a buffer or string between encodings in one pass,
2384 * returning a string that must be freed with SDL_free() or NULL on error.
2385 *
2386 * \since This function is available since SDL 3.0.0.
2387 */
2388extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
2389 const char *fromcode,
2390 const char *inbuf,
2391 size_t inbytesleft);
2392#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
2393#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
2394#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
2395#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t))
2396
2397/* force builds using Clang's static analysis tools to use literal C runtime
2398 here, since there are possibly tests that are ineffective otherwise. */
2399#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
2400
2401/* The analyzer knows about strlcpy even when the system doesn't provide it */
2402#if !defined(HAVE_STRLCPY) && !defined(strlcpy)
2403size_t strlcpy(char* dst, const char* src, size_t size);
2404#endif
2405
2406/* The analyzer knows about strlcat even when the system doesn't provide it */
2407#if !defined(HAVE_STRLCAT) && !defined(strlcat)
2408size_t strlcat(char* dst, const char* src, size_t size);
2409#endif
2410
2411#if !defined(HAVE_WCSLCPY) && !defined(wcslcpy)
2412size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
2413#endif
2414
2415#if !defined(HAVE_WCSLCAT) && !defined(wcslcat)
2416size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
2417#endif
2418
2419/* Starting LLVM 16, the analyser errors out if these functions do not have
2420 their prototype defined (clang-diagnostic-implicit-function-declaration) */
2421#include <stdlib.h>
2422#include <stdio.h>
2423
2424#define SDL_malloc malloc
2425#define SDL_calloc calloc
2426#define SDL_realloc realloc
2427#define SDL_free free
2428#ifndef SDL_memcpy
2429#define SDL_memcpy memcpy
2430#endif
2431#ifndef SDL_memmove
2432#define SDL_memmove memmove
2433#endif
2434#ifndef SDL_memset
2435#define SDL_memset memset
2436#endif
2437#define SDL_memcmp memcmp
2438#define SDL_strlcpy strlcpy
2439#define SDL_strlcat strlcat
2440#define SDL_strlen strlen
2441#define SDL_wcslen wcslen
2442#define SDL_wcslcpy wcslcpy
2443#define SDL_wcslcat wcslcat
2444#define SDL_strdup strdup
2445#define SDL_wcsdup wcsdup
2446#define SDL_strchr strchr
2447#define SDL_strrchr strrchr
2448#define SDL_strstr strstr
2449#define SDL_wcsstr wcsstr
2450#define SDL_strtok_r strtok_r
2451#define SDL_strcmp strcmp
2452#define SDL_wcscmp wcscmp
2453#define SDL_strncmp strncmp
2454#define SDL_wcsncmp wcsncmp
2455#define SDL_strcasecmp strcasecmp
2456#define SDL_strncasecmp strncasecmp
2457#define SDL_sscanf sscanf
2458#define SDL_vsscanf vsscanf
2459#define SDL_snprintf snprintf
2460#define SDL_vsnprintf vsnprintf
2461#endif
2462
2463/**
2464 * If a * b would overflow, return -1.
2465 *
2466 * Otherwise store a * b via ret and return 0.
2467 *
2468 * \since This function is available since SDL 3.0.0.
2469 */
2471 size_t b,
2472 size_t *ret)
2473{
2474 if (a != 0 && b > SDL_SIZE_MAX / a) {
2475 return -1;
2476 }
2477 *ret = a * b;
2478 return 0;
2479}
2480
2481#ifndef SDL_WIKI_DOCUMENTATION_SECTION
2482#if SDL_HAS_BUILTIN(__builtin_mul_overflow)
2483/* This needs to be wrapped in an inline rather than being a direct #define,
2484 * because __builtin_mul_overflow() is type-generic, but we want to be
2485 * consistent about interpreting a and b as size_t. */
2486SDL_FORCE_INLINE int SDL_size_mul_overflow_builtin (size_t a,
2487 size_t b,
2488 size_t *ret)
2489{
2490 return __builtin_mul_overflow(a, b, ret) == 0 ? 0 : -1;
2491}
2492#define SDL_size_mul_overflow(a, b, ret) (SDL_size_mul_overflow_builtin(a, b, ret))
2493#endif
2494#endif
2495
2496/**
2497 * If a + b would overflow, return -1.
2498 *
2499 * Otherwise store a + b via ret and return 0.
2500 *
2501 * \since This function is available since SDL 3.0.0.
2502 */
2504 size_t b,
2505 size_t *ret)
2506{
2507 if (b > SDL_SIZE_MAX - a) {
2508 return -1;
2509 }
2510 *ret = a + b;
2511 return 0;
2512}
2513
2514#ifndef SDL_WIKI_DOCUMENTATION_SECTION
2515#if SDL_HAS_BUILTIN(__builtin_add_overflow)
2516/* This needs to be wrapped in an inline rather than being a direct #define,
2517 * the same as the call to __builtin_mul_overflow() above. */
2518SDL_FORCE_INLINE int SDL_size_add_overflow_builtin (size_t a,
2519 size_t b,
2520 size_t *ret)
2521{
2522 return __builtin_add_overflow(a, b, ret) == 0 ? 0 : -1;
2523}
2524#define SDL_size_add_overflow(a, b, ret) (SDL_size_add_overflow_builtin(a, b, ret))
2525#endif
2526#endif
2527
2528/* This is a generic function pointer which should be cast to the type you expect */
2529#ifdef SDL_FUNCTION_POINTER_IS_VOID_POINTER
2530typedef void *SDL_FunctionPointer;
2531#else
2532typedef void (*SDL_FunctionPointer)(void);
2533#endif
2534
2535/* Ends C function definitions when using C++ */
2536#ifdef __cplusplus
2537}
2538#endif
2539#include <SDL3/SDL_close_code.h>
2540
2541#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:851
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)
void * SDL_bsearch_r(const void *key, const void *base, size_t nmemb, size_t size, int(*compare)(void *, const void *, const void *), void *userdata)
int SDL_abs(int x)
size_t SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
void SDL_qsort_r(void *base, size_t nmemb, size_t size, int(*compare)(void *, const void *, const void *), void *userdata)
double SDL_tan(double x)
char * SDL_ltoa(long value, char *str, int radix)
int SDL_isxdigit(int x)
float SDL_ceilf(float x)
int64_t Sint64
Definition SDL_stdinc.h:233
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:473
#define SDL_OUT_BYTECAP(x)
Definition SDL_stdinc.h:383
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:206
int SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt,...) SDL_SCANF_VARARG_FUNC(2)
void SDL_qsort(void *base, size_t nmemb, size_t size, int(*compare)(const void *, const void *))
float SDL_atanf(float x)
int SDL_isprint(int x)
#define SDL_PRINTF_VARARG_FUNCV(fmtargnumber)
Definition SDL_stdinc.h:397
int SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
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:379
int SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2)
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)
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)
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:399
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:386
char * SDL_strstr(const char *haystack, const char *needle)
int SDL_GetNumAllocations(void)
double SDL_exp(double x)
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)
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:380
double SDL_scalbn(double x, int n)
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)
char * SDL_getenv(const char *name)
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:469
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)
float SDL_log10f(float x)
void(* SDL_free_func)(void *mem)
Definition SDL_stdinc.h:476
int SDL_memcmp(const void *s1, const void *s2, size_t len)
char * SDL_ulltoa(Uint64 value, char *str, int radix)
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)
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:385
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:396
#define SDL_COMPILE_TIME_ASSERT(name, x)
Definition SDL_stdinc.h:417
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:242
SDL_MALLOC char * SDL_strdup(const char *str)
int SDL_iscntrl(int x)
#define SDL_memcpy
Definition SDL_stdinc.h:826
void SDL_free(void *mem)
void *(* SDL_calloc_func)(size_t nmemb, size_t size)
Definition SDL_stdinc.h:474
#define SDL_SCANF_VARARG_FUNC(fmtargnumber)
Definition SDL_stdinc.h:398
double SDL_atan2(double y, double x)
double SDL_log(double x)
void(* SDL_FunctionPointer)(void)
int SDL_toupper(int x)
uint32_t Uint32
Definition SDL_stdinc.h:224
float SDL_powf(float x, float y)
size_t SDL_strlen(const char *str)
#define SDL_memmove
Definition SDL_stdinc.h:840
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)
void * SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int(*compare)(const void *, const void *))
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:475
size_t SDL_utf8strlen(const char *str)
int SDL_isgraph(int x)
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:381
#define SDL_WPRINTF_VARARG_FUNC(fmtargnumber)
Definition SDL_stdinc.h:400
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 128 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:829

Definition at line 829 of file SDL_stdinc.h.

830 { SDL_COMPILE_TIME_ASSERT(SDL_copyp, sizeof (*(dst)) == sizeof (*(src))); } \
831 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 151 of file SDL_stdinc.h.

◆ SDL_FLT_EPSILON

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

Definition at line 268 of file SDL_stdinc.h.

◆ SDL_FOURCC

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

Definition at line 133 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 2369 of file SDL_stdinc.h.

◆ SDL_ICONV_EILSEQ

#define SDL_ICONV_EILSEQ   (size_t)-3

Definition at line 2370 of file SDL_stdinc.h.

◆ SDL_ICONV_EINVAL

#define SDL_ICONV_EINVAL   (size_t)-4

Definition at line 2371 of file SDL_stdinc.h.

◆ SDL_ICONV_ERROR

#define SDL_ICONV_ERROR   (size_t)-1

Definition at line 2368 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 2392 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 2393 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 2394 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 2395 of file SDL_stdinc.h.

◆ SDL_IN_BYTECAP

#define SDL_IN_BYTECAP (   x)

Definition at line 379 of file SDL_stdinc.h.

◆ SDL_INOUT_Z_CAP

#define SDL_INOUT_Z_CAP (   x)

Definition at line 380 of file SDL_stdinc.h.

◆ SDL_max

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

Definition at line 577 of file SDL_stdinc.h.

◆ SDL_MAX_SINT16

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

A signed 16-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 195 of file SDL_stdinc.h.

◆ SDL_MAX_SINT32

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

A signed 32-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 213 of file SDL_stdinc.h.

◆ SDL_MAX_SINT64

#define SDL_MAX_SINT64   ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */

A signed 64-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 231 of file SDL_stdinc.h.

◆ SDL_MAX_SINT8

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

A signed 8-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 177 of file SDL_stdinc.h.

◆ SDL_MAX_TIME

#define SDL_MAX_TIME   SDL_MAX_SINT64

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.

Definition at line 254 of file SDL_stdinc.h.

◆ SDL_MAX_UINT16

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

An unsigned 16-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 204 of file SDL_stdinc.h.

◆ SDL_MAX_UINT32

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

An unsigned 32-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 222 of file SDL_stdinc.h.

◆ SDL_MAX_UINT64

#define SDL_MAX_UINT64   ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */

An unsigned 64-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 240 of file SDL_stdinc.h.

◆ SDL_MAX_UINT8

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

An unsigned 8-bit integer type.

Since
This macro is available since SDL 3.0.0.

Definition at line 186 of file SDL_stdinc.h.

◆ SDL_memcpy

#define SDL_memcpy   memcpy

Definition at line 826 of file SDL_stdinc.h.

◆ SDL_memmove

#define SDL_memmove   memmove

Definition at line 840 of file SDL_stdinc.h.

◆ SDL_memset

#define SDL_memset   memset

Definition at line 851 of file SDL_stdinc.h.

◆ SDL_min

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

Definition at line 576 of file SDL_stdinc.h.

◆ SDL_MIN_SINT16

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

Definition at line 196 of file SDL_stdinc.h.

◆ SDL_MIN_SINT32

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

Definition at line 214 of file SDL_stdinc.h.

◆ SDL_MIN_SINT64

#define SDL_MIN_SINT64   ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */

Definition at line 232 of file SDL_stdinc.h.

◆ SDL_MIN_SINT8

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

Definition at line 178 of file SDL_stdinc.h.

◆ SDL_MIN_TIME

#define SDL_MIN_TIME   SDL_MIN_SINT64

Definition at line 255 of file SDL_stdinc.h.

◆ SDL_MIN_UINT16

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

Definition at line 205 of file SDL_stdinc.h.

◆ SDL_MIN_UINT32

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

Definition at line 223 of file SDL_stdinc.h.

◆ SDL_MIN_UINT64

#define SDL_MIN_UINT64   ((Uint64)(0x0000000000000000ull)) /* 0 */

Definition at line 241 of file SDL_stdinc.h.

◆ SDL_MIN_UINT8

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

Definition at line 187 of file SDL_stdinc.h.

◆ SDL_OUT_BYTECAP

#define SDL_OUT_BYTECAP (   x)

Definition at line 383 of file SDL_stdinc.h.

◆ SDL_OUT_CAP

#define SDL_OUT_CAP (   x)

Definition at line 382 of file SDL_stdinc.h.

◆ SDL_OUT_Z_BYTECAP

#define SDL_OUT_Z_BYTECAP (   x)

Definition at line 384 of file SDL_stdinc.h.

◆ SDL_OUT_Z_CAP

#define SDL_OUT_Z_CAP (   x)

Definition at line 381 of file SDL_stdinc.h.

◆ SDL_PI_D

#define SDL_PI_D   3.141592653589793238462643383279502884

pi (double)

Definition at line 1192 of file SDL_stdinc.h.

◆ SDL_PI_F

#define SDL_PI_F   3.141592653589793238462643383279502884F

pi (float)

Definition at line 1195 of file SDL_stdinc.h.

◆ SDL_PRINTF_FORMAT_STRING

#define SDL_PRINTF_FORMAT_STRING

Definition at line 385 of file SDL_stdinc.h.

◆ SDL_PRINTF_VARARG_FUNC

#define SDL_PRINTF_VARARG_FUNC (   fmtargnumber)

Definition at line 396 of file SDL_stdinc.h.

◆ SDL_PRINTF_VARARG_FUNCV

#define SDL_PRINTF_VARARG_FUNCV (   fmtargnumber)

Definition at line 397 of file SDL_stdinc.h.

◆ SDL_PRIs32

#define SDL_PRIs32   "d"

Definition at line 324 of file SDL_stdinc.h.

◆ SDL_PRIs64

#define SDL_PRIs64   "lld"

Definition at line 284 of file SDL_stdinc.h.

◆ SDL_PRIu32

#define SDL_PRIu32   "u"

Definition at line 331 of file SDL_stdinc.h.

◆ SDL_PRIu64

#define SDL_PRIu64   "llu"

Definition at line 295 of file SDL_stdinc.h.

◆ SDL_PRIx32

#define SDL_PRIx32   "x"

Definition at line 338 of file SDL_stdinc.h.

◆ SDL_PRIX32

#define SDL_PRIX32   "X"

Definition at line 345 of file SDL_stdinc.h.

◆ SDL_PRIx64

#define SDL_PRIx64   "llx"

Definition at line 306 of file SDL_stdinc.h.

◆ SDL_PRIX64

#define SDL_PRIX64   "llX"

Definition at line 317 of file SDL_stdinc.h.

◆ SDL_reinterpret_cast

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

Definition at line 126 of file SDL_stdinc.h.

◆ SDL_SCANF_FORMAT_STRING

#define SDL_SCANF_FORMAT_STRING

Definition at line 386 of file SDL_stdinc.h.

◆ SDL_SCANF_VARARG_FUNC

#define SDL_SCANF_VARARG_FUNC (   fmtargnumber)

Definition at line 398 of file SDL_stdinc.h.

◆ SDL_SCANF_VARARG_FUNCV

#define SDL_SCANF_VARARG_FUNCV (   fmtargnumber)

Definition at line 399 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 461 of file SDL_stdinc.h.

◆ SDL_stack_free

#define SDL_stack_free (   data)

Definition at line 462 of file SDL_stdinc.h.

◆ SDL_static_cast

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

Definition at line 127 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 112 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 160 of file SDL_stdinc.h.

◆ SDL_WPRINTF_VARARG_FUNC

#define SDL_WPRINTF_VARARG_FUNC (   fmtargnumber)

Definition at line 400 of file SDL_stdinc.h.

◆ SDL_WSCANF_VARARG_FUNC

#define SDL_WSCANF_VARARG_FUNC (   fmtargnumber)

Definition at line 401 of file SDL_stdinc.h.

◆ SDL_zero

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

Definition at line 854 of file SDL_stdinc.h.

◆ SDL_zeroa

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

Definition at line 856 of file SDL_stdinc.h.

◆ SDL_zerop

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

Definition at line 855 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 170 of file SDL_stdinc.h.

◆ SDL_calloc_func

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

Definition at line 474 of file SDL_stdinc.h.

◆ SDL_free_func

typedef void(* SDL_free_func) (void *mem)

Definition at line 476 of file SDL_stdinc.h.

◆ SDL_FunctionPointer

typedef void(* SDL_FunctionPointer) (void)

Definition at line 2532 of file SDL_stdinc.h.

◆ SDL_iconv_t

typedef struct SDL_iconv_data_t* SDL_iconv_t

Definition at line 2374 of file SDL_stdinc.h.

◆ SDL_malloc_func

typedef void *(* SDL_malloc_func) (size_t size)

Definition at line 473 of file SDL_stdinc.h.

◆ SDL_realloc_func

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

Definition at line 475 of file SDL_stdinc.h.

◆ SDL_Time

typedef Sint64 SDL_Time

Definition at line 256 of file SDL_stdinc.h.

◆ Sint16

typedef int16_t Sint16

Definition at line 197 of file SDL_stdinc.h.

◆ Sint32

typedef int32_t Sint32

Definition at line 215 of file SDL_stdinc.h.

◆ Sint64

typedef int64_t Sint64

Definition at line 233 of file SDL_stdinc.h.

◆ Sint8

typedef int8_t Sint8

Definition at line 179 of file SDL_stdinc.h.

◆ Uint16

typedef uint16_t Uint16

Definition at line 206 of file SDL_stdinc.h.

◆ Uint32

typedef uint32_t Uint32

Definition at line 224 of file SDL_stdinc.h.

◆ Uint64

typedef uint64_t Uint64

Definition at line 242 of file SDL_stdinc.h.

◆ Uint8

typedef uint8_t Uint8

Definition at line 188 of file SDL_stdinc.h.

Function Documentation

◆ alloca()

void * alloca ( size_t  )

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

Parameters
alignmentthe alignment requested
sizethe size to allocate
Returns
a pointer to the aligned memory
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().

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.
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.
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.
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
xfloating point value of the denominator (x coordinate).
yfloating point value of the numerator (y 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.
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
xfloating point value of the denominator (x coordinate).
yfloating point value of the numerator (y 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.
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
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,
int(*)(const void *, const void *)  compare 
)
extern

◆ SDL_bsearch_r()

void * SDL_bsearch_r ( const void *  key,
const void *  base,
size_t  nmemb,
size_t  size,
int(*)(void *, const void *, const void *)  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
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
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
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
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
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
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
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
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
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
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
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
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
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
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()

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
Since
This function is available since SDL 3.0.0.

◆ SDL_GetNumAllocations()

int SDL_GetNumAllocations ( void  )
extern

Get the number of outstanding (unfreed) allocations.

Returns
the number of allocations
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.

Parameters
malloc_funcfilled with malloc function
calloc_funcfilled with calloc function
realloc_funcfilled with realloc function
free_funcfilled with free function
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

This function converts a buffer or string between encodings in one pass, returning a string that must be freed with SDL_free() 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_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_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
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
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
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
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
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
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
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
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
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
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,
int(*)(const void *, const void *)  compare 
)
extern

◆ SDL_qsort_r()

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

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

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.
Since
This function is available since SDL 3.0.0.

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

If a + b would overflow, return -1.

Otherwise store a + b via ret and return 0.

Since
This function is available since SDL 3.0.0.

Definition at line 2503 of file SDL_stdinc.h.

2506{
2507 if (b > SDL_SIZE_MAX - a) {
2508 return -1;
2509 }
2510 *ret = a + b;
2511 return 0;
2512}

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 
)

If a * b would overflow, return -1.

Otherwise store a * b via ret and return 0.

Since
This function is available since SDL 3.0.0.

Definition at line 2470 of file SDL_stdinc.h.

2473{
2474 if (a != 0 && b > SDL_SIZE_MAX / a) {
2475 return -1;
2476 }
2477 *ret = a * b;
2478 return 0;
2479}

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
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
Since
This function is available since SDL 3.0.0.
See also
SDL_sqrt

◆ SDL_sscanf()

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

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

\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
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
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
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
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_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_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 469 of file SDL_stdinc.h.