SDL 3.0
|
#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>
Go to the source code of this file.
Macros | |
#define | bool unsigned char |
#define | false 0 |
#define | true 1 |
#define | __bool_true_false_are_defined 1 |
#define | SDL_SIZE_MAX ((size_t) -1) |
#define | SDL_COMPILE_TIME_ASSERT(name, x) typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1] |
#define | SDL_HAS_BUILTIN(x) 0 |
#define | SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) |
#define | SDL_STRINGIFY_ARG(arg) #arg |
Cast operators | |
Use proper C++ casts when compiled as C++ to be compatible with the option -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). | |
#define | SDL_reinterpret_cast(type, expression) ((type)(expression)) |
#define | SDL_static_cast(type, expression) ((type)(expression)) |
#define | SDL_const_cast(type, expression) ((type)(expression)) |
#define | SDL_FOURCC(A, B, C, D) |
#define | SDL_SINT64_C(c) c ## LL |
#define | SDL_UINT64_C(c) c ## ULL |
Functions | |
void * | alloca (size_t) |
Basic data types | |
#define | SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */ |
#define | SDL_MIN_SINT8 ((Sint8)(~0x7F)) /* -128 */ |
#define | SDL_MAX_UINT8 ((Uint8)0xFF) /* 255 */ |
#define | SDL_MIN_UINT8 ((Uint8)0x00) /* 0 */ |
#define | SDL_MAX_SINT16 ((Sint16)0x7FFF) /* 32767 */ |
#define | SDL_MIN_SINT16 ((Sint16)(~0x7FFF)) /* -32768 */ |
#define | SDL_MAX_UINT16 ((Uint16)0xFFFF) /* 65535 */ |
#define | SDL_MIN_UINT16 ((Uint16)0x0000) /* 0 */ |
#define | SDL_MAX_SINT32 ((Sint32)0x7FFFFFFF) /* 2147483647 */ |
#define | SDL_MIN_SINT32 ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */ |
#define | SDL_MAX_UINT32 ((Uint32)0xFFFFFFFFu) /* 4294967295 */ |
#define | SDL_MIN_UINT32 ((Uint32)0x00000000) /* 0 */ |
#define | SDL_MAX_SINT64 SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* 9223372036854775807 */ |
#define | SDL_MIN_SINT64 ~SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* -9223372036854775808 */ |
#define | SDL_MAX_UINT64 SDL_UINT64_C(0xFFFFFFFFFFFFFFFF) /* 18446744073709551615 */ |
#define | SDL_MIN_UINT64 SDL_UINT64_C(0x0000000000000000) /* 0 */ |
#define | SDL_MAX_TIME SDL_MAX_SINT64 |
#define | SDL_MIN_TIME SDL_MIN_SINT64 |
typedef 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_PRILL_PREFIX "ll" |
#define | SDL_PRILLd SDL_PRILL_PREFIX "d" |
#define | SDL_PRILLu SDL_PRILL_PREFIX "u" |
#define | SDL_PRILLx SDL_PRILL_PREFIX "x" |
#define | SDL_PRILLX SDL_PRILL_PREFIX "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_WPRINTF_VARARG_FUNCV(fmtargnumber) |
#define | SDL_INIT_INTERFACE(iface) |
#define | SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) |
#define | SDL_stack_free(data) |
#define | SDL_min(x, y) (((x) < (y)) ? (x) : (y)) |
#define | SDL_max(x, y) (((x) > (y)) ? (x) : (y)) |
#define | SDL_clamp(x, a, b) (((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x))) |
#define | SDL_memcpy memcpy |
#define | SDL_copyp(dst, src) |
#define | SDL_memmove memmove |
#define | SDL_memset memset |
#define | SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) |
#define | SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) |
#define | SDL_zeroa(x) SDL_memset((x), 0, sizeof((x))) |
#define | SDL_INVALID_UNICODE_CODEPOINT 0xFFFD |
#define | SDL_PI_D 3.141592653589793238462643383279502884 |
#define | SDL_PI_F 3.141592653589793238462643383279502884F |
#define | SDL_ICONV_ERROR (size_t)-1 |
#define | SDL_ICONV_E2BIG (size_t)-2 |
#define | SDL_ICONV_EILSEQ (size_t)-3 |
#define | SDL_ICONV_EINVAL (size_t)-4 |
#define | SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) |
#define | SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) |
#define | SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1) |
#define | SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t)) |
typedef void *(* | SDL_malloc_func) (size_t size) |
typedef void *(* | SDL_calloc_func) (size_t nmemb, size_t size) |
typedef void *(* | SDL_realloc_func) (void *mem, size_t size) |
typedef void(* | SDL_free_func) (void *mem) |
typedef struct SDL_Environment | SDL_Environment |
typedef int(* | SDL_CompareCallback) (const void *a, const void *b) |
typedef int(* | SDL_CompareCallback_r) (void *userdata, const void *a, const void *b) |
typedef struct SDL_iconv_data_t * | SDL_iconv_t |
typedef void(* | SDL_FunctionPointer) (void) |
SDL_MALLOC size_t | size |
SDL_MALLOC void * | SDL_malloc (size_t size) |
SDL_MALLOC | SDL_ALLOC_SIZE2 (1, 2) void *SDL_calloc(size_t nmemb |
SDL_ALLOC_SIZE (2) void *SDL_realloc(void *mem | |
void | SDL_free (void *mem) |
void | SDL_GetOriginalMemoryFunctions (SDL_malloc_func *malloc_func, SDL_calloc_func *calloc_func, SDL_realloc_func *realloc_func, SDL_free_func *free_func) |
void | SDL_GetMemoryFunctions (SDL_malloc_func *malloc_func, SDL_calloc_func *calloc_func, SDL_realloc_func *realloc_func, SDL_free_func *free_func) |
bool | 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) |
SDL_Environment * | SDL_GetEnvironment (void) |
SDL_Environment * | SDL_CreateEnvironment (bool populated) |
const char * | SDL_GetEnvironmentVariable (SDL_Environment *env, const char *name) |
char ** | SDL_GetEnvironmentVariables (SDL_Environment *env) |
bool | SDL_SetEnvironmentVariable (SDL_Environment *env, const char *name, const char *value, bool overwrite) |
bool | SDL_UnsetEnvironmentVariable (SDL_Environment *env, const char *name) |
void | SDL_DestroyEnvironment (SDL_Environment *env) |
const char * | SDL_getenv (const char *name) |
const char * | SDL_getenv_unsafe (const char *name) |
int | SDL_setenv_unsafe (const char *name, const char *value, int overwrite) |
int | SDL_unsetenv_unsafe (const char *name) |
void | SDL_qsort (void *base, size_t nmemb, size_t size, SDL_CompareCallback compare) |
void * | SDL_bsearch (const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback compare) |
void | SDL_qsort_r (void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata) |
void * | SDL_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata) |
int | SDL_abs (int x) |
int | SDL_isalpha (int x) |
int | SDL_isalnum (int x) |
int | SDL_isblank (int x) |
int | SDL_iscntrl (int x) |
int | SDL_isdigit (int x) |
int | SDL_isxdigit (int x) |
int | SDL_ispunct (int x) |
int | SDL_isspace (int x) |
int | SDL_isupper (int x) |
int | SDL_islower (int x) |
int | SDL_isprint (int x) |
int | SDL_isgraph (int x) |
int | SDL_toupper (int x) |
int | SDL_tolower (int x) |
Uint16 | SDL_crc16 (Uint16 crc, const void *data, size_t len) |
Uint32 | SDL_crc32 (Uint32 crc, const void *data, size_t len) |
Uint32 | SDL_murmur3_32 (const void *data, size_t len, Uint32 seed) |
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 (long long value, char *str, int radix) |
char * | SDL_ulltoa (unsigned long long 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) |
long long | SDL_strtoll (const char *str, char **endp, int base) |
unsigned long long | 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) |
char * | SDL_strpbrk (const char *str, const char *breakset) |
Uint32 | SDL_StepUTF8 (const char **pstr, size_t *pslen) |
Uint32 | SDL_StepBackUTF8 (const char *start, const char **pstr) |
char * | SDL_UCS4ToUTF8 (Uint32 codepoint, char *dst) |
int | SDL_sscanf (const char *text, SDL_SCANF_FORMAT_STRING const char *fmt,...) SDL_SCANF_VARARG_FUNC(2) |
int | SDL_vsscanf (const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap) SDL_SCANF_VARARG_FUNCV(2) |
int | SDL_snprintf (SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(3) |
int | SDL_swprintf (SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt,...) SDL_WPRINTF_VARARG_FUNC(3) |
int | SDL_vsnprintf (SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3) |
int | SDL_vswprintf (SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt, va_list ap) SDL_WPRINTF_VARARG_FUNCV(3) |
int | SDL_asprintf (char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(2) |
int | SDL_vasprintf (char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2) |
void | SDL_srand (Uint64 seed) |
Sint32 | SDL_rand (Sint32 n) |
float | SDL_randf (void) |
Uint32 | SDL_rand_bits (void) |
Sint32 | SDL_rand_r (Uint64 *state, Sint32 n) |
float | SDL_randf_r (Uint64 *state) |
Uint32 | SDL_rand_bits_r (Uint64 *state) |
double | SDL_acos (double x) |
float | SDL_acosf (float x) |
double | SDL_asin (double x) |
float | SDL_asinf (float x) |
double | SDL_atan (double x) |
float | SDL_atanf (float x) |
double | SDL_atan2 (double y, double x) |
float | SDL_atan2f (float y, float x) |
double | SDL_ceil (double x) |
float | SDL_ceilf (float x) |
double | SDL_copysign (double x, double y) |
float | SDL_copysignf (float x, float y) |
double | SDL_cos (double x) |
float | SDL_cosf (float x) |
double | SDL_exp (double x) |
float | SDL_expf (float x) |
double | SDL_fabs (double x) |
float | SDL_fabsf (float x) |
double | SDL_floor (double x) |
float | SDL_floorf (float x) |
double | SDL_trunc (double x) |
float | SDL_truncf (float x) |
double | SDL_fmod (double x, double y) |
float | SDL_fmodf (float x, float y) |
int | SDL_isinf (double x) |
int | SDL_isinff (float x) |
int | SDL_isnan (double x) |
int | SDL_isnanf (float x) |
double | SDL_log (double x) |
float | SDL_logf (float x) |
double | SDL_log10 (double x) |
float | SDL_log10f (float x) |
double | SDL_modf (double x, double *y) |
float | SDL_modff (float x, float *y) |
double | SDL_pow (double x, double y) |
float | SDL_powf (float x, float y) |
double | SDL_round (double x) |
float | SDL_roundf (float x) |
long | SDL_lround (double x) |
long | SDL_lroundf (float x) |
double | SDL_scalbn (double x, int n) |
float | SDL_scalbnf (float x, int n) |
double | SDL_sin (double x) |
float | SDL_sinf (float x) |
double | SDL_sqrt (double x) |
float | SDL_sqrtf (float x) |
double | SDL_tan (double x) |
float | SDL_tanf (float x) |
SDL_iconv_t | SDL_iconv_open (const char *tocode, const char *fromcode) |
int | SDL_iconv_close (SDL_iconv_t cd) |
size_t | SDL_iconv (SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) |
char * | SDL_iconv_string (const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft) |
SDL_FORCE_INLINE bool | SDL_size_mul_check_overflow (size_t a, size_t b, size_t *ret) |
SDL_FORCE_INLINE bool | SDL_size_add_check_overflow (size_t a, size_t b, size_t *ret) |
#define __bool_true_false_are_defined 1 |
Definition at line 56 of file SDL_stdinc.h.
#define bool unsigned char |
This is a general header that includes C language support. It implements a subset of the C runtime APIs, but with an SDL_
prefix. For most common use cases, these should behave the same way as their C runtime equivalents, but they may differ in how or whether they handle certain edge cases. When in doubt, consult the documentation for details.
Definition at line 53 of file SDL_stdinc.h.
#define false 0 |
Definition at line 54 of file SDL_stdinc.h.
#define SDL_arraysize | ( | array | ) | (sizeof(array)/sizeof(array[0])) |
The number of elements in an array.
This macro looks like it double-evaluates the argument, but it does so inside of sizeof
, so there are no side-effects here, as expressions do not actually run any code in these cases.
Definition at line 136 of file SDL_stdinc.h.
#define SDL_clamp | ( | x, | |
a, | |||
b | |||
) | (((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x))) |
Definition at line 1470 of file SDL_stdinc.h.
#define SDL_COMPILE_TIME_ASSERT | ( | name, | |
x | |||
) | typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1] |
Definition at line 112 of file SDL_stdinc.h.
#define SDL_const_cast | ( | type, | |
expression | |||
) | ((type)(expression)) |
Definition at line 234 of file SDL_stdinc.h.
#define SDL_copyp | ( | dst, | |
src | |||
) |
Definition at line 1740 of file SDL_stdinc.h.
#define SDL_FLT_EPSILON 1.1920928955078125e-07F /* 0x0.000002p0 */ |
Epsilon constant, used for comparing floating-point numbers.
Equals by default to platform-defined FLT_EPSILON
, or 1.1920928955078125e-07F
if that's not available.
Definition at line 432 of file SDL_stdinc.h.
#define SDL_FOURCC | ( | A, | |
B, | |||
C, | |||
D | |||
) |
Define a four character code as a Uint32.
A | the first ASCII character. |
B | the second ASCII character. |
C | the third ASCII character. |
D | the fourth ASCII character. |
\threadsafety It is safe to call this macro from any thread.
Definition at line 253 of file SDL_stdinc.h.
#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 124 of file SDL_stdinc.h.
#define SDL_ICONV_E2BIG (size_t)-2 |
Definition at line 4134 of file SDL_stdinc.h.
#define SDL_ICONV_EILSEQ (size_t)-3 |
Definition at line 4135 of file SDL_stdinc.h.
#define SDL_ICONV_EINVAL (size_t)-4 |
Definition at line 4136 of file SDL_stdinc.h.
#define SDL_ICONV_ERROR (size_t)-1 |
Definition at line 4133 of file SDL_stdinc.h.
#define SDL_iconv_utf8_locale | ( | S | ) | SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) |
Definition at line 4242 of file SDL_stdinc.h.
#define SDL_iconv_utf8_ucs2 | ( | S | ) | (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) |
Definition at line 4243 of file SDL_stdinc.h.
#define SDL_iconv_utf8_ucs4 | ( | S | ) | (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1) |
Definition at line 4244 of file SDL_stdinc.h.
#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 4245 of file SDL_stdinc.h.
#define SDL_IN_BYTECAP | ( | x | ) |
Definition at line 562 of file SDL_stdinc.h.
#define SDL_INIT_INTERFACE | ( | iface | ) |
A macro to initialize an SDL interface.
This macro will initialize an SDL interface structure and should be called before you fill out the fields with your implementation.
You can use it like this:
If you are using designated initializers, you can use the size of the interface as the version, e.g.
\threadsafety It is safe to call this macro from any thread.
Definition at line 675 of file SDL_stdinc.h.
#define SDL_INOUT_Z_CAP | ( | x | ) |
Definition at line 563 of file SDL_stdinc.h.
#define SDL_INVALID_UNICODE_CODEPOINT 0xFFFD |
The Unicode REPLACEMENT CHARACTER codepoint.
SDL_StepUTF8() and SDL_StepBackUTF8() report this codepoint when they encounter a UTF-8 string with encoding errors.
This tends to render as something like a question mark in most places.
Definition at line 2507 of file SDL_stdinc.h.
#define SDL_max | ( | x, | |
y | |||
) | (((x) > (y)) ? (x) : (y)) |
Definition at line 1469 of file SDL_stdinc.h.
#define SDL_MAX_SINT16 ((Sint16)0x7FFF) /* 32767 */ |
Definition at line 344 of file SDL_stdinc.h.
#define SDL_MAX_SINT32 ((Sint32)0x7FFFFFFF) /* 2147483647 */ |
Definition at line 362 of file SDL_stdinc.h.
#define SDL_MAX_SINT64 SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* 9223372036854775807 */ |
Definition at line 382 of file SDL_stdinc.h.
#define SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */ |
Definition at line 326 of file SDL_stdinc.h.
#define SDL_MAX_TIME SDL_MAX_SINT64 |
Definition at line 410 of file SDL_stdinc.h.
#define SDL_MAX_UINT16 ((Uint16)0xFFFF) /* 65535 */ |
Definition at line 353 of file SDL_stdinc.h.
#define SDL_MAX_UINT32 ((Uint32)0xFFFFFFFFu) /* 4294967295 */ |
Definition at line 371 of file SDL_stdinc.h.
#define SDL_MAX_UINT64 SDL_UINT64_C(0xFFFFFFFFFFFFFFFF) /* 18446744073709551615 */ |
Definition at line 393 of file SDL_stdinc.h.
#define SDL_MAX_UINT8 ((Uint8)0xFF) /* 255 */ |
Definition at line 335 of file SDL_stdinc.h.
#define SDL_memcpy memcpy |
Definition at line 1737 of file SDL_stdinc.h.
#define SDL_memmove memmove |
Definition at line 1768 of file SDL_stdinc.h.
#define SDL_memset memset |
Definition at line 1779 of file SDL_stdinc.h.
#define SDL_min | ( | x, | |
y | |||
) | (((x) < (y)) ? (x) : (y)) |
Definition at line 1468 of file SDL_stdinc.h.
#define SDL_MIN_SINT16 ((Sint16)(~0x7FFF)) /* -32768 */ |
Definition at line 345 of file SDL_stdinc.h.
#define SDL_MIN_SINT32 ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */ |
Definition at line 363 of file SDL_stdinc.h.
#define SDL_MIN_SINT64 ~SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* -9223372036854775808 */ |
Definition at line 383 of file SDL_stdinc.h.
#define SDL_MIN_SINT8 ((Sint8)(~0x7F)) /* -128 */ |
Definition at line 327 of file SDL_stdinc.h.
#define SDL_MIN_TIME SDL_MIN_SINT64 |
Definition at line 411 of file SDL_stdinc.h.
#define SDL_MIN_UINT16 ((Uint16)0x0000) /* 0 */ |
Definition at line 354 of file SDL_stdinc.h.
#define SDL_MIN_UINT32 ((Uint32)0x00000000) /* 0 */ |
Definition at line 372 of file SDL_stdinc.h.
#define SDL_MIN_UINT64 SDL_UINT64_C(0x0000000000000000) /* 0 */ |
Definition at line 394 of file SDL_stdinc.h.
#define SDL_MIN_UINT8 ((Uint8)0x00) /* 0 */ |
Definition at line 336 of file SDL_stdinc.h.
#define SDL_OUT_BYTECAP | ( | x | ) |
Definition at line 566 of file SDL_stdinc.h.
#define SDL_OUT_CAP | ( | x | ) |
Definition at line 565 of file SDL_stdinc.h.
#define SDL_OUT_Z_BYTECAP | ( | x | ) |
Definition at line 567 of file SDL_stdinc.h.
#define SDL_OUT_Z_CAP | ( | x | ) |
Definition at line 564 of file SDL_stdinc.h.
#define SDL_PI_D 3.141592653589793238462643383279502884 |
pi (double)
Definition at line 2813 of file SDL_stdinc.h.
#define SDL_PI_F 3.141592653589793238462643383279502884F |
pi (float)
Definition at line 2816 of file SDL_stdinc.h.
#define SDL_PRILL_PREFIX "ll" |
Definition at line 517 of file SDL_stdinc.h.
#define SDL_PRILLd SDL_PRILL_PREFIX "d" |
Definition at line 520 of file SDL_stdinc.h.
#define SDL_PRILLu SDL_PRILL_PREFIX "u" |
Definition at line 523 of file SDL_stdinc.h.
#define SDL_PRILLx SDL_PRILL_PREFIX "x" |
Definition at line 526 of file SDL_stdinc.h.
#define SDL_PRILLX SDL_PRILL_PREFIX "X" |
Definition at line 529 of file SDL_stdinc.h.
#define SDL_PRINTF_FORMAT_STRING |
Definition at line 568 of file SDL_stdinc.h.
#define SDL_PRINTF_VARARG_FUNC | ( | fmtargnumber | ) |
Definition at line 579 of file SDL_stdinc.h.
#define SDL_PRINTF_VARARG_FUNCV | ( | fmtargnumber | ) |
Definition at line 580 of file SDL_stdinc.h.
#define SDL_PRIs32 "d" |
Definition at line 488 of file SDL_stdinc.h.
#define SDL_PRIs64 "lld" |
Definition at line 448 of file SDL_stdinc.h.
#define SDL_PRIu32 "u" |
Definition at line 495 of file SDL_stdinc.h.
#define SDL_PRIu64 "llu" |
Definition at line 459 of file SDL_stdinc.h.
#define SDL_PRIx32 "x" |
Definition at line 502 of file SDL_stdinc.h.
#define SDL_PRIX32 "X" |
Definition at line 509 of file SDL_stdinc.h.
#define SDL_PRIx64 "llx" |
Definition at line 470 of file SDL_stdinc.h.
#define SDL_PRIX64 "llX" |
Definition at line 481 of file SDL_stdinc.h.
#define SDL_reinterpret_cast | ( | type, | |
expression | |||
) | ((type)(expression)) |
Definition at line 232 of file SDL_stdinc.h.
#define SDL_SCANF_FORMAT_STRING |
Definition at line 569 of file SDL_stdinc.h.
#define SDL_SCANF_VARARG_FUNC | ( | fmtargnumber | ) |
Definition at line 581 of file SDL_stdinc.h.
#define SDL_SCANF_VARARG_FUNCV | ( | fmtargnumber | ) |
Definition at line 582 of file SDL_stdinc.h.
#define SDL_SINT64_C | ( | c | ) | c ## LL |
Definition at line 297 of file SDL_stdinc.h.
#define SDL_SIZE_MAX ((size_t) -1) |
Definition at line 94 of file SDL_stdinc.h.
#define SDL_stack_alloc | ( | type, | |
count | |||
) | (type*)alloca(sizeof(type)*(count)) |
Definition at line 683 of file SDL_stdinc.h.
#define SDL_stack_free | ( | data | ) |
Definition at line 684 of file SDL_stdinc.h.
#define SDL_static_cast | ( | type, | |
expression | |||
) | ((type)(expression)) |
Definition at line 233 of file SDL_stdinc.h.
#define SDL_STRINGIFY_ARG | ( | arg | ) | #arg |
Macro useful for building other macros with strings in them.
For example:
Definition at line 149 of file SDL_stdinc.h.
#define SDL_UINT64_C | ( | c | ) | c ## ULL |
Definition at line 309 of file SDL_stdinc.h.
#define SDL_WPRINTF_VARARG_FUNC | ( | fmtargnumber | ) |
Definition at line 583 of file SDL_stdinc.h.
#define SDL_WPRINTF_VARARG_FUNCV | ( | fmtargnumber | ) |
Definition at line 584 of file SDL_stdinc.h.
#define SDL_zero | ( | x | ) | SDL_memset(&(x), 0, sizeof((x))) |
Definition at line 1782 of file SDL_stdinc.h.
#define SDL_zeroa | ( | x | ) | SDL_memset((x), 0, sizeof((x))) |
Definition at line 1784 of file SDL_stdinc.h.
#define SDL_zerop | ( | x | ) | SDL_memset((x), 0, sizeof(*(x))) |
Definition at line 1783 of file SDL_stdinc.h.
#define true 1 |
Definition at line 55 of file SDL_stdinc.h.
typedef void *(* SDL_calloc_func) (size_t nmemb, size_t size) |
A callback used to implement SDL_calloc().
SDL will always ensure that the passed nmemb
and size
are both greater than 0.
nmemb | the number of elements in the array. |
size | the size of each element of the array. |
\threadsafety It should be safe to call this callback from any thread.
Definition at line 829 of file SDL_stdinc.h.
typedef int(* SDL_CompareCallback) (const void *a, const void *b) |
A callback used with SDL sorting and binary search functions.
a | a pointer to the first element being compared. |
b | a pointer to the second element being compared. |
a
should be sorted before b
, 1 if b
should be sorted before a
, 0 if they are equal. If two elements are equal, their order in the sorted array is undefined.Definition at line 1239 of file SDL_stdinc.h.
typedef int(* SDL_CompareCallback_r) (void *userdata, const void *a, const void *b) |
A callback used with SDL sorting and binary search functions.
userdata | the userdata pointer passed to the sort function. |
a | a pointer to the first element being compared. |
b | a pointer to the second element being compared. |
a
should be sorted before b
, 1 if b
should be sorted before a
, 0 if they are equal. If two elements are equal, their order in the sorted array is undefined.Definition at line 1352 of file SDL_stdinc.h.
typedef struct SDL_Environment SDL_Environment |
A thread-safe set of environment variables
Definition at line 1011 of file SDL_stdinc.h.
typedef void(* SDL_free_func) (void *mem) |
A callback used to implement SDL_free().
SDL will always ensure that the passed mem
is a non-NULL pointer.
mem | a pointer to allocated memory. |
\threadsafety It should be safe to call this callback from any thread.
Definition at line 868 of file SDL_stdinc.h.
typedef void(* SDL_FunctionPointer) (void) |
Definition at line 4417 of file SDL_stdinc.h.
typedef struct SDL_iconv_data_t* SDL_iconv_t |
Definition at line 4138 of file SDL_stdinc.h.
typedef void *(* SDL_malloc_func) (size_t size) |
A callback used to implement SDL_malloc().
SDL will always ensure that the passed size
is greater than 0.
size | the size to allocate. |
\threadsafety It should be safe to call this callback from any thread.
Definition at line 808 of file SDL_stdinc.h.
typedef void *(* SDL_realloc_func) (void *mem, size_t size) |
A callback used to implement SDL_realloc().
SDL will always ensure that the passed size
is greater than 0.
mem | a pointer to allocated memory to reallocate, or NULL. |
size | the new size of the memory. |
\threadsafety It should be safe to call this callback from any thread.
Definition at line 850 of file SDL_stdinc.h.
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().
Definition at line 409 of file SDL_stdinc.h.
typedef int16_t Sint16 |
A signed 16-bit integer type.
Definition at line 343 of file SDL_stdinc.h.
typedef int32_t Sint32 |
A signed 32-bit integer type.
Definition at line 361 of file SDL_stdinc.h.
typedef int64_t Sint64 |
A signed 64-bit integer type.
Definition at line 381 of file SDL_stdinc.h.
typedef int8_t Sint8 |
A signed 8-bit integer type.
Definition at line 325 of file SDL_stdinc.h.
typedef uint16_t Uint16 |
An unsigned 16-bit integer type.
Definition at line 352 of file SDL_stdinc.h.
typedef uint32_t Uint32 |
An unsigned 32-bit integer type.
Definition at line 370 of file SDL_stdinc.h.
typedef uint64_t Uint64 |
An unsigned 64-bit integer type.
Definition at line 392 of file SDL_stdinc.h.
typedef uint8_t Uint8 |
An unsigned 8-bit integer type.
Definition at line 334 of file SDL_stdinc.h.
void * alloca | ( | size_t | ) |
int SDL_abs | ( | int | x | ) |
double SDL_acos | ( | double | x | ) |
Compute the arc cosine of x
.
The definition of y = acos(x)
is x = cos(y)
.
Domain: -1 <= x <= 1
Range: 0 <= y <= Pi
This function operates on double-precision floating point values, use SDL_acosf for single-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. |
x
, in radians.\threadsafety It is safe to call this function from any thread.
float SDL_acosf | ( | float | x | ) |
Compute the arc cosine of x
.
The definition of y = acos(x)
is x = cos(y)
.
Domain: -1 <= x <= 1
Range: 0 <= y <= Pi
This function operates on single-precision floating point values, use SDL_acos for double-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. |
x
, in radians.\threadsafety It is safe to call this function from any thread.
SDL_MALLOC void * SDL_aligned_alloc | ( | size_t | alignment, |
size_t | size | ||
) |
Allocate memory aligned to a specific alignment.
The memory returned by this function must be freed with SDL_aligned_free(), not SDL_free().
If alignment
is less than the size of void *
, it will be increased to match that.
The returned memory address will be a multiple of the alignment value, and the size of the memory allocated will be a multiple of the alignment value.
alignment | the alignment of the memory. |
size | the size to allocate. |
\threadsafety It is safe to call this function from any thread.
void SDL_aligned_free | ( | void * | mem | ) |
Free memory allocated by SDL_aligned_alloc().
The pointer is no longer valid after this call and cannot be dereferenced anymore.
If mem
is NULL, this function does nothing.
mem | a pointer previously returned by SDL_aligned_alloc(), or NULL. |
\threadsafety It is safe to call this function from any thread.
SDL_ALLOC_SIZE | ( | 2 | ) |
Change the size of allocated memory.
The memory returned by this function must be freed with SDL_free().
If size
is 0, it will be set to 1. Note that this is unlike some other C runtime realloc
implementations, which may treat realloc(mem, 0)
the same way as free(mem)
.
If mem
is NULL, the behavior of this function is equivalent to SDL_malloc(). Otherwise, the function can have one of three possible outcomes:
mem
, it means that mem
was resized in place without freeing.mem
was freed and cannot be dereferenced anymore.mem
will remain valid and must still be freed with SDL_free().mem | a pointer to allocated memory to reallocate, or NULL. |
size | the new size of the memory. |
\threadsafety It is safe to call this function from any thread.
SDL_MALLOC SDL_ALLOC_SIZE2 | ( | 1 | , |
2 | |||
) |
Allocate a zero-initialized array.
The memory returned by this function must be freed with SDL_free().
If either of nmemb
or size
is 0, they will both be set to 1.
nmemb | the number of elements in the array. |
size | the size of each element of the array. |
\threadsafety It is safe to call this function from any thread.
double SDL_asin | ( | double | x | ) |
Compute the arc sine of x
.
The definition of y = asin(x)
is x = sin(y)
.
Domain: -1 <= x <= 1
Range: -Pi/2 <= y <= Pi/2
This function operates on double-precision floating point values, use SDL_asinf for single-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. |
x
, in radians.\threadsafety It is safe to call this function from any thread.
float SDL_asinf | ( | float | x | ) |
Compute the arc sine of x
.
The definition of y = asin(x)
is x = sin(y)
.
Domain: -1 <= x <= 1
Range: -Pi/2 <= y <= Pi/2
This function operates on single-precision floating point values, use SDL_asin for double-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. |
x
, in radians.\threadsafety It is safe to call this function from any thread.
int SDL_asprintf | ( | char ** | strp, |
SDL_PRINTF_FORMAT_STRING const char * | fmt, | ||
... | |||
) |
double SDL_atan | ( | double | x | ) |
Compute the arc tangent of x
.
The definition of y = atan(x)
is x = tan(y)
.
Domain: -INF <= x <= INF
Range: -Pi/2 <= y <= Pi/2
This function operates on double-precision floating point values, use SDL_atanf for single-precision floats.
To calculate the arc tangent of y / x, use SDL_atan2.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. |
x
in radians, or 0 if x = 0
.\threadsafety It is safe to call this function from any thread.
double SDL_atan2 | ( | double | y, |
double | x | ||
) |
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.
y | floating point value of the numerator (y coordinate). |
x | floating point value of the denominator (x coordinate). |
y / x
in radians, or, if x = 0
, either -Pi/2
, 0
, or Pi/2
, depending on the value of y
.\threadsafety It is safe to call this function from any thread.
float SDL_atan2f | ( | float | y, |
float | x | ||
) |
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.
y | floating point value of the numerator (y coordinate). |
x | floating point value of the denominator (x coordinate). |
y / x
in radians, or, if x = 0
, either -Pi/2
, 0
, or Pi/2
, depending on the value of y
.\threadsafety It is safe to call this function from any thread.
float SDL_atanf | ( | float | x | ) |
Compute the arc tangent of x
.
The definition of y = atan(x)
is x = tan(y)
.
Domain: -INF <= x <= INF
Range: -Pi/2 <= y <= Pi/2
This function operates on single-precision floating point values, use SDL_atan for dboule-precision floats.
To calculate the arc tangent of y / x, use SDL_atan2f.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. |
x
in radians, or 0 if x = 0
.\threadsafety It is safe to call this function from any thread.
double SDL_atof | ( | const char * | str | ) |
Parse a double
from a string.
The result of calling SDL_atof(str)
is equivalent to SDL_strtod(str,
NULL)
.
str | The null-terminated string to read. Must not be NULL. |
double
.\threadsafety It is safe to call this function from any thread.
int SDL_atoi | ( | const char * | str | ) |
Parse an int
from a string.
The result of calling SDL_atoi(str)
is equivalent to (int)SDL_strtol(str, NULL, 10)
.
str | The null-terminated string to read. Must not be NULL. |
int
.\threadsafety It is safe to call this function from any thread.
void * SDL_bsearch | ( | const void * | key, |
const void * | base, | ||
size_t | nmemb, | ||
size_t | size, | ||
SDL_CompareCallback | compare | ||
) |
Perform a binary search on a previously sorted array.
For example:
key | a pointer to a key equal to the element being searched for. |
base | a pointer to the start of the array. |
nmemb | the number of elements in the array. |
size | the size of the elements in the array. |
compare | a function used to compare elements in the array. |
\threadsafety It is safe to call this function from any thread.
void * SDL_bsearch_r | ( | const void * | key, |
const void * | base, | ||
size_t | nmemb, | ||
size_t | size, | ||
SDL_CompareCallback_r | compare, | ||
void * | userdata | ||
) |
Perform a binary search on a previously sorted array, passing a userdata pointer to the compare function.
For example:
key | a pointer to a key equal to the element being searched for. |
base | a pointer to the start of the array. |
nmemb | the number of elements in the array. |
size | the size of the elements in the array. |
compare | a function used to compare elements in the array. |
userdata | a pointer to pass to the compare function. |
\threadsafety It is safe to call this function from any thread.
double SDL_ceil | ( | double | x | ) |
Compute the ceiling of x
.
The ceiling of x
is the smallest integer y
such that y > x
, i.e x
rounded up to the nearest integer.
Domain: -INF <= x <= INF
Range: -INF <= y <= INF
, y integer
This function operates on double-precision floating point values, use SDL_ceilf for single-precision floats.
x | floating point value. |
x
.\threadsafety It is safe to call this function from any thread.
float SDL_ceilf | ( | float | x | ) |
Compute the ceiling of x
.
The ceiling of x
is the smallest integer y
such that y > x
, i.e x
rounded up to the nearest integer.
Domain: -INF <= x <= INF
Range: -INF <= y <= INF
, y integer
This function operates on single-precision floating point values, use SDL_ceil for double-precision floats.
x | floating point value. |
x
.\threadsafety It is safe to call this function from any thread.
double SDL_copysign | ( | double | x, |
double | y | ||
) |
Copy the sign of one floating-point value to another.
The definition of copysign is that copysign(x, y) = abs(x) * sign(y)
.
Domain: -INF <= x <= INF
, -INF <= y <= f
Range: -INF <= z <= INF
This function operates on double-precision floating point values, use SDL_copysignf for single-precision floats.
x | floating point value to use as the magnitude. |
y | floating point value to use as the sign. |
\threadsafety It is safe to call this function from any thread.
float SDL_copysignf | ( | float | x, |
float | y | ||
) |
Copy the sign of one floating-point value to another.
The definition of copysign is that copysign(x, y) = abs(x) * sign(y)
.
Domain: -INF <= x <= INF
, -INF <= y <= f
Range: -INF <= z <= INF
This function operates on single-precision floating point values, use SDL_copysign for double-precision floats.
x | floating point value to use as the magnitude. |
y | floating point value to use as the sign. |
\threadsafety It is safe to call this function from any thread.
double SDL_cos | ( | double | x | ) |
Compute the cosine of x
.
Domain: -INF <= x <= INF
Range: -1 <= y <= 1
This function operates on double-precision floating point values, use SDL_cosf for single-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value, in radians. |
x
.\threadsafety It is safe to call this function from any thread.
float SDL_cosf | ( | float | x | ) |
Compute the cosine of x
.
Domain: -INF <= x <= INF
Range: -1 <= y <= 1
This function operates on single-precision floating point values, use SDL_cos for double-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value, in radians. |
x
.\threadsafety It is safe to call this function from any thread.
SDL_Environment * SDL_CreateEnvironment | ( | bool | populated | ) |
Create a set of environment variables
populated | true to initialize it from the C runtime environment, false to create an empty environment. |
\threadsafety If populated
is false, it is safe to call this function from any thread, otherwise it is safe if no other threads are calling setenv() or unsetenv()
void SDL_DestroyEnvironment | ( | SDL_Environment * | env | ) |
Destroy a set of environment variables.
env | the environment to destroy. |
\threadsafety It is safe to call this function from any thread, as long as the environment is no longer in use.
double SDL_exp | ( | double | x | ) |
Compute the exponential of x
.
The definition of y = exp(x)
is y = e^x
, where e
is the base of the natural logarithm. The inverse is the natural logarithm, SDL_log.
Domain: -INF <= x <= INF
Range: 0 <= y <= INF
The output will overflow if exp(x)
is too large to be represented.
This function operates on double-precision floating point values, use SDL_expf for single-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. |
e^x
.\threadsafety It is safe to call this function from any thread.
float SDL_expf | ( | float | x | ) |
Compute the exponential of x
.
The definition of y = exp(x)
is y = e^x
, where e
is the base of the natural logarithm. The inverse is the natural logarithm, SDL_logf.
Domain: -INF <= x <= INF
Range: 0 <= y <= INF
The output will overflow if exp(x)
is too large to be represented.
This function operates on single-precision floating point values, use SDL_exp for double-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. |
e^x
.\threadsafety It is safe to call this function from any thread.
double SDL_fabs | ( | double | x | ) |
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.
x | floating point value to use as the magnitude. |
x
.\threadsafety It is safe to call this function from any thread.
float SDL_fabsf | ( | float | x | ) |
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.
x | floating point value to use as the magnitude. |
x
.\threadsafety It is safe to call this function from any thread.
Referenced by SDL_RectsEqualEpsilon().
double SDL_floor | ( | double | x | ) |
Compute the floor of x
.
The floor of x
is the largest integer y
such that y > x
, i.e x
rounded down to the nearest integer.
Domain: -INF <= x <= INF
Range: -INF <= y <= INF
, y integer
This function operates on double-precision floating point values, use SDL_floorf for single-precision floats.
x | floating point value. |
x
.\threadsafety It is safe to call this function from any thread.
float SDL_floorf | ( | float | x | ) |
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.
x | floating point value. |
x
.\threadsafety It is safe to call this function from any thread.
double SDL_fmod | ( | double | x, |
double | y | ||
) |
Return the floating-point remainder of x / y
Divides x
by y
, and returns the remainder.
Domain: -INF <= x <= INF
, -INF <= y <= INF
, y != 0
Range: -y <= z <= y
This function operates on double-precision floating point values, use SDL_fmodf for single-precision floats.
x | the numerator. |
y | the denominator. Must not be 0. |
x / y
.\threadsafety It is safe to call this function from any thread.
float SDL_fmodf | ( | float | x, |
float | y | ||
) |
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.
x | the numerator. |
y | the denominator. Must not be 0. |
x / y
.\threadsafety It is safe to call this function from any thread.
void SDL_free | ( | void * | mem | ) |
Free allocated memory.
The pointer is no longer valid after this call and cannot be dereferenced anymore.
If mem
is NULL, this function does nothing.
mem | a pointer to allocated memory, or NULL. |
\threadsafety It is safe to call this function from any thread.
const char * SDL_getenv | ( | const char * | name | ) |
Get the value of a variable in the environment.
This function uses SDL's cached copy of the environment and is thread-safe.
name | the name of the variable to get. |
\threadsafety It is safe to call this function from any thread.
const char * SDL_getenv_unsafe | ( | const char * | name | ) |
Get the value of a variable in the environment.
This function bypasses SDL's cached copy of the environment and is not thread-safe.
name | the name of the variable to get. |
\threadsafety This function is not thread safe, consider using SDL_getenv() instead.
SDL_Environment * SDL_GetEnvironment | ( | void | ) |
Get the process environment.
This is initialized at application start and is not affected by setenv() and unsetenv() calls after that point. Use SDL_SetEnvironmentVariable() and SDL_UnsetEnvironmentVariable() if you want to modify this environment, or SDL_setenv_unsafe() or SDL_unsetenv_unsafe() if you want changes to persist in the C runtime environment after SDL_Quit().
\threadsafety It is safe to call this function from any thread.
const char * SDL_GetEnvironmentVariable | ( | SDL_Environment * | env, |
const char * | name | ||
) |
Get the value of a variable in the environment.
env | the environment to query. |
name | the name of the variable to get. |
\threadsafety It is safe to call this function from any thread.
char ** SDL_GetEnvironmentVariables | ( | SDL_Environment * | env | ) |
Get all variables in the environment.
env | the environment to query. |
\threadsafety It is safe to call this function from any thread.
void SDL_GetMemoryFunctions | ( | SDL_malloc_func * | malloc_func, |
SDL_calloc_func * | calloc_func, | ||
SDL_realloc_func * | realloc_func, | ||
SDL_free_func * | free_func | ||
) |
Get the current set of SDL memory functions.
malloc_func | filled with malloc function. |
calloc_func | filled with calloc function. |
realloc_func | filled with realloc function. |
free_func | filled with free function. |
\threadsafety This does not hold a lock, so do not call this in the unlikely event of a background thread calling SDL_SetMemoryFunctions simultaneously.
int SDL_GetNumAllocations | ( | void | ) |
Get the number of outstanding (unfreed) allocations.
\threadsafety It is safe to call this function from any thread.
void SDL_GetOriginalMemoryFunctions | ( | SDL_malloc_func * | malloc_func, |
SDL_calloc_func * | calloc_func, | ||
SDL_realloc_func * | realloc_func, | ||
SDL_free_func * | free_func | ||
) |
Get the original set of SDL memory functions.
This is what SDL_malloc and friends will use by default, if there has been no call to SDL_SetMemoryFunctions. This is not necessarily using the C runtime's malloc
functions behind the scenes! Different platforms and build configurations might do any number of unexpected things.
malloc_func | filled with malloc function. |
calloc_func | filled with calloc function. |
realloc_func | filled with realloc function. |
free_func | filled with free function. |
\threadsafety It is safe to call this function from any thread.
size_t SDL_iconv | ( | SDL_iconv_t | cd, |
const char ** | inbuf, | ||
size_t * | inbytesleft, | ||
char ** | outbuf, | ||
size_t * | outbytesleft | ||
) |
This function converts text between encodings, reading from and writing to a buffer.
It returns the number of succesful conversions.
cd | The character set conversion context, created in SDL_iconv_open(). |
inbuf | Address of variable that points to the first character of the input sequence. |
inbytesleft | The number of bytes in the input buffer. |
outbuf | Address of variable that points to the output buffer. |
outbytesleft | The number of bytes in the output buffer. |
On exit:
int SDL_iconv_close | ( | SDL_iconv_t | cd | ) |
This function frees a context used for character set conversion.
cd | The character set conversion handle. |
SDL_iconv_t SDL_iconv_open | ( | const char * | tocode, |
const char * | fromcode | ||
) |
This function allocates a context for the specified character set conversion.
tocode | The target character encoding, must not be NULL. |
fromcode | The source character encoding, must not be NULL. |
char * SDL_iconv_string | ( | const char * | tocode, |
const char * | fromcode, | ||
const char * | inbuf, | ||
size_t | inbytesleft | ||
) |
Helper function to convert a string's encoding in one call.
This function converts a buffer or string between encodings in one pass.
The string does not need to be NULL-terminated; this function operates on the number of bytes specified in inbytesleft
whether there is a NULL character anywhere in the buffer.
The returned string is owned by the caller, and should be passed to SDL_free when no longer needed.
tocode | the character encoding of the output string. Examples are "UTF-8", "UCS-4", etc. |
fromcode | the character encoding of data in inbuf . |
inbuf | the string to convert to a different encoding. |
inbytesleft | the size of the input string in bytes. |
int SDL_isalnum | ( | int | x | ) |
Query if a character is alphabetic (a letter) or a number.
WARNING: Regardless of system locale, this will only treat ASCII values for English 'a-z', 'A-Z', and '0-9' as true.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
int SDL_isalpha | ( | int | x | ) |
Query if a character is alphabetic (a letter).
WARNING: Regardless of system locale, this will only treat ASCII values for English 'a-z' and 'A-Z' as true.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
int SDL_isblank | ( | int | x | ) |
Report if a character is blank (a space or tab).
WARNING: Regardless of system locale, this will only treat ASCII values 0x20 (space) or 0x9 (tab) as true.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
int SDL_iscntrl | ( | int | x | ) |
Report if a character is a control character.
WARNING: Regardless of system locale, this will only treat ASCII values 0 through 0x1F, and 0x7F, as true.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
int SDL_isdigit | ( | int | x | ) |
Report if a character is a numeric digit.
WARNING: Regardless of system locale, this will only treat ASCII values '0' (0x30) through '9' (0x39), as true.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
int SDL_isgraph | ( | int | x | ) |
Report if a character is any "printable" except space.
Be advised that "printable" has a definition that goes back to text terminals from the dawn of computing, making this a sort of special case function that is not suitable for Unicode (or most any) text management.
WARNING: Regardless of system locale, this is equivalent to ‘(SDL_isprint(x)) && ((x) != ’ ')`.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
int SDL_isinf | ( | double | x | ) |
Return whether the value is infinity.
x | double-precision floating point value. |
\threadsafety It is safe to call this function from any thread.
int SDL_isinff | ( | float | x | ) |
Return whether the value is infinity.
x | floating point value. |
\threadsafety It is safe to call this function from any thread.
int SDL_islower | ( | int | x | ) |
Report if a character is lower case.
WARNING: Regardless of system locale, this will only treat ASCII values 'a' through 'z' as true.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
int SDL_isnan | ( | double | x | ) |
Return whether the value is NaN.
x | double-precision floating point value. |
\threadsafety It is safe to call this function from any thread.
int SDL_isnanf | ( | float | x | ) |
Return whether the value is NaN.
x | floating point value. |
\threadsafety It is safe to call this function from any thread.
int SDL_isprint | ( | int | x | ) |
Report if a character is "printable".
Be advised that "printable" has a definition that goes back to text terminals from the dawn of computing, making this a sort of special case function that is not suitable for Unicode (or most any) text management.
WARNING: Regardless of system locale, this will only treat ASCII values ' ' (0x20) through '~' (0x7E) as true.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
int SDL_ispunct | ( | int | x | ) |
Report if a character is a punctuation mark.
WARNING: Regardless of system locale, this is equivalent to ((SDL_isgraph(x)) && (!SDL_isalnum(x)))
.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
int SDL_isspace | ( | int | x | ) |
Report if a character is whitespace.
WARNING: Regardless of system locale, this will only treat the following ASCII values as true:
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
int SDL_isupper | ( | int | x | ) |
Report if a character is upper case.
WARNING: Regardless of system locale, this will only treat ASCII values 'A' through 'Z' as true.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
int SDL_isxdigit | ( | int | x | ) |
Report if a character is a hexadecimal digit.
WARNING: Regardless of system locale, this will only treat ASCII values 'A' through 'F', 'a' through 'f', and '0' through '9', as true.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
char * SDL_itoa | ( | int | value, |
char * | str, | ||
int | radix | ||
) |
char * SDL_lltoa | ( | long long | value, |
char * | str, | ||
int | radix | ||
) |
double SDL_log | ( | double | x | ) |
Compute the natural logarithm of x
.
Domain: 0 < x <= INF
Range: -INF <= y <= INF
It is an error for x
to be less than or equal to 0.
This function operates on double-precision floating point values, use SDL_logf for single-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. Must be greater than 0. |
x
.\threadsafety It is safe to call this function from any thread.
double SDL_log10 | ( | double | x | ) |
Compute the base-10 logarithm of x
.
Domain: 0 < x <= INF
Range: -INF <= y <= INF
It is an error for x
to be less than or equal to 0.
This function operates on double-precision floating point values, use SDL_log10f for single-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. Must be greater than 0. |
x
.\threadsafety It is safe to call this function from any thread.
float SDL_log10f | ( | float | x | ) |
Compute the base-10 logarithm of x
.
Domain: 0 < x <= INF
Range: -INF <= y <= INF
It is an error for x
to be less than or equal to 0.
This function operates on single-precision floating point values, use SDL_log10 for double-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. Must be greater than 0. |
x
.\threadsafety It is safe to call this function from any thread.
float SDL_logf | ( | float | x | ) |
Compute the natural logarithm of x
.
Domain: 0 < x <= INF
Range: -INF <= y <= INF
It is an error for x
to be less than or equal to 0.
This function operates on single-precision floating point values, use SDL_log for double-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. Must be greater than 0. |
x
.\threadsafety It is safe to call this function from any thread.
long SDL_lround | ( | double | x | ) |
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.
x | floating point value. |
x
.\threadsafety It is safe to call this function from any thread.
long SDL_lroundf | ( | float | x | ) |
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,
x | floating point value. |
x
.\threadsafety It is safe to call this function from any thread.
char * SDL_ltoa | ( | long | value, |
char * | str, | ||
int | radix | ||
) |
SDL_MALLOC void * SDL_malloc | ( | size_t | size | ) |
Allocate uninitialized memory.
The allocated memory returned by this function must be freed with SDL_free().
If size
is 0, it will be set to 1.
If you want to allocate memory aligned to a specific alignment, consider using SDL_aligned_alloc().
size | the size to allocate. |
\threadsafety It is safe to call this function from any thread.
int SDL_memcmp | ( | const void * | s1, |
const void * | s2, | ||
size_t | len | ||
) |
void * SDL_memcpy | ( | SDL_OUT_BYTECAP(len) void * | dst, |
SDL_IN_BYTECAP(len) const void * | src, | ||
size_t | len | ||
) |
Copy non-overlapping memory.
The memory regions must not overlap. If they do, use SDL_memmove() instead.
dst | The destination memory region. Must not be NULL, and must not overlap with src . |
src | The source memory region. Must not be NULL, and must not overlap with dst . |
len | The length in bytes of both dst and src . |
dst
.\threadsafety It is safe to call this function from any thread.
void * SDL_memmove | ( | SDL_OUT_BYTECAP(len) void * | dst, |
SDL_IN_BYTECAP(len) const void * | src, | ||
size_t | len | ||
) |
Copy memory.
It is okay for the memory regions to overlap. If you are confident that the regions never overlap, using SDL_memcpy() may improve performance.
dst | The destination memory region. Must not be NULL. |
src | The source memory region. Must not be NULL. |
len | The length in bytes of both dst and src . |
dst
.\threadsafety It is safe to call this function from any thread.
void * SDL_memset | ( | SDL_OUT_BYTECAP(len) void * | dst, |
int | c, | ||
size_t | len | ||
) |
void * SDL_memset4 | ( | void * | dst, |
Uint32 | val, | ||
size_t | dwords | ||
) |
double SDL_modf | ( | double | x, |
double * | y | ||
) |
Split x
into integer and fractional parts
This function operates on double-precision floating point values, use SDL_modff for single-precision floats.
x | floating point value. |
y | output pointer to store the integer part of x . |
x
.\threadsafety It is safe to call this function from any thread.
float SDL_modff | ( | float | x, |
float * | y | ||
) |
Split x
into integer and fractional parts
This function operates on single-precision floating point values, use SDL_modf for double-precision floats.
x | floating point value. |
y | output pointer to store the integer part of x . |
x
.\threadsafety It is safe to call this function from any thread.
double SDL_pow | ( | double | x, |
double | y | ||
) |
Raise x
to the power y
Domain: -INF <= x <= INF
, -INF <= y <= INF
Range: -INF <= z <= INF
If y
is the base of the natural logarithm (e), consider using SDL_exp instead.
This function operates on double-precision floating point values, use SDL_powf for single-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | the base. |
y | the exponent. |
x
raised to the power y
.\threadsafety It is safe to call this function from any thread.
float SDL_powf | ( | float | x, |
float | y | ||
) |
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.
x | the base. |
y | the exponent. |
x
raised to the power y
.\threadsafety It is safe to call this function from any thread.
void SDL_qsort | ( | void * | base, |
size_t | nmemb, | ||
size_t | size, | ||
SDL_CompareCallback | compare | ||
) |
Sort an array.
For example:
base | a pointer to the start of the array. |
nmemb | the number of elements in the array. |
size | the size of the elements in the array. |
compare | a function used to compare elements in the array. |
\threadsafety It is safe to call this function from any thread.
void SDL_qsort_r | ( | void * | base, |
size_t | nmemb, | ||
size_t | size, | ||
SDL_CompareCallback_r | compare, | ||
void * | userdata | ||
) |
Sort an array, passing a userdata pointer to the compare function.
For example:
base | a pointer to the start of the array. |
nmemb | the number of elements in the array. |
size | the size of the elements in the array. |
compare | a function used to compare elements in the array. |
userdata | a pointer to pass to the compare function. |
\threadsafety It is safe to call this function from any thread.
Generate a pseudo-random number less than n for positive n
The method used is faster and of better quality than rand() % n
. Odds are roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and much worse as n gets bigger.
Example: to simulate a d6 use SDL_rand(6) + 1
The +1 converts 0..5 to 1..6
If you want to generate a pseudo-random number in the full range of Sint32, you should use: (Sint32)SDL_rand_bits()
If you want reproducible output, be sure to initialize with SDL_srand() first.
There are no guarantees as to the quality of the random sequence produced, and this should not be used for security (cryptography, passwords) or where money is on the line (loot-boxes, casinos). There are many random number libraries available with different characteristics and you should pick one of those to meet any serious needs.
n | the number of possible outcomes. n must be positive. |
\threadsafety All calls should be made from a single thread
Uint32 SDL_rand_bits | ( | void | ) |
Generate 32 pseudo-random bits.
You likely want to use SDL_rand() to get a psuedo-random number instead.
There are no guarantees as to the quality of the random sequence produced, and this should not be used for security (cryptography, passwords) or where money is on the line (loot-boxes, casinos). There are many random number libraries available with different characteristics and you should pick one of those to meet any serious needs.
\threadsafety All calls should be made from a single thread
Generate 32 pseudo-random bits.
You likely want to use SDL_rand_r() to get a psuedo-random number instead.
There are no guarantees as to the quality of the random sequence produced, and this should not be used for security (cryptography, passwords) or where money is on the line (loot-boxes, casinos). There are many random number libraries available with different characteristics and you should pick one of those to meet any serious needs.
state | a pointer to the current random number state, this may not be NULL. |
\threadsafety This function is thread-safe, as long as the state pointer isn't shared between threads.
Generate a pseudo-random number less than n for positive n
The method used is faster and of better quality than rand() % n
. Odds are roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and much worse as n gets bigger.
Example: to simulate a d6 use SDL_rand_r(state, 6) + 1
The +1 converts 0..5 to 1..6
If you want to generate a pseudo-random number in the full range of Sint32, you should use: (Sint32)SDL_rand_bits_r(state)
There are no guarantees as to the quality of the random sequence produced, and this should not be used for security (cryptography, passwords) or where money is on the line (loot-boxes, casinos). There are many random number libraries available with different characteristics and you should pick one of those to meet any serious needs.
state | a pointer to the current random number state, this may not be NULL. |
n | the number of possible outcomes. n must be positive. |
\threadsafety This function is thread-safe, as long as the state pointer isn't shared between threads.
float SDL_randf | ( | void | ) |
Generate a uniform pseudo-random floating point number less than 1.0
If you want reproducible output, be sure to initialize with SDL_srand() first.
There are no guarantees as to the quality of the random sequence produced, and this should not be used for security (cryptography, passwords) or where money is on the line (loot-boxes, casinos). There are many random number libraries available with different characteristics and you should pick one of those to meet any serious needs.
\threadsafety All calls should be made from a single thread
float SDL_randf_r | ( | Uint64 * | state | ) |
Generate a uniform pseudo-random floating point number less than 1.0
If you want reproducible output, be sure to initialize with SDL_srand() first.
There are no guarantees as to the quality of the random sequence produced, and this should not be used for security (cryptography, passwords) or where money is on the line (loot-boxes, casinos). There are many random number libraries available with different characteristics and you should pick one of those to meet any serious needs.
state | a pointer to the current random number state, this may not be NULL. |
\threadsafety This function is thread-safe, as long as the state pointer isn't shared between threads.
double SDL_round | ( | double | x | ) |
Round x
to the nearest integer.
Rounds x
to the nearest integer. Values halfway between integers will be rounded away from zero.
Domain: -INF <= x <= INF
Range: -INF <= y <= INF
, y integer
This function operates on double-precision floating point values, use SDL_roundf for single-precision floats. To get the result as an integer type, use SDL_lround.
x | floating point value. |
x
.\threadsafety It is safe to call this function from any thread.
float SDL_roundf | ( | float | x | ) |
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.
x | floating point value. |
x
.\threadsafety It is safe to call this function from any thread.
double SDL_scalbn | ( | double | x, |
int | n | ||
) |
Scale x
by an integer power of two.
Multiplies x
by the n
th power of the floating point radix (always 2).
Domain: -INF <= x <= INF
, n
integer
Range: -INF <= y <= INF
This function operates on double-precision floating point values, use SDL_scalbnf for single-precision floats.
x | floating point value to be scaled. |
n | integer exponent. |
x * 2^n
.\threadsafety It is safe to call this function from any thread.
float SDL_scalbnf | ( | float | x, |
int | n | ||
) |
Scale x
by an integer power of two.
Multiplies x
by the n
th power of the floating point radix (always 2).
Domain: -INF <= x <= INF
, n
integer
Range: -INF <= y <= INF
This function operates on single-precision floating point values, use SDL_scalbn for double-precision floats.
x | floating point value to be scaled. |
n | integer exponent. |
x * 2^n
.\threadsafety It is safe to call this function from any thread.
int SDL_setenv_unsafe | ( | const char * | name, |
const char * | value, | ||
int | overwrite | ||
) |
Set the value of a variable in the environment.
name | the name of the variable to set. |
value | the value of the variable to set. |
overwrite | 1 to overwrite the variable if it exists, 0 to return success without setting the variable if it already exists. |
\threadsafety This function is not thread safe, consider using SDL_SetEnvironmentVariable() instead.
bool SDL_SetEnvironmentVariable | ( | SDL_Environment * | env, |
const char * | name, | ||
const char * | value, | ||
bool | overwrite | ||
) |
Set the value of a variable in the environment.
env | the environment to modify. |
name | the name of the variable to set. |
value | the value of the variable to set. |
overwrite | true to overwrite the variable if it exists, false to return success without setting the variable if it already exists. |
\threadsafety It is safe to call this function from any thread.
bool SDL_SetMemoryFunctions | ( | SDL_malloc_func | malloc_func, |
SDL_calloc_func | calloc_func, | ||
SDL_realloc_func | realloc_func, | ||
SDL_free_func | free_func | ||
) |
Replace SDL's memory allocation functions with a custom set.
It is not safe to call this function once any allocations have been made, as future calls to SDL_free will use the new allocator, even if they came from an SDL_malloc made with the old one!
If used, usually this needs to be the first call made into the SDL library, if not the very first thing done at program startup time.
malloc_func | custom malloc function. |
calloc_func | custom calloc function. |
realloc_func | custom realloc function. |
free_func | custom free function. |
\threadsafety It is safe to call this function from any thread, but one should not replace the memory functions once any allocations are made!
double SDL_sin | ( | double | x | ) |
Compute the sine of x
.
Domain: -INF <= x <= INF
Range: -1 <= y <= 1
This function operates on double-precision floating point values, use SDL_sinf for single-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value, in radians. |
x
.\threadsafety It is safe to call this function from any thread.
float SDL_sinf | ( | float | x | ) |
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.
x | floating point value, in radians. |
x
.\threadsafety It is safe to call this function from any thread.
SDL_FORCE_INLINE bool SDL_size_add_check_overflow | ( | size_t | a, |
size_t | b, | ||
size_t * | ret | ||
) |
Add two integers, checking for overflow.
If a + b
would overflow, return -1.
Otherwise store a + b
via ret and return 0.
a | the first addend. |
b | the second addend. |
ret | on non-overflow output, stores the addition result, may not be NULL. |
\threadsafety It is safe to call this function from any thread.
Definition at line 4374 of file SDL_stdinc.h.
References SDL_SIZE_MAX.
SDL_FORCE_INLINE bool SDL_size_mul_check_overflow | ( | size_t | a, |
size_t | b, | ||
size_t * | ret | ||
) |
Multiply two integers, checking for overflow.
If a * b
would overflow, return false.
Otherwise store a * b
via ret and return true.
a | the multiplicand. |
b | the multiplier. |
ret | on non-overflow output, stores the multiplication result, may not be NULL. |
\threadsafety It is safe to call this function from any thread.
Definition at line 4335 of file SDL_stdinc.h.
References SDL_SIZE_MAX.
int SDL_snprintf | ( | SDL_OUT_Z_CAP(maxlen) char * | text, |
size_t | maxlen, | ||
SDL_PRINTF_FORMAT_STRING const char * | fmt, | ||
... | |||
) |
double SDL_sqrt | ( | double | x | ) |
Compute the square root of x
.
Domain: 0 <= x <= INF
Range: 0 <= y <= INF
This function operates on double-precision floating point values, use SDL_sqrtf for single-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. Must be greater than or equal to 0. |
x
.\threadsafety It is safe to call this function from any thread.
float SDL_sqrtf | ( | float | x | ) |
Compute the square root of x
.
Domain: 0 <= x <= INF
Range: 0 <= y <= INF
This function operates on single-precision floating point values, use SDL_sqrt for double-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value. Must be greater than or equal to 0. |
x
.\threadsafety It is safe to call this function from any thread.
void SDL_srand | ( | Uint64 | seed | ) |
Seeds the pseudo-random number generator.
Reusing the seed number will cause SDL_rand_*() to repeat the same stream of 'random' numbers.
seed | the value to use as a random number seed, or 0 to use SDL_GetPerformanceCounter(). |
\threadsafety This should be called on the same thread that calls SDL_rand*()
int SDL_sscanf | ( | const char * | text, |
SDL_SCANF_FORMAT_STRING const char * | fmt, | ||
... | |||
) |
Uint32 SDL_StepBackUTF8 | ( | const char * | start, |
const char ** | pstr | ||
) |
Decode a UTF-8 string in reverse, one Unicode codepoint at a time.
This will go to the start of the previous Unicode codepoint in the string, move *pstr
to that location and return that codepoint.
If *pstr
is already at the start of the string), it will not advance *pstr
at all.
Generally this function is called in a loop until it returns zero, adjusting its parameter each iteration.
If an invalid UTF-8 sequence is encountered, this function returns SDL_INVALID_UNICODE_CODEPOINT.
Several things can generate invalid UTF-8 sequences, including overlong encodings, the use of UTF-16 surrogate values, and truncated data. Please refer to RFC3629 for details.
start | a pointer to the beginning of the UTF-8 string. |
pstr | a pointer to a UTF-8 string pointer to be read and adjusted. |
\threadsafety It is safe to call this function from any thread.
Uint32 SDL_StepUTF8 | ( | const char ** | pstr, |
size_t * | pslen | ||
) |
Decode a UTF-8 string, one Unicode codepoint at a time.
This will return the first Unicode codepoint in the UTF-8 encoded string in *pstr
, and then advance *pstr
past any consumed bytes before returning.
It will not access more than *pslen
bytes from the string. *pslen
will be adjusted, as well, subtracting the number of bytes consumed.
pslen
is allowed to be NULL, in which case the string must be NULL-terminated, as the function will blindly read until it sees the NULL char.
if *pslen
is zero, it assumes the end of string is reached and returns a zero codepoint regardless of the contents of the string buffer.
If the resulting codepoint is zero (a NULL terminator), or *pslen
is zero, it will not advance *pstr
or *pslen
at all.
Generally this function is called in a loop until it returns zero, adjusting its parameters each iteration.
If an invalid UTF-8 sequence is encountered, this function returns SDL_INVALID_UNICODE_CODEPOINT and advances the string/length by one byte (which is to say, a multibyte sequence might produce several SDL_INVALID_UNICODE_CODEPOINT returns before it syncs to the next valid UTF-8 sequence).
Several things can generate invalid UTF-8 sequences, including overlong encodings, the use of UTF-16 surrogate values, and truncated data. Please refer to RFC3629 for details.
pstr | a pointer to a UTF-8 string pointer to be read and adjusted. |
pslen | a pointer to the number of bytes in the string, to be read and adjusted. NULL is allowed. |
\threadsafety It is safe to call this function from any thread.
int SDL_strcasecmp | ( | const char * | str1, |
const char * | str2 | ||
) |
Compare two null-terminated UTF-8 strings, case-insensitively.
This will work with Unicode strings, using a technique called "case-folding" to handle the vast majority of case-sensitive human languages regardless of system locale. It can deal with expanding values: a German Eszett character can compare against two ASCII 's' chars and be considered a match, for example. A notable exception: it does not handle the Turkish 'i' character; human language is complicated!
Since this handles Unicode, it expects the string to be well-formed UTF-8 and not a null-terminated string of arbitrary bytes. Bytes that are not valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT CHARACTER), which is to say two strings of random bits may turn out to match if they convert to the same amount of replacement characters.
str1 | the first string to compare. NULL is not permitted! |
str2 | the second string to compare. NULL is not permitted! |
\threadsafety It is safe to call this function from any thread.
char * SDL_strcasestr | ( | const char * | haystack, |
const char * | needle | ||
) |
char * SDL_strchr | ( | const char * | str, |
int | c | ||
) |
int SDL_strcmp | ( | const char * | str1, |
const char * | str2 | ||
) |
Compare two null-terminated UTF-8 strings.
Due to the nature of UTF-8 encoding, this will work with Unicode strings, since effectively this function just compares bytes until it hits a null-terminating character. Also due to the nature of UTF-8, this can be used with SDL_qsort() to put strings in (roughly) alphabetical order.
str1 | the first string to compare. NULL is not permitted! |
str2 | the second string to compare. NULL is not permitted! |
\threadsafety It is safe to call this function from any thread.
SDL_MALLOC char * SDL_strdup | ( | const char * | str | ) |
size_t SDL_strlcat | ( | SDL_INOUT_Z_CAP(maxlen) char * | dst, |
const char * | src, | ||
size_t | maxlen | ||
) |
Concatenate strings.
This function appends up to maxlen
- SDL_strlen(dst) - 1 characters from src
to the end of the string in dst
, then appends a null terminator.
src
and dst
must not overlap.
If maxlen
- SDL_strlen(dst) - 1 is less than or equal to 0, then dst
is unmodified.
dst | The destination buffer already containing the first null-terminated string. Must not be NULL and must not overlap with src . |
src | The second null-terminated string. Must not be NULL, and must not overlap with dst . |
maxlen | The length (in characters) of the destination buffer. |
dst
plus the length of src
.\threadsafety It is safe to call this function from any thread.
size_t SDL_strlcpy | ( | SDL_OUT_Z_CAP(maxlen) char * | dst, |
const char * | src, | ||
size_t | maxlen | ||
) |
Copy a string.
This function copies up to maxlen
- 1 characters from src
to dst
, then appends a null terminator.
If maxlen
is 0, no characters are copied and no null terminator is written.
If you want to copy an UTF-8 string but need to ensure that multi-byte sequences are not truncated, consider using SDL_utf8strlcpy().
dst | The destination buffer. Must not be NULL, and must not overlap with src . |
src | The null-terminated string to copy. Must not be NULL, and must not overlap with dst . |
maxlen | The length (in characters) of the destination buffer. |
src
.\threadsafety It is safe to call this function from any thread.
size_t SDL_strlen | ( | const char * | str | ) |
char * SDL_strlwr | ( | char * | str | ) |
Convert a string to lowercase.
WARNING: Regardless of system locale, this will only convert ASCII values 'A' through 'Z' to lowercase.
This function operates on a null-terminated string of bytes–even if it is malformed UTF-8!–and converts ASCII characters 'A' through 'Z' to their lowercase equivalents in-place, returning the original str
pointer.
str | the string to convert in-place. Can not be NULL. |
str
pointer passed into this function.\threadsafety It is safe to call this function from any thread.
int SDL_strncasecmp | ( | const char * | str1, |
const char * | str2, | ||
size_t | maxlen | ||
) |
Compare two UTF-8 strings, case-insensitively, up to a number of bytes.
This will work with Unicode strings, using a technique called "case-folding" to handle the vast majority of case-sensitive human languages regardless of system locale. It can deal with expanding values: a German Eszett character can compare against two ASCII 's' chars and be considered a match, for example. A notable exception: it does not handle the Turkish 'i' character; human language is complicated!
Since this handles Unicode, it expects the string to be well-formed UTF-8 and not a null-terminated string of arbitrary bytes. Bytes that are not valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT CHARACTER), which is to say two strings of random bits may turn out to match if they convert to the same amount of replacement characters.
Note that while this function is intended to be used with UTF-8, maxlen
specifies a byte limit! If the limit lands in the middle of a multi-byte UTF-8 sequence, it may convert a portion of the final character to one or more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not to overflow a buffer.
maxlen
specifies a maximum number of bytes to compare; if the strings match to this number of bytes (or both have matched to a null-terminator character before this number of bytes), they will be considered equal.
str1 | the first string to compare. NULL is not permitted! |
str2 | the second string to compare. NULL is not permitted! |
maxlen | the maximum number of bytes to compare. |
\threadsafety It is safe to call this function from any thread.
int SDL_strncmp | ( | const char * | str1, |
const char * | str2, | ||
size_t | maxlen | ||
) |
Compare two UTF-8 strings up to a number of bytes.
Due to the nature of UTF-8 encoding, this will work with Unicode strings, since effectively this function just compares bytes until it hits a null-terminating character. Also due to the nature of UTF-8, this can be used with SDL_qsort() to put strings in (roughly) alphabetical order.
Note that while this function is intended to be used with UTF-8, it is doing a bytewise comparison, and maxlen
specifies a byte limit! If the limit lands in the middle of a multi-byte UTF-8 sequence, it will only compare a portion of the final character.
maxlen
specifies a maximum number of bytes to compare; if the strings match to this number of bytes (or both have matched to a null-terminator character before this number of bytes), they will be considered equal.
str1 | the first string to compare. NULL is not permitted! |
str2 | the second string to compare. NULL is not permitted! |
maxlen | the maximum number of bytes to compare. |
\threadsafety It is safe to call this function from any thread.
SDL_MALLOC char * SDL_strndup | ( | const char * | str, |
size_t | maxlen | ||
) |
size_t SDL_strnlen | ( | const char * | str, |
size_t | maxlen | ||
) |
char * SDL_strnstr | ( | const char * | haystack, |
const char * | needle, | ||
size_t | maxlen | ||
) |
char * SDL_strpbrk | ( | const char * | str, |
const char * | breakset | ||
) |
Searches a string for the first occurence of any character contained in a breakset, and returns a pointer from the string to that character.
str | The null-terminated string to be searched. Must not be NULL, and must not overlap with breakset . |
breakset | A null-terminated string containing the list of characters to look for. Must not be NULL, and must not overlap with str . |
\threadsafety It is safe to call this function from any thread.
char * SDL_strrchr | ( | const char * | str, |
int | c | ||
) |
char * SDL_strrev | ( | char * | str | ) |
char * SDL_strstr | ( | const char * | haystack, |
const char * | needle | ||
) |
double SDL_strtod | ( | const char * | str, |
char ** | endp | ||
) |
Parse a double
from a string.
This function makes fewer guarantees than the C runtime strtod
:
str | The null-terminated string to read. Must not be NULL. |
endp | If not NULL, the address of the first invalid character (i.e. the next character after the parsed number) will be written to this pointer. |
double
, or 0 if no number could be parsed.\threadsafety It is safe to call this function from any thread.
char * SDL_strtok_r | ( | char * | s1, |
const char * | s2, | ||
char ** | saveptr | ||
) |
long SDL_strtol | ( | const char * | str, |
char ** | endp, | ||
int | base | ||
) |
Parse a long
from a string.
If str
starts with whitespace, then those whitespace characters are skipped before attempting to parse the number.
If the parsed number does not fit inside a long
, the result is clamped to the minimum and maximum representable long
values.
str | The null-terminated string to read. Must not be NULL. |
endp | If not NULL, the address of the first invalid character (i.e. the next character after the parsed number) will be written to this pointer. |
base | The base of the integer to read. Supported values are 0 and 2 to 36 inclusive. If 0, the base will be inferred from the number's prefix (0x for hexadecimal, 0 for octal, decimal otherwise). |
long
, or 0 if no number could be parsed.\threadsafety It is safe to call this function from any thread.
long long SDL_strtoll | ( | const char * | str, |
char ** | endp, | ||
int | base | ||
) |
Parse a long long
from a string.
If str
starts with whitespace, then those whitespace characters are skipped before attempting to parse the number.
If the parsed number does not fit inside a long long
, the result is clamped to the minimum and maximum representable long long
values.
str | The null-terminated string to read. Must not be NULL. |
endp | If not NULL, the address of the first invalid character (i.e. the next character after the parsed number) will be written to this pointer. |
base | The base of the integer to read. Supported values are 0 and 2 to 36 inclusive. If 0, the base will be inferred from the number's prefix (0x for hexadecimal, 0 for octal, decimal otherwise). |
long long
, or 0 if no number could be parsed.\threadsafety It is safe to call this function from any thread.
unsigned long SDL_strtoul | ( | const char * | str, |
char ** | endp, | ||
int | base | ||
) |
Parse an unsigned long
from a string.
If str
starts with whitespace, then those whitespace characters are skipped before attempting to parse the number.
If the parsed number does not fit inside an unsigned long
, the result is clamped to the maximum representable unsigned long
value.
str | The null-terminated string to read. Must not be NULL. |
endp | If not NULL, the address of the first invalid character (i.e. the next character after the parsed number) will be written to this pointer. |
base | The base of the integer to read. Supported values are 0 and 2 to 36 inclusive. If 0, the base will be inferred from the number's prefix (0x for hexadecimal, 0 for octal, decimal otherwise). |
unsigned long
, or 0 if no number could be parsed.\threadsafety It is safe to call this function from any thread.
unsigned long long SDL_strtoull | ( | const char * | str, |
char ** | endp, | ||
int | base | ||
) |
Parse an unsigned long long
from a string.
If str
starts with whitespace, then those whitespace characters are skipped before attempting to parse the number.
If the parsed number does not fit inside an unsigned long long
, the result is clamped to the maximum representable unsigned long long
value.
str | The null-terminated string to read. Must not be NULL. |
endp | If not NULL, the address of the first invalid character (i.e. the next character after the parsed number) will be written to this pointer. |
base | The base of the integer to read. Supported values are 0 and 2 to 36 inclusive. If 0, the base will be inferred from the number's prefix (0x for hexadecimal, 0 for octal, decimal otherwise). |
unsigned long long
, or 0 if no number could be parsed.\threadsafety It is safe to call this function from any thread.
char * SDL_strupr | ( | char * | str | ) |
Convert a string to uppercase.
WARNING: Regardless of system locale, this will only convert ASCII values 'A' through 'Z' to uppercase.
This function operates on a null-terminated string of bytes–even if it is malformed UTF-8!–and converts ASCII characters 'a' through 'z' to their uppercase equivalents in-place, returning the original str
pointer.
str | the string to convert in-place. Can not be NULL. |
str
pointer passed into this function.\threadsafety It is safe to call this function from any thread.
int SDL_swprintf | ( | SDL_OUT_Z_CAP(maxlen) wchar_t * | text, |
size_t | maxlen, | ||
SDL_PRINTF_FORMAT_STRING const wchar_t * | fmt, | ||
... | |||
) |
double SDL_tan | ( | double | x | ) |
Compute the tangent of x
.
Domain: -INF <= x <= INF
Range: -INF <= y <= INF
This function operates on double-precision floating point values, use SDL_tanf for single-precision floats.
This function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated.
x | floating point value, in radians. |
x
.\threadsafety It is safe to call this function from any thread.
float SDL_tanf | ( | float | x | ) |
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.
x | floating point value, in radians. |
x
.\threadsafety It is safe to call this function from any thread.
int SDL_tolower | ( | int | x | ) |
Convert low-ASCII English letters to lowercase.
WARNING: Regardless of system locale, this will only convert ASCII values 'A' through 'Z' to lowercase.
This function returns the lowercase equivalent of x
. If a character cannot be converted, or is already lowercase, this function returns x
.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
int SDL_toupper | ( | int | x | ) |
Convert low-ASCII English letters to uppercase.
WARNING: Regardless of system locale, this will only convert ASCII values 'a' through 'z' to uppercase.
This function returns the uppercase equivalent of x
. If a character cannot be converted, or is already uppercase, this function returns x
.
x | character value to check. |
\threadsafety It is safe to call this function from any thread.
double SDL_trunc | ( | double | x | ) |
Truncate x
to an integer.
Rounds x
to the next closest integer to 0. This is equivalent to removing the fractional part of x
, leaving only the integer part.
Domain: -INF <= x <= INF
Range: -INF <= y <= INF
, y integer
This function operates on double-precision floating point values, use SDL_truncf for single-precision floats.
x | floating point value. |
x
truncated to an integer.\threadsafety It is safe to call this function from any thread.
float SDL_truncf | ( | float | x | ) |
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.
x | floating point value. |
x
truncated to an integer.\threadsafety It is safe to call this function from any thread.
char * SDL_UCS4ToUTF8 | ( | Uint32 | codepoint, |
char * | dst | ||
) |
Convert a single Unicode codepoint to UTF-8.
The buffer pointed to by dst
must be at least 4 bytes long, as this function may generate between 1 and 4 bytes of output.
This function returns the first byte after the newly-written UTF-8 sequence, which is useful for encoding multiple codepoints in a loop, or knowing where to write a NULL-terminator character to end the string (in either case, plan to have a buffer of more than 4 bytes!).
If codepoint
is an invalid value (outside the Unicode range, or a UTF-16 surrogate value, etc), this will use U+FFFD (REPLACEMENT CHARACTER) for the codepoint instead, and not set an error.
If dst
is NULL, this returns NULL immediately without writing to the pointer and without setting an error.
codepoint | a Unicode codepoint to convert to UTF-8. |
dst | the location to write the encoded UTF-8. Must point to at least 4 bytes! |
\threadsafety It is safe to call this function from any thread.
char * SDL_uitoa | ( | unsigned int | value, |
char * | str, | ||
int | radix | ||
) |
char * SDL_ulltoa | ( | unsigned long long | value, |
char * | str, | ||
int | radix | ||
) |
char * SDL_ultoa | ( | unsigned long | value, |
char * | str, | ||
int | radix | ||
) |
int SDL_unsetenv_unsafe | ( | const char * | name | ) |
Clear a variable from the environment.
name | the name of the variable to unset. |
\threadsafety This function is not thread safe, consider using SDL_UnsetEnvironmentVariable() instead.
bool SDL_UnsetEnvironmentVariable | ( | SDL_Environment * | env, |
const char * | name | ||
) |
Clear a variable from the environment.
env | the environment to modify. |
name | the name of the variable to unset. |
\threadsafety It is safe to call this function from any thread.
size_t SDL_utf8strlcpy | ( | SDL_OUT_Z_CAP(dst_bytes) char * | dst, |
const char * | src, | ||
size_t | dst_bytes | ||
) |
Copy an UTF-8 string.
This function copies up to dst_bytes
- 1 bytes from src
to dst
while also ensuring that the string written to dst
does not end in a truncated multi-byte sequence. Finally, it appends a null terminator.
src
and dst
must not overlap.
Note that unlike SDL_strlcpy(), this function returns the number of bytes written, not the length of src
.
dst | The destination buffer. Must not be NULL, and must not overlap with src . |
src | The null-terminated UTF-8 string to copy. Must not be NULL, and must not overlap with dst . |
dst_bytes | The length (in bytes) of the destination buffer. Must not be 0. |
\threadsafety It is safe to call this function from any thread.
size_t SDL_utf8strlen | ( | const char * | str | ) |
size_t SDL_utf8strnlen | ( | const char * | str, |
size_t | bytes | ||
) |
int SDL_vasprintf | ( | char ** | strp, |
SDL_PRINTF_FORMAT_STRING const char * | fmt, | ||
va_list | ap | ||
) |
int SDL_vsnprintf | ( | SDL_OUT_Z_CAP(maxlen) char * | text, |
size_t | maxlen, | ||
SDL_PRINTF_FORMAT_STRING const char * | fmt, | ||
va_list | ap | ||
) |
int SDL_vsscanf | ( | const char * | text, |
SDL_SCANF_FORMAT_STRING const char * | fmt, | ||
va_list | ap | ||
) |
int SDL_vswprintf | ( | SDL_OUT_Z_CAP(maxlen) wchar_t * | text, |
size_t | maxlen, | ||
SDL_PRINTF_FORMAT_STRING const wchar_t * | fmt, | ||
va_list | ap | ||
) |
int SDL_wcscasecmp | ( | const wchar_t * | str1, |
const wchar_t * | str2 | ||
) |
Compare two null-terminated wide strings, case-insensitively.
This will work with Unicode strings, using a technique called "case-folding" to handle the vast majority of case-sensitive human languages regardless of system locale. It can deal with expanding values: a German Eszett character can compare against two ASCII 's' chars and be considered a match, for example. A notable exception: it does not handle the Turkish 'i' character; human language is complicated!
Depending on your platform, "wchar_t" might be 2 bytes, and expected to be UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this handles Unicode, it expects the string to be well-formed and not a null-terminated string of arbitrary bytes. Characters that are not valid UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT CHARACTER), which is to say two strings of random bits may turn out to match if they convert to the same amount of replacement characters.
str1 | the first string to compare. NULL is not permitted! |
str2 | the second string to compare. NULL is not permitted! |
\threadsafety It is safe to call this function from any thread.
int SDL_wcscmp | ( | const wchar_t * | str1, |
const wchar_t * | str2 | ||
) |
Compare two null-terminated wide strings.
This only compares wchar_t values until it hits a null-terminating character; it does not care if the string is well-formed UTF-16 (or UTF-32, depending on your platform's wchar_t size), or uses valid Unicode values.
str1 | the first string to compare. NULL is not permitted! |
str2 | the second string to compare. NULL is not permitted! |
\threadsafety It is safe to call this function from any thread.
wchar_t * SDL_wcsdup | ( | const wchar_t * | wstr | ) |
size_t SDL_wcslcat | ( | SDL_INOUT_Z_CAP(maxlen) wchar_t * | dst, |
const wchar_t * | src, | ||
size_t | maxlen | ||
) |
Concatenate wide strings.
This function appends up to maxlen
- SDL_wcslen(dst) - 1 wide characters from src
to the end of the wide string in dst
, then appends a null terminator.
src
and dst
must not overlap.
If maxlen
- SDL_wcslen(dst) - 1 is less than or equal to 0, then dst
is unmodified.
dst | The destination buffer already containing the first null-terminated wide string. Must not be NULL and must not overlap with src . |
src | The second null-terminated wide string. Must not be NULL, and must not overlap with dst . |
maxlen | The length (in wide characters) of the destination buffer. |
dst
plus the length of src
.\threadsafety It is safe to call this function from any thread.
size_t SDL_wcslcpy | ( | SDL_OUT_Z_CAP(maxlen) wchar_t * | dst, |
const wchar_t * | src, | ||
size_t | maxlen | ||
) |
Copy a wide string.
This function copies maxlen
- 1 wide characters from src
to dst
, then appends a null terminator.
src
and dst
must not overlap.
If maxlen
is 0, no wide characters are copied and no null terminator is written.
dst | The destination buffer. Must not be NULL, and must not overlap with src . |
src | The null-terminated wide string to copy. Must not be NULL, and must not overlap with dst . |
maxlen | The length (in wide characters) of the destination buffer. |
src
.\threadsafety It is safe to call this function from any thread.
size_t SDL_wcslen | ( | const wchar_t * | wstr | ) |
int SDL_wcsncasecmp | ( | const wchar_t * | str1, |
const wchar_t * | str2, | ||
size_t | maxlen | ||
) |
Compare two wide strings, case-insensitively, up to a number of wchar_t.
This will work with Unicode strings, using a technique called "case-folding" to handle the vast majority of case-sensitive human languages regardless of system locale. It can deal with expanding values: a German Eszett character can compare against two ASCII 's' chars and be considered a match, for example. A notable exception: it does not handle the Turkish 'i' character; human language is complicated!
Depending on your platform, "wchar_t" might be 2 bytes, and expected to be UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this handles Unicode, it expects the string to be well-formed and not a null-terminated string of arbitrary bytes. Characters that are not valid UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT CHARACTER), which is to say two strings of random bits may turn out to match if they convert to the same amount of replacement characters.
Note that while this function might deal with variable-sized characters, maxlen
specifies a wchar limit! If the limit lands in the middle of a multi-byte UTF-16 sequence, it may convert a portion of the final character to one or more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not to overflow a buffer.
maxlen
specifies a maximum number of wchar_t values to compare; if the strings match to this number of wchar_t (or both have matched to a null-terminator character before this number of bytes), they will be considered equal.
str1 | the first string to compare. NULL is not permitted! |
str2 | the second string to compare. NULL is not permitted! |
maxlen | the maximum number of wchar_t values to compare. |
\threadsafety It is safe to call this function from any thread.
int SDL_wcsncmp | ( | const wchar_t * | str1, |
const wchar_t * | str2, | ||
size_t | maxlen | ||
) |
Compare two wide strings up to a number of wchar_t values.
This only compares wchar_t values; it does not care if the string is well-formed UTF-16 (or UTF-32, depending on your platform's wchar_t size), or uses valid Unicode values.
Note that while this function is intended to be used with UTF-16 (or UTF-32, depending on your platform's definition of wchar_t), it is comparing raw wchar_t values and not Unicode codepoints: maxlen
specifies a wchar_t limit! If the limit lands in the middle of a multi-wchar UTF-16 sequence, it will only compare a portion of the final character.
maxlen
specifies a maximum number of wchar_t to compare; if the strings match to this number of wide chars (or both have matched to a null-terminator character before this count), they will be considered equal.
str1 | the first string to compare. NULL is not permitted! |
str2 | the second string to compare. NULL is not permitted! |
maxlen | the maximum number of wchar_t to compare. |
\threadsafety It is safe to call this function from any thread.
size_t SDL_wcsnlen | ( | const wchar_t * | wstr, |
size_t | maxlen | ||
) |
wchar_t * SDL_wcsnstr | ( | const wchar_t * | haystack, |
const wchar_t * | needle, | ||
size_t | maxlen | ||
) |
wchar_t * SDL_wcsstr | ( | const wchar_t * | haystack, |
const wchar_t * | needle | ||
) |
long SDL_wcstol | ( | const wchar_t * | str, |
wchar_t ** | endp, | ||
int | base | ||
) |
Parse a long
from a wide string.
If str
starts with whitespace, then those whitespace characters are skipped before attempting to parse the number.
If the parsed number does not fit inside a long
, the result is clamped to the minimum and maximum representable long
values.
str | The null-terminated wide string to read. Must not be NULL. |
endp | If not NULL, the address of the first invalid wide character (i.e. the next character after the parsed number) will be written to this pointer. |
base | The base of the integer to read. Supported values are 0 and 2 to 36 inclusive. If 0, the base will be inferred from the number's prefix (0x for hexadecimal, 0 for octal, decimal otherwise). |
long
, or 0 if no number could be parsed.\threadsafety It is safe to call this function from any thread.
size_t size |
Definition at line 734 of file SDL_stdinc.h.