SDL  2.0
SDL_stdinc.h File Reference
#include "SDL_config.h"
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <strings.h>
#include <inttypes.h>
#include <ctype.h>
#include <math.h>
#include "begin_code.h"
#include <alloca.h>
#include "close_code.h"
+ Include dependency graph for SDL_stdinc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SDL_arraysize(array)   (sizeof(array)/sizeof(array[0]))
 
#define SDL_TABLESIZE(table)   SDL_arraysize(table)
 
#define SDL_STRINGIFY_ARG(arg)   #arg
 
#define SDL_FOURCC(A, B, C, D)
 
#define SDL_PRIs64   "I64d"
 
#define SDL_PRIu64   "I64u"
 
#define SDL_PRIx64   "I64x"
 
#define SDL_PRIX64   "I64X"
 
#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_SCANF_VARARG_FUNC(fmtargnumber)
 
#define SDL_COMPILE_TIME_ASSERT(name, x)   typedef int SDL_dummy_ ## name[(x) * 2 - 1]
 
#define SDL_stack_alloc(type, count)   (type*)alloca(sizeof(type)*(count))
 
#define SDL_stack_free(data)
 
#define SDL_min(x, y)   (((x) < (y)) ? (x) : (y))
 
#define SDL_max(x, y)   (((x) > (y)) ? (x) : (y))
 
#define SDL_zero(x)   SDL_memset(&(x), 0, sizeof((x)))
 
#define SDL_zerop(x)   SDL_memset((x), 0, sizeof(*(x)))
 
#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-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
 
#define SDL_iconv_utf8_ucs4(S)   (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
 
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))
 

Functions

voidSDL_malloc (size_t size)
 
voidSDL_calloc (size_t nmemb, size_t size)
 
voidSDL_realloc (void *mem, size_t size)
 
void SDL_free (void *mem)
 
char * SDL_getenv (const char *name)
 
int SDL_setenv (const char *name, const char *value, int overwrite)
 
void SDL_qsort (void *base, size_t nmemb, size_t size, int(*compare)(const void *, const void *))
 
int SDL_abs (int x)
 
int SDL_isdigit (int x)
 
int SDL_isspace (int x)
 
int SDL_toupper (int x)
 
int SDL_tolower (int x)
 
voidSDL_memset (SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
 
SDL_FORCE_INLINE void SDL_memset4 (void *dst, Uint32 val, size_t dwords)
 
voidSDL_memcpy (SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
 
voidSDL_memmove (SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
 
int SDL_memcmp (const void *s1, const void *s2, size_t len)
 
size_t SDL_wcslen (const wchar_t *wstr)
 
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)
 
size_t SDL_strlen (const char *str)
 
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)
 
char * SDL_strdup (const char *str)
 
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_itoa (int value, char *str, int radix)
 
char * SDL_uitoa (unsigned int value, char *str, int radix)
 
char * SDL_ltoa (long value, char *str, int radix)
 
char * SDL_ultoa (unsigned long value, char *str, int radix)
 
char * SDL_lltoa (Sint64 value, char *str, int radix)
 
char * SDL_ulltoa (Uint64 value, char *str, int radix)
 
int SDL_atoi (const char *str)
 
double SDL_atof (const char *str)
 
long SDL_strtol (const char *str, char **endp, int base)
 
unsigned long SDL_strtoul (const char *str, char **endp, int base)
 
Sint64 SDL_strtoll (const char *str, char **endp, int base)
 
Uint64 SDL_strtoull (const char *str, char **endp, int base)
 
double SDL_strtod (const char *str, char **endp)
 
int SDL_strcmp (const char *str1, const char *str2)
 
int SDL_strncmp (const char *str1, const char *str2, size_t maxlen)
 
int SDL_strcasecmp (const char *str1, const char *str2)
 
int SDL_strncasecmp (const char *str1, const char *str2, size_t len)
 
int SDL_sscanf (const char *text, SDL_SCANF_FORMAT_STRING const char *fmt,...) SDL_SCANF_VARARG_FUNC(2)
 
int SDL_vsscanf (const char *text, const char *fmt, va_list ap)
 
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_vsnprintf (SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
 
double SDL_acos (double x)
 
double SDL_asin (double x)
 
double SDL_atan (double x)
 
double SDL_atan2 (double x, double y)
 
double SDL_ceil (double x)
 
double SDL_copysign (double x, double y)
 
double SDL_cos (double x)
 
float SDL_cosf (float x)
 
double SDL_fabs (double x)
 
double SDL_floor (double x)
 
double SDL_log (double x)
 
double SDL_pow (double x, double y)
 
double SDL_scalbn (double 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 voidSDL_memcpy4 (SDL_OUT_BYTECAP(dwords *4) void *dst, SDL_IN_BYTECAP(dwords *4) const void *src, size_t dwords)
 

Basic data types

#define SDL_MAX_SINT32   ((Sint32)0x7FFFFFFF) /* 2147483647 */
 A signed 32-bit integer type. More...
 
#define SDL_MIN_SINT32   ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */
 
enum  SDL_bool {
  SDL_FALSE = 0,
  SDL_TRUE = 1
}
 
typedef int8_t Sint8
 A signed 8-bit integer type. More...
 
typedef uint8_t Uint8
 An unsigned 8-bit integer type. More...
 
typedef int16_t Sint16
 A signed 16-bit integer type. More...
 
typedef uint16_t Uint16
 An unsigned 16-bit integer type. More...
 
typedef int32_t Sint32
 
typedef uint32_t Uint32
 An unsigned 32-bit integer type. More...
 
typedef int64_t Sint64
 A signed 64-bit integer type. More...
 
typedef uint64_t Uint64
 An unsigned 64-bit integer type. More...
 

Detailed Description

This is a general header that includes C language support.

Definition in file SDL_stdinc.h.

Macro Definition Documentation

◆ SDL_arraysize

◆ SDL_COMPILE_TIME_ASSERT

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

Definition at line 266 of file SDL_stdinc.h.

◆ SDL_const_cast

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

Definition at line 114 of file SDL_stdinc.h.

Referenced by SDL_strchr(), SDL_strrchr(), SDL_strstr(), and SDL_TLSSet().

◆ SDL_FOURCC

#define SDL_FOURCC (   A,
  B,
  C,
 
)
Value:
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:161
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define SDL_static_cast(type, expression)
Definition: SDL_stdinc.h:113

Definition at line 119 of file SDL_stdinc.h.

◆ SDL_ICONV_E2BIG

#define SDL_ICONV_E2BIG   (size_t)-2

Definition at line 468 of file SDL_stdinc.h.

Referenced by SDL_iconv(), and SDL_iconv_string().

◆ SDL_ICONV_EILSEQ

#define SDL_ICONV_EILSEQ   (size_t)-3

Definition at line 469 of file SDL_stdinc.h.

Referenced by SDL_iconv_string().

◆ SDL_ICONV_EINVAL

#define SDL_ICONV_EINVAL   (size_t)-4

Definition at line 470 of file SDL_stdinc.h.

Referenced by SDL_iconv(), and SDL_iconv_string().

◆ SDL_ICONV_ERROR

#define SDL_ICONV_ERROR   (size_t)-1

Definition at line 467 of file SDL_stdinc.h.

Referenced by SDL_iconv_string().

◆ SDL_iconv_utf8_locale

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

Definition at line 488 of file SDL_stdinc.h.

◆ SDL_iconv_utf8_ucs2

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

Definition at line 489 of file SDL_stdinc.h.

◆ SDL_iconv_utf8_ucs4

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

Definition at line 490 of file SDL_stdinc.h.

◆ SDL_IN_BYTECAP

#define SDL_IN_BYTECAP (   x)

Definition at line 248 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_INOUT_Z_CAP

#define SDL_INOUT_Z_CAP (   x)

Definition at line 249 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_max

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

◆ SDL_MAX_SINT32

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

A signed 32-bit integer type.

Definition at line 155 of file SDL_stdinc.h.

Referenced by SDL_CreateRGBSurfaceWithFormat().

◆ SDL_min

◆ SDL_MIN_SINT32

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

Definition at line 156 of file SDL_stdinc.h.

◆ SDL_OUT_BYTECAP

#define SDL_OUT_BYTECAP (   x)

Definition at line 252 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_OUT_CAP

#define SDL_OUT_CAP (   x)

Definition at line 251 of file SDL_stdinc.h.

◆ SDL_OUT_Z_BYTECAP

#define SDL_OUT_Z_BYTECAP (   x)

Definition at line 253 of file SDL_stdinc.h.

◆ SDL_OUT_Z_CAP

#define SDL_OUT_Z_CAP (   x)

Definition at line 250 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_PRINTF_FORMAT_STRING

#define SDL_PRINTF_FORMAT_STRING

Definition at line 254 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_PRINTF_VARARG_FUNC

#define SDL_PRINTF_VARARG_FUNC (   fmtargnumber)

Definition at line 261 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_PRIs64

◆ SDL_PRIu64

◆ SDL_PRIx64

#define SDL_PRIx64   "I64x"

Definition at line 203 of file SDL_stdinc.h.

◆ SDL_PRIX64

#define SDL_PRIX64   "I64X"

Definition at line 214 of file SDL_stdinc.h.

Referenced by platform_testEndianessAndSwap(), and TestEndian().

◆ SDL_reinterpret_cast

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

Definition at line 112 of file SDL_stdinc.h.

◆ SDL_SCANF_FORMAT_STRING

#define SDL_SCANF_FORMAT_STRING

Definition at line 255 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_SCANF_VARARG_FUNC

#define SDL_SCANF_VARARG_FUNC (   fmtargnumber)

Definition at line 262 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_stack_alloc

◆ SDL_stack_free

◆ SDL_static_cast

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

Definition at line 113 of file SDL_stdinc.h.

Referenced by SDL_memset4(), SDL_Swap16(), SDL_Swap32(), and SDL_Swap64().

◆ SDL_STRINGIFY_ARG

#define SDL_STRINGIFY_ARG (   arg)    #arg

Macro useful for building other macros with strings in them

e.g. #define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(FUNCTION) ": " X "\n")

Definition at line 98 of file SDL_stdinc.h.

◆ SDL_TABLESIZE

#define SDL_TABLESIZE (   table)    SDL_arraysize(table)

Definition at line 91 of file SDL_stdinc.h.

◆ SDL_zero

◆ SDL_zerop

Typedef Documentation

◆ Sint16

typedef int16_t Sint16

A signed 16-bit integer type.

Definition at line 147 of file SDL_stdinc.h.

◆ Sint32

typedef int32_t Sint32

Definition at line 157 of file SDL_stdinc.h.

◆ Sint64

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) a int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64

A signed 64-bit integer type.

Definition at line 166 of file SDL_stdinc.h.

◆ Sint8

typedef int8_t Sint8

A signed 8-bit integer type.

Definition at line 139 of file SDL_stdinc.h.

◆ Uint16

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) d int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16

An unsigned 16-bit integer type.

Definition at line 151 of file SDL_stdinc.h.

◆ Uint32

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) e int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16 return SDL_Window const char return SDL_GLattr int return SDL_Window return return SDL_Window int int return SDL_GLContext SDL_RWops int return return void return int int return double return SDL_bool return int int return SDL_AudioDeviceID const void Uint32 return SDL_AudioDeviceID int float float float return SDL_JoystickID return int SDL_Rect return SDL_Window float return SDL_Window return SDL_Renderer SDL_bool return SDL_AudioDeviceID void Uint32 return Uint32 int int int Uint32

An unsigned 32-bit integer type.

Definition at line 161 of file SDL_stdinc.h.

◆ Uint64

typedef uint64_t Uint64

An unsigned 64-bit integer type.

Definition at line 170 of file SDL_stdinc.h.

◆ Uint8

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) b int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8

An unsigned 8-bit integer type.

Definition at line 143 of file SDL_stdinc.h.

Enumeration Type Documentation

◆ SDL_bool

enum SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) b int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16 return SDL_Window const char return SDL_GLattr int return SDL_Window return return SDL_Window int int return SDL_GLContext SDL_RWops int return return void return int int return double return SDL_bool return int int return SDL_AudioDeviceID const void Uint32 return SDL_AudioDeviceID int float float float return SDL_JoystickID return int SDL_Rect return SDL_Window float return SDL_Window return SDL_Renderer SDL_bool return SDL_AudioDeviceID void Uint32 return Uint32 int int int Uint32 return const char SDL_bool
Enumerator
SDL_FALSE 
SDL_TRUE 

Definition at line 130 of file SDL_stdinc.h.

131 {
132  SDL_FALSE = 0,
133  SDL_TRUE = 1
134 } SDL_bool;
SDL_bool
Definition: SDL_stdinc.h:130

Function Documentation

◆ SDL_abs()

int SDL_abs ( int  x)

Definition at line 249 of file SDL_stdlib.c.

References SDL_isdigit(), SDL_isspace(), SDL_tolower(), and SDL_toupper().

250 {
251 #if defined(HAVE_ABS)
252  return abs(x);
253 #else
254  return ((x) < 0 ? -(x) : (x));
255 #endif
256 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567

◆ SDL_acos()

double SDL_acos ( double  x)

Definition at line 55 of file SDL_stdlib.c.

References SDL_atan(), and SDL_sqrt().

Referenced by SDL_asin(), and SDL_memset4().

56 {
57 #if defined(HAVE_ACOS)
58  return acos(val);
59 #else
60  double result;
61  if (val == -1.0) {
62  result = M_PI;
63  } else {
64  result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
65  if (result < 0.0)
66  {
67  result += M_PI;
68  }
69  }
70  return result;
71 #endif
72 }
GLuint64EXT * result
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:210
double SDL_atan(double x)
Definition: SDL_stdlib.c:35
GLuint GLfloat * val

◆ SDL_asin()

double SDL_asin ( double  x)

Definition at line 75 of file SDL_stdlib.c.

References SDL_acos().

Referenced by SDL_memset4().

76 {
77 #if defined(HAVE_ASIN)
78  return asin(val);
79 #else
80  double result;
81  if (val == -1.0) {
82  result = -(M_PI / 2.0);
83  } else {
84  result = (M_PI / 2.0) - SDL_acos(val);
85  }
86  return result;
87 #endif
88 }
GLuint64EXT * result
double SDL_acos(double val)
Definition: SDL_stdlib.c:55
GLuint GLfloat * val

◆ SDL_atan()

double SDL_atan ( double  x)

Definition at line 35 of file SDL_stdlib.c.

References atan(), and SDL_uclibc_atan().

Referenced by SDL_acos(), and SDL_memset4().

36 {
37 #if defined(HAVE_ATAN)
38  return atan(x);
39 #else
40  return SDL_uclibc_atan(x);
41 #endif /* HAVE_ATAN */
42 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_atan(double x)
double atan(double x)
Definition: s_atan.c:67

◆ SDL_atan2()

double SDL_atan2 ( double  x,
double  y 
)

Definition at line 45 of file SDL_stdlib.c.

References SDL_uclibc_atan2().

Referenced by SDL_memset4().

46 {
47 #if defined(HAVE_ATAN2)
48  return atan2(x, y);
49 #else
50  return SDL_uclibc_atan2(x, y);
51 #endif /* HAVE_ATAN2 */
52 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_atan2(double y, double x)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567

◆ SDL_atof()

double SDL_atof ( const char *  str)

Definition at line 776 of file SDL_string.c.

References NULL, and SDL_strtod().

Referenced by SDL_memset4().

777 {
778 #ifdef HAVE_ATOF
779  return (double) atof(string);
780 #else
781  return SDL_strtod(string, NULL);
782 #endif /* HAVE_ATOF */
783 }
double SDL_strtod(const char *string, char **endp)
Definition: SDL_string.c:886
#define NULL
Definition: begin_code.h:143

◆ SDL_atoi()

int SDL_atoi ( const char *  str)

Definition at line 767 of file SDL_string.c.

References NULL, and SDL_strtol().

Referenced by SDL_memset4().

768 {
769 #ifdef HAVE_ATOI
770  return atoi(string);
771 #else
772  return SDL_strtol(string, NULL, 0);
773 #endif /* HAVE_ATOI */
774 }
long SDL_strtol(const char *string, char **endp, int base)
Definition: SDL_string.c:786
#define NULL
Definition: begin_code.h:143

◆ SDL_calloc()

◆ SDL_ceil()

double SDL_ceil ( double  x)

Definition at line 91 of file SDL_stdlib.c.

References SDL_floor().

Referenced by SDL_memset4().

92 {
93 #if defined(HAVE_CEIL)
94  return ceil(x);
95 #else
96  double integer = SDL_floor(x);
97  double fraction = x - integer;
98  if (fraction > 0.0) {
99  integer += 1.0;
100  }
101  return integer;
102 #endif /* HAVE_CEIL */
103 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_floor(double x)
Definition: SDL_stdlib.c:148

◆ SDL_copysign()

double SDL_copysign ( double  x,
double  y 
)

Definition at line 106 of file SDL_stdlib.c.

References copysign, and SDL_uclibc_copysign().

Referenced by SDL_memset4().

107 {
108 #if defined(HAVE_COPYSIGN)
109  return copysign(x, y);
110 #elif defined(HAVE__COPYSIGN)
111  return _copysign(x, y);
112 #else
113  return SDL_uclibc_copysign(x, y);
114 #endif /* HAVE_COPYSIGN */
115 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_copysign(double x, double y)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
#define copysign
Definition: math_private.h:34

◆ SDL_cos()

double SDL_cos ( double  x)

Definition at line 118 of file SDL_stdlib.c.

References cos, and SDL_uclibc_cos().

Referenced by SDL_cosf(), and SDL_memset4().

119 {
120 #if defined(HAVE_COS)
121  return cos(x);
122 #else
123  return SDL_uclibc_cos(x);
124 #endif /* HAVE_COS */
125 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
#define cos
Definition: math_private.h:35
double SDL_uclibc_cos(double x)

◆ SDL_cosf()

float SDL_cosf ( float  x)

Definition at line 128 of file SDL_stdlib.c.

References SDL_cos().

Referenced by SDL_memset4().

129 {
130 #if defined(HAVE_COSF)
131  return cosf(x);
132 #else
133  return (float)SDL_cos((double)x);
134 #endif
135 }
double SDL_cos(double x)
Definition: SDL_stdlib.c:118
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567

◆ SDL_fabs()

double SDL_fabs ( double  x)

Definition at line 138 of file SDL_stdlib.c.

References fabs, and SDL_uclibc_fabs().

Referenced by SDL_memset4().

139 {
140 #if defined(HAVE_FABS)
141  return fabs(x);
142 #else
143  return SDL_uclibc_fabs(x);
144 #endif /* HAVE_FABS */
145 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_fabs(double x)
#define fabs
Definition: math_private.h:36

◆ SDL_floor()

double SDL_floor ( double  x)

Definition at line 148 of file SDL_stdlib.c.

References floor, and SDL_uclibc_floor().

Referenced by SDL_ceil(), and SDL_memset4().

149 {
150 #if defined(HAVE_FLOOR)
151  return floor(x);
152 #else
153  return SDL_uclibc_floor(x);
154 #endif /* HAVE_FLOOR */
155 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_floor(double x)
#define floor
Definition: math_private.h:37

◆ SDL_free()

void SDL_free ( void mem)

Referenced by _compare(), audio_convertAudio(), clean_out_device_list(), clipboard_testClipboardTextFunctions(), clipboard_testGetClipboardText(), clipboard_testSetClipboardText(), close_audio_device(), free_audio_queue(), free_device_list(), hints_setHint(), IMA_ADPCM_decode(), IsSDLWindowEventPending(), keyboard_getScancodeFromNameNegative(), main(), MS_ADPCM_decode(), pixels_calcGammaRamp(), quit(), ReadChunk(), RLEAlphaSurface(), RLEColorkeySurface(), SDL_AddHintCallback(), SDL_AddTimer(), SDL_AllocFormat(), SDL_AllocPalette(), SDL_ClearHints(), SDL_CreateCond(), SDL_CreateMutex(), SDL_CreateSemaphore(), SDL_CreateThreadWithStackSize(), SDL_CreateWindowTexture(), SDL_DelEventWatch(), SDL_DelHintCallback(), SDL_DelTouch(), SDL_DestroyCond(), SDL_DestroyMutex(), SDL_DestroySemaphore(), SDL_DestroyTexture(), SDL_DestroyWindow(), SDL_DestroyWindowTexture(), SDL_FreeBlitMap(), SDL_FreeFormat(), SDL_FreePalette(), SDL_FreeRW(), SDL_FreeShapeTree(), SDL_FreeSurface(), SDL_FreeWAV(), SDL_GameControllerAddMapping(), SDL_GameControllerAddMappingsFromRW(), SDL_GameControllerClose(), SDL_GameControllerLoadHints(), SDL_GameControllerOpen(), SDL_GameControllerQuit(), SDL_Generic_SetTLSData(), SDL_GetErrBuf(), SDL_GL_DeleteContext(), SDL_HapticClose(), SDL_HapticOpen(), SDL_HapticOpenFromJoystick(), SDL_iconv_close(), SDL_InvalidateMap(), SDL_JoystickClose(), SDL_JoystickOpen(), SDL_LoadWAV_RW(), SDL_LogOutput(), SDL_LogResetPriorities(), SDL_MouseQuit(), SDL_PrivateAddMappingForGUID(), SDL_RemoveTimer(), SDL_RunThread(), SDL_SetClipboardText(), SDL_setenv(), SDL_SetHintWithPriority(), SDL_SetWindowData(), SDL_SetWindowTitle(), SDL_StopEventLoop(), SDL_SW_DestroyYUVTexture(), SDL_SYS_AddJoystickDevice(), SDL_SYS_RemoveJoystickDevice(), SDL_TimerQuit(), SDL_TLSCleanup(), SDL_TouchQuit(), SDL_UnRLESurface(), SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), SDL_UpdateTextureYUVPlanar(), SDL_VideoQuit(), SDL_WaitThread(), SDLTest_CommonEvent(), SDLTest_CommonQuit(), SDLTest_GenerateExecKey(), sdltest_generateRunSeed(), sdltest_randomAsciiString(), sdltest_randomAsciiStringOfSize(), sdltest_randomAsciiStringWithMaximumLength(), SDLTest_RunSuites(), SDLTest_ScreenShot(), stdlib_getsetenv(), SW_DestroyRenderer(), unifont_cleanup(), unifont_load_texture(), video_getSetWindowData(), and WatchGameController().

◆ SDL_getenv()

char* SDL_getenv ( const char *  name)

Definition at line 212 of file SDL_getenv.c.

References i, main, NULL, SDL_setenv(), SDL_strcmp, SDL_strlen, and SDL_strncmp.

Referenced by SDL_setenv().

213 {
214  int len, i;
215  char *value;
216 
217  /* Input validation */
218  if (!name || SDL_strlen(name)==0) {
219  return NULL;
220  }
221 
222  value = (char *) 0;
223  if (SDL_env) {
224  len = SDL_strlen(name);
225  for (i = 0; SDL_env[i] && !value; ++i) {
226  if ((SDL_strncmp(SDL_env[i], name, len) == 0) &&
227  (SDL_env[i][len] == '=')) {
228  value = &SDL_env[i][len + 1];
229  }
230  }
231  }
232  return value;
233 }
GLuint const GLchar * name
#define SDL_strncmp
static char ** SDL_env
Definition: SDL_getenv.c:106
GLenum GLsizei len
GLsizei const GLfloat * value
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:143
#define SDL_strlen

◆ SDL_iconv()

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

Definition at line 247 of file SDL_iconv.c.

References ENCODING_ASCII, ENCODING_LATIN1, ENCODING_UCS2BE, ENCODING_UCS2LE, ENCODING_UCS4BE, ENCODING_UCS4LE, ENCODING_UTF16, ENCODING_UTF16BE, ENCODING_UTF16LE, ENCODING_UTF16NATIVE, ENCODING_UTF32, ENCODING_UTF32BE, ENCODING_UTF32LE, ENCODING_UTF32NATIVE, ENCODING_UTF8, SDL_FALSE, SDL_ICONV_E2BIG, SDL_ICONV_EINVAL, SDL_TRUE, UNICODE_BOM, UNKNOWN_ASCII, and UNKNOWN_UNICODE.

Referenced by SDL_iconv_string().

250 {
251  /* For simplicity, we'll convert everything to and from UCS-4 */
252  const char *src;
253  char *dst;
254  size_t srclen, dstlen;
255  Uint32 ch = 0;
256  size_t total;
257 
258  if (!inbuf || !*inbuf) {
259  /* Reset the context */
260  return 0;
261  }
262  if (!outbuf || !*outbuf || !outbytesleft || !*outbytesleft) {
263  return SDL_ICONV_E2BIG;
264  }
265  src = *inbuf;
266  srclen = (inbytesleft ? *inbytesleft : 0);
267  dst = *outbuf;
268  dstlen = *outbytesleft;
269 
270  switch (cd->src_fmt) {
271  case ENCODING_UTF16:
272  /* Scan for a byte order marker */
273  {
274  Uint8 *p = (Uint8 *) src;
275  size_t n = srclen / 2;
276  while (n) {
277  if (p[0] == 0xFF && p[1] == 0xFE) {
278  cd->src_fmt = ENCODING_UTF16BE;
279  break;
280  } else if (p[0] == 0xFE && p[1] == 0xFF) {
281  cd->src_fmt = ENCODING_UTF16LE;
282  break;
283  }
284  p += 2;
285  --n;
286  }
287  if (n == 0) {
288  /* We can't tell, default to host order */
289  cd->src_fmt = ENCODING_UTF16NATIVE;
290  }
291  }
292  break;
293  case ENCODING_UTF32:
294  /* Scan for a byte order marker */
295  {
296  Uint8 *p = (Uint8 *) src;
297  size_t n = srclen / 4;
298  while (n) {
299  if (p[0] == 0xFF && p[1] == 0xFE &&
300  p[2] == 0x00 && p[3] == 0x00) {
301  cd->src_fmt = ENCODING_UTF32BE;
302  break;
303  } else if (p[0] == 0x00 && p[1] == 0x00 &&
304  p[2] == 0xFE && p[3] == 0xFF) {
305  cd->src_fmt = ENCODING_UTF32LE;
306  break;
307  }
308  p += 4;
309  --n;
310  }
311  if (n == 0) {
312  /* We can't tell, default to host order */
313  cd->src_fmt = ENCODING_UTF32NATIVE;
314  }
315  }
316  break;
317  }
318 
319  switch (cd->dst_fmt) {
320  case ENCODING_UTF16:
321  /* Default to host order, need to add byte order marker */
322  if (dstlen < 2) {
323  return SDL_ICONV_E2BIG;
324  }
325  *(Uint16 *) dst = UNICODE_BOM;
326  dst += 2;
327  dstlen -= 2;
328  cd->dst_fmt = ENCODING_UTF16NATIVE;
329  break;
330  case ENCODING_UTF32:
331  /* Default to host order, need to add byte order marker */
332  if (dstlen < 4) {
333  return SDL_ICONV_E2BIG;
334  }
335  *(Uint32 *) dst = UNICODE_BOM;
336  dst += 4;
337  dstlen -= 4;
338  cd->dst_fmt = ENCODING_UTF32NATIVE;
339  break;
340  }
341 
342  total = 0;
343  while (srclen > 0) {
344  /* Decode a character */
345  switch (cd->src_fmt) {
346  case ENCODING_ASCII:
347  {
348  Uint8 *p = (Uint8 *) src;
349  ch = (Uint32) (p[0] & 0x7F);
350  ++src;
351  --srclen;
352  }
353  break;
354  case ENCODING_LATIN1:
355  {
356  Uint8 *p = (Uint8 *) src;
357  ch = (Uint32) p[0];
358  ++src;
359  --srclen;
360  }
361  break;
362  case ENCODING_UTF8: /* RFC 3629 */
363  {
364  Uint8 *p = (Uint8 *) src;
365  size_t left = 0;
366  SDL_bool overlong = SDL_FALSE;
367  if (p[0] >= 0xFC) {
368  if ((p[0] & 0xFE) != 0xFC) {
369  /* Skip illegal sequences
370  return SDL_ICONV_EILSEQ;
371  */
372  ch = UNKNOWN_UNICODE;
373  } else {
374  if (p[0] == 0xFC && srclen > 1 && (p[1] & 0xFC) == 0x80) {
375  overlong = SDL_TRUE;
376  }
377  ch = (Uint32) (p[0] & 0x01);
378  left = 5;
379  }
380  } else if (p[0] >= 0xF8) {
381  if ((p[0] & 0xFC) != 0xF8) {
382  /* Skip illegal sequences
383  return SDL_ICONV_EILSEQ;
384  */
385  ch = UNKNOWN_UNICODE;
386  } else {
387  if (p[0] == 0xF8 && srclen > 1 && (p[1] & 0xF8) == 0x80) {
388  overlong = SDL_TRUE;
389  }
390  ch = (Uint32) (p[0] & 0x03);
391  left = 4;
392  }
393  } else if (p[0] >= 0xF0) {
394  if ((p[0] & 0xF8) != 0xF0) {
395  /* Skip illegal sequences
396  return SDL_ICONV_EILSEQ;
397  */
398  ch = UNKNOWN_UNICODE;
399  } else {
400  if (p[0] == 0xF0 && srclen > 1 && (p[1] & 0xF0) == 0x80) {
401  overlong = SDL_TRUE;
402  }
403  ch = (Uint32) (p[0] & 0x07);
404  left = 3;
405  }
406  } else if (p[0] >= 0xE0) {
407  if ((p[0] & 0xF0) != 0xE0) {
408  /* Skip illegal sequences
409  return SDL_ICONV_EILSEQ;
410  */
411  ch = UNKNOWN_UNICODE;
412  } else {
413  if (p[0] == 0xE0 && srclen > 1 && (p[1] & 0xE0) == 0x80) {
414  overlong = SDL_TRUE;
415  }
416  ch = (Uint32) (p[0] & 0x0F);
417  left = 2;
418  }
419  } else if (p[0] >= 0xC0) {
420  if ((p[0] & 0xE0) != 0xC0) {
421  /* Skip illegal sequences
422  return SDL_ICONV_EILSEQ;
423  */
424  ch = UNKNOWN_UNICODE;
425  } else {
426  if ((p[0] & 0xDE) == 0xC0) {
427  overlong = SDL_TRUE;
428  }
429  ch = (Uint32) (p[0] & 0x1F);
430  left = 1;
431  }
432  } else {
433  if ((p[0] & 0x80) != 0x00) {
434  /* Skip illegal sequences
435  return SDL_ICONV_EILSEQ;
436  */
437  ch = UNKNOWN_UNICODE;
438  } else {
439  ch = (Uint32) p[0];
440  }
441  }
442  ++src;
443  --srclen;
444  if (srclen < left) {
445  return SDL_ICONV_EINVAL;
446  }
447  while (left--) {
448  ++p;
449  if ((p[0] & 0xC0) != 0x80) {
450  /* Skip illegal sequences
451  return SDL_ICONV_EILSEQ;
452  */
453  ch = UNKNOWN_UNICODE;
454  break;
455  }
456  ch <<= 6;
457  ch |= (p[0] & 0x3F);
458  ++src;
459  --srclen;
460  }
461  if (overlong) {
462  /* Potential security risk
463  return SDL_ICONV_EILSEQ;
464  */
465  ch = UNKNOWN_UNICODE;
466  }
467  if ((ch >= 0xD800 && ch <= 0xDFFF) ||
468  (ch == 0xFFFE || ch == 0xFFFF) || ch > 0x10FFFF) {
469  /* Skip illegal sequences
470  return SDL_ICONV_EILSEQ;
471  */
472  ch = UNKNOWN_UNICODE;
473  }
474  }
475  break;
476  case ENCODING_UTF16BE: /* RFC 2781 */
477  {
478  Uint8 *p = (Uint8 *) src;
479  Uint16 W1, W2;
480  if (srclen < 2) {
481  return SDL_ICONV_EINVAL;
482  }
483  W1 = ((Uint16) p[0] << 8) | (Uint16) p[1];
484  src += 2;
485  srclen -= 2;
486  if (W1 < 0xD800 || W1 > 0xDFFF) {
487  ch = (Uint32) W1;
488  break;
489  }
490  if (W1 > 0xDBFF) {
491  /* Skip illegal sequences
492  return SDL_ICONV_EILSEQ;
493  */
494  ch = UNKNOWN_UNICODE;
495  break;
496  }
497  if (srclen < 2) {
498  return SDL_ICONV_EINVAL;
499  }
500  p = (Uint8 *) src;
501  W2 = ((Uint16) p[0] << 8) | (Uint16) p[1];
502  src += 2;
503  srclen -= 2;
504  if (W2 < 0xDC00 || W2 > 0xDFFF) {
505  /* Skip illegal sequences
506  return SDL_ICONV_EILSEQ;
507  */
508  ch = UNKNOWN_UNICODE;
509  break;
510  }
511  ch = (((Uint32) (W1 & 0x3FF) << 10) |
512  (Uint32) (W2 & 0x3FF)) + 0x10000;
513  }
514  break;
515  case ENCODING_UTF16LE: /* RFC 2781 */
516  {
517  Uint8 *p = (Uint8 *) src;
518  Uint16 W1, W2;
519  if (srclen < 2) {
520  return SDL_ICONV_EINVAL;
521  }
522  W1 = ((Uint16) p[1] << 8) | (Uint16) p[0];
523  src += 2;
524  srclen -= 2;
525  if (W1 < 0xD800 || W1 > 0xDFFF) {
526  ch = (Uint32) W1;
527  break;
528  }
529  if (W1 > 0xDBFF) {
530  /* Skip illegal sequences
531  return SDL_ICONV_EILSEQ;
532  */
533  ch = UNKNOWN_UNICODE;
534  break;
535  }
536  if (srclen < 2) {
537  return SDL_ICONV_EINVAL;
538  }
539  p = (Uint8 *) src;
540  W2 = ((Uint16) p[1] << 8) | (Uint16) p[0];
541  src += 2;
542  srclen -= 2;
543  if (W2 < 0xDC00 || W2 > 0xDFFF) {
544  /* Skip illegal sequences
545  return SDL_ICONV_EILSEQ;
546  */
547  ch = UNKNOWN_UNICODE;
548  break;
549  }
550  ch = (((Uint32) (W1 & 0x3FF) << 10) |
551  (Uint32) (W2 & 0x3FF)) + 0x10000;
552  }
553  break;
554  case ENCODING_UCS2LE:
555  {
556  Uint8 *p = (Uint8 *) src;
557  if (srclen < 2) {
558  return SDL_ICONV_EINVAL;
559  }
560  ch = ((Uint32) p[1] << 8) | (Uint32) p[0];
561  src += 2;
562  srclen -= 2;
563  }
564  break;
565  case ENCODING_UCS2BE:
566  {
567  Uint8 *p = (Uint8 *) src;
568  if (srclen < 2) {
569  return SDL_ICONV_EINVAL;
570  }
571  ch = ((Uint32) p[0] << 8) | (Uint32) p[1];
572  src += 2;
573  srclen -= 2;
574  }
575  break;
576  case ENCODING_UCS4BE:
577  case ENCODING_UTF32BE:
578  {
579  Uint8 *p = (Uint8 *) src;
580  if (srclen < 4) {
581  return SDL_ICONV_EINVAL;
582  }
583  ch = ((Uint32) p[0] << 24) |
584  ((Uint32) p[1] << 16) |
585  ((Uint32) p[2] << 8) | (Uint32) p[3];
586  src += 4;
587  srclen -= 4;
588  }
589  break;
590  case ENCODING_UCS4LE:
591  case ENCODING_UTF32LE:
592  {
593  Uint8 *p = (Uint8 *) src;
594  if (srclen < 4) {
595  return SDL_ICONV_EINVAL;
596  }
597  ch = ((Uint32) p[3] << 24) |
598  ((Uint32) p[2] << 16) |
599  ((Uint32) p[1] << 8) | (Uint32) p[0];
600  src += 4;
601  srclen -= 4;
602  }
603  break;
604  }
605 
606  /* Encode a character */
607  switch (cd->dst_fmt) {
608  case ENCODING_ASCII:
609  {
610  Uint8 *p = (Uint8 *) dst;
611  if (dstlen < 1) {
612  return SDL_ICONV_E2BIG;
613  }
614  if (ch > 0x7F) {
615  *p = UNKNOWN_ASCII;
616  } else {
617  *p = (Uint8) ch;
618  }
619  ++dst;
620  --dstlen;
621  }
622  break;
623  case ENCODING_LATIN1:
624  {
625  Uint8 *p = (Uint8 *) dst;
626  if (dstlen < 1) {
627  return SDL_ICONV_E2BIG;
628  }
629  if (ch > 0xFF) {
630  *p = UNKNOWN_ASCII;
631  } else {
632  *p = (Uint8) ch;
633  }
634  ++dst;
635  --dstlen;
636  }
637  break;
638  case ENCODING_UTF8: /* RFC 3629 */
639  {
640  Uint8 *p = (Uint8 *) dst;
641  if (ch > 0x10FFFF) {
642  ch = UNKNOWN_UNICODE;
643  }
644  if (ch <= 0x7F) {
645  if (dstlen < 1) {
646  return SDL_ICONV_E2BIG;
647  }
648  *p = (Uint8) ch;
649  ++dst;
650  --dstlen;
651  } else if (ch <= 0x7FF) {
652  if (dstlen < 2) {
653  return SDL_ICONV_E2BIG;
654  }
655  p[0] = 0xC0 | (Uint8) ((ch >> 6) & 0x1F);
656  p[1] = 0x80 | (Uint8) (ch & 0x3F);
657  dst += 2;
658  dstlen -= 2;
659  } else if (ch <= 0xFFFF) {
660  if (dstlen < 3) {
661  return SDL_ICONV_E2BIG;
662  }
663  p[0] = 0xE0 | (Uint8) ((ch >> 12) & 0x0F);
664  p[1] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
665  p[2] = 0x80 | (Uint8) (ch & 0x3F);
666  dst += 3;
667  dstlen -= 3;
668  } else if (ch <= 0x1FFFFF) {
669  if (dstlen < 4) {
670  return SDL_ICONV_E2BIG;
671  }
672  p[0] = 0xF0 | (Uint8) ((ch >> 18) & 0x07);
673  p[1] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
674  p[2] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
675  p[3] = 0x80 | (Uint8) (ch & 0x3F);
676  dst += 4;
677  dstlen -= 4;
678  } else if (ch <= 0x3FFFFFF) {
679  if (dstlen < 5) {
680  return SDL_ICONV_E2BIG;
681  }
682  p[0] = 0xF8 | (Uint8) ((ch >> 24) & 0x03);
683  p[1] = 0x80 | (Uint8) ((ch >> 18) & 0x3F);
684  p[2] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
685  p[3] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
686  p[4] = 0x80 | (Uint8) (ch & 0x3F);
687  dst += 5;
688  dstlen -= 5;
689  } else {
690  if (dstlen < 6) {
691  return SDL_ICONV_E2BIG;
692  }
693  p[0] = 0xFC | (Uint8) ((ch >> 30) & 0x01);
694  p[1] = 0x80 | (Uint8) ((ch >> 24) & 0x3F);
695  p[2] = 0x80 | (Uint8) ((ch >> 18) & 0x3F);
696  p[3] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
697  p[4] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
698  p[5] = 0x80 | (Uint8) (ch & 0x3F);
699  dst += 6;
700  dstlen -= 6;
701  }
702  }
703  break;
704  case ENCODING_UTF16BE: /* RFC 2781 */
705  {
706  Uint8 *p = (Uint8 *) dst;
707  if (ch > 0x10FFFF) {
708  ch = UNKNOWN_UNICODE;
709  }
710  if (ch < 0x10000) {
711  if (dstlen < 2) {
712  return SDL_ICONV_E2BIG;
713  }
714  p[0] = (Uint8) (ch >> 8);
715  p[1] = (Uint8) ch;
716  dst += 2;
717  dstlen -= 2;
718  } else {
719  Uint16 W1, W2;
720  if (dstlen < 4) {
721  return SDL_ICONV_E2BIG;
722  }
723  ch = ch - 0x10000;
724  W1 = 0xD800 | (Uint16) ((ch >> 10) & 0x3FF);
725  W2 = 0xDC00 | (Uint16) (ch & 0x3FF);
726  p[0] = (Uint8) (W1 >> 8);
727  p[1] = (Uint8) W1;
728  p[2] = (Uint8) (W2 >> 8);
729  p[3] = (Uint8) W2;
730  dst += 4;
731  dstlen -= 4;
732  }
733  }
734  break;
735  case ENCODING_UTF16LE: /* RFC 2781 */
736  {
737  Uint8 *p = (Uint8 *) dst;
738  if (ch > 0x10FFFF) {
739  ch = UNKNOWN_UNICODE;
740  }
741  if (ch < 0x10000) {
742  if (dstlen < 2) {
743  return SDL_ICONV_E2BIG;
744  }
745  p[1] = (Uint8) (ch >> 8);
746  p[0] = (Uint8) ch;
747  dst += 2;
748  dstlen -= 2;
749  } else {
750  Uint16 W1, W2;
751  if (dstlen < 4) {
752  return SDL_ICONV_E2BIG;
753  }
754  ch = ch - 0x10000;
755  W1 = 0xD800 | (Uint16) ((ch >> 10) & 0x3FF);
756  W2 = 0xDC00 | (Uint16) (ch & 0x3FF);
757  p[1] = (Uint8) (W1 >> 8);
758  p[0] = (Uint8) W1;
759  p[3] = (Uint8) (W2 >> 8);
760  p[2] = (Uint8) W2;
761  dst += 4;
762  dstlen -= 4;
763  }
764  }
765  break;
766  case ENCODING_UCS2BE:
767  {
768  Uint8 *p = (Uint8 *) dst;
769  if (ch > 0xFFFF) {
770  ch = UNKNOWN_UNICODE;
771  }
772  if (dstlen < 2) {
773  return SDL_ICONV_E2BIG;
774  }
775  p[0] = (Uint8) (ch >> 8);
776  p[1] = (Uint8) ch;
777  dst += 2;
778  dstlen -= 2;
779  }
780  break;
781  case ENCODING_UCS2LE:
782  {
783  Uint8 *p = (Uint8 *) dst;
784  if (ch > 0xFFFF) {
785  ch = UNKNOWN_UNICODE;
786  }
787  if (dstlen < 2) {
788  return SDL_ICONV_E2BIG;
789  }
790  p[1] = (Uint8) (ch >> 8);
791  p[0] = (Uint8) ch;
792  dst += 2;
793  dstlen -= 2;
794  }
795  break;
796  case ENCODING_UTF32BE:
797  if (ch > 0x10FFFF) {
798  ch = UNKNOWN_UNICODE;
799  }
800  case ENCODING_UCS4BE:
801  if (ch > 0x7FFFFFFF) {
802  ch = UNKNOWN_UNICODE;
803  }
804  {
805  Uint8 *p = (Uint8 *) dst;
806  if (dstlen < 4) {
807  return SDL_ICONV_E2BIG;
808  }
809  p[0] = (Uint8) (ch >> 24);
810  p[1] = (Uint8) (ch >> 16);
811  p[2] = (Uint8) (ch >> 8);
812  p[3] = (Uint8) ch;
813  dst += 4;
814  dstlen -= 4;
815  }
816  break;
817  case ENCODING_UTF32LE:
818  if (ch > 0x10FFFF) {
819  ch = UNKNOWN_UNICODE;
820  }
821  case ENCODING_UCS4LE:
822  if (ch > 0x7FFFFFFF) {
823  ch = UNKNOWN_UNICODE;
824  }
825  {
826  Uint8 *p = (Uint8 *) dst;
827  if (dstlen < 4) {
828  return SDL_ICONV_E2BIG;
829  }
830  p[3] = (Uint8) (ch >> 24);
831  p[2] = (Uint8) (ch >> 16);
832  p[1] = (Uint8) (ch >> 8);
833  p[0] = (Uint8) ch;
834  dst += 4;
835  dstlen -= 4;
836  }
837  break;
838  }
839 
840  /* Update state */
841  *inbuf = src;
842  *inbytesleft = srclen;
843  *outbuf = dst;
844  *outbytesleft = dstlen;
845  ++total;
846  }
847  return total;
848 }
GLenum GLenum dst
GLdouble n
#define UNKNOWN_UNICODE
Definition: SDL_iconv.c:97
GLfloat GLfloat p
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:161
#define UNICODE_BOM
Definition: SDL_iconv.c:94
GLint left
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define SDL_ICONV_E2BIG
Definition: SDL_stdinc.h:468
#define ENCODING_UTF32NATIVE
Definition: SDL_iconv.c:118
#define SDL_ICONV_EINVAL
Definition: SDL_stdinc.h:470
SDL_bool
Definition: SDL_stdinc.h:130
#define UNKNOWN_ASCII
Definition: SDL_iconv.c:96
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151
#define ENCODING_UTF16NATIVE
Definition: SDL_iconv.c:117
GLenum src

◆ SDL_iconv_close()

int SDL_iconv_close ( SDL_iconv_t  cd)

Definition at line 851 of file SDL_iconv.c.

References SDL_free().

Referenced by SDL_iconv_string().

852 {
853  if (cd != (SDL_iconv_t)-1) {
854  SDL_free(cd);
855  }
856  return 0;
857 }
void SDL_free(void *mem)

◆ SDL_iconv_open()

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

Definition at line 207 of file SDL_iconv.c.

References SDL_iconv_t::dst_fmt, ENCODING_UNKNOWN, encodings, getlocale(), i, SDL_arraysize, SDL_malloc, SDL_strcasecmp, and SDL_iconv_t::src_fmt.

Referenced by SDL_iconv_string().

208 {
209  int src_fmt = ENCODING_UNKNOWN;
210  int dst_fmt = ENCODING_UNKNOWN;
211  int i;
212  char fromcode_buffer[64];
213  char tocode_buffer[64];
214 
215  if (!fromcode || !*fromcode) {
216  fromcode = getlocale(fromcode_buffer, sizeof(fromcode_buffer));
217  }
218  if (!tocode || !*tocode) {
219  tocode = getlocale(tocode_buffer, sizeof(tocode_buffer));
220  }
221  for (i = 0; i < SDL_arraysize(encodings); ++i) {
222  if (SDL_strcasecmp(fromcode, encodings[i].name) == 0) {
223  src_fmt = encodings[i].format;
224  if (dst_fmt != ENCODING_UNKNOWN) {
225  break;
226  }
227  }
228  if (SDL_strcasecmp(tocode, encodings[i].name) == 0) {
229  dst_fmt = encodings[i].format;
230  if (src_fmt != ENCODING_UNKNOWN) {
231  break;
232  }
233  }
234  }
235  if (src_fmt != ENCODING_UNKNOWN && dst_fmt != ENCODING_UNKNOWN) {
236  SDL_iconv_t cd = (SDL_iconv_t) SDL_malloc(sizeof(*cd));
237  if (cd) {
238  cd->src_fmt = src_fmt;
239  cd->dst_fmt = dst_fmt;
240  return cd;
241  }
242  }
243  return (SDL_iconv_t) - 1;
244 }
GLuint const GLchar * name
#define SDL_strcasecmp
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:90
#define SDL_malloc
static const char * getlocale(char *buffer, size_t bufsize)
Definition: SDL_iconv.c:172
static struct @25 encodings[]

◆ SDL_iconv_string()

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

This function converts a string between encodings in one pass, returning a string that must be freed with SDL_free() or NULL on error.

Definition at line 862 of file SDL_iconv.c.

References NULL, SDL_iconv(), SDL_iconv_close(), SDL_ICONV_E2BIG, SDL_ICONV_EILSEQ, SDL_ICONV_EINVAL, SDL_ICONV_ERROR, SDL_iconv_open(), SDL_malloc, SDL_memset, and SDL_realloc.

864 {
865  SDL_iconv_t cd;
866  char *string;
867  size_t stringsize;
868  char *outbuf;
869  size_t outbytesleft;
870  size_t retCode = 0;
871 
872  cd = SDL_iconv_open(tocode, fromcode);
873  if (cd == (SDL_iconv_t) - 1) {
874  /* See if we can recover here (fixes iconv on Solaris 11) */
875  if (!tocode || !*tocode) {
876  tocode = "UTF-8";
877  }
878  if (!fromcode || !*fromcode) {
879  fromcode = "UTF-8";
880  }
881  cd = SDL_iconv_open(tocode, fromcode);
882  }
883  if (cd == (SDL_iconv_t) - 1) {
884  return NULL;
885  }
886 
887  stringsize = inbytesleft > 4 ? inbytesleft : 4;
888  string = SDL_malloc(stringsize);
889  if (!string) {
890  SDL_iconv_close(cd);
891  return NULL;
892  }
893  outbuf = string;
894  outbytesleft = stringsize;
895  SDL_memset(outbuf, 0, 4);
896 
897  while (inbytesleft > 0) {
898  retCode = SDL_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
899  switch (retCode) {
900  case SDL_ICONV_E2BIG:
901  {
902  char *oldstring = string;
903  stringsize *= 2;
904  string = SDL_realloc(string, stringsize);
905  if (!string) {
906  SDL_iconv_close(cd);
907  return NULL;
908  }
909  outbuf = string + (outbuf - oldstring);
910  outbytesleft = stringsize - (outbuf - string);
911  SDL_memset(outbuf, 0, 4);
912  }
913  break;
914  case SDL_ICONV_EILSEQ:
915  /* Try skipping some input data - not perfect, but... */
916  ++inbuf;
917  --inbytesleft;
918  break;
919  case SDL_ICONV_EINVAL:
920  case SDL_ICONV_ERROR:
921  /* We can't continue... */
922  inbytesleft = 0;
923  break;
924  }
925  }
926  SDL_iconv_close(cd);
927 
928  return string;
929 }
int SDL_iconv_close(SDL_iconv_t cd)
Definition: SDL_iconv.c:851
GLsizei const GLchar *const * string
#define SDL_ICONV_EILSEQ
Definition: SDL_stdinc.h:469
SDL_iconv_t SDL_iconv_open(const char *tocode, const char *fromcode)
Definition: SDL_iconv.c:207
#define SDL_realloc
#define SDL_ICONV_E2BIG
Definition: SDL_stdinc.h:468
#define SDL_ICONV_EINVAL
Definition: SDL_stdinc.h:470
#define NULL
Definition: begin_code.h:143
#define SDL_ICONV_ERROR
Definition: SDL_stdinc.h:467
#define SDL_malloc
size_t SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition: SDL_iconv.c:247
#define SDL_memset

◆ SDL_isdigit()

int SDL_isdigit ( int  x)

Definition at line 264 of file SDL_stdlib.c.

Referenced by SDL_abs().

264 { return ((x) >= '0') && ((x) <= '9'); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567

◆ SDL_isspace()

int SDL_isspace ( int  x)

Definition at line 265 of file SDL_stdlib.c.

Referenced by SDL_abs().

265 { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567

◆ SDL_itoa()

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

Definition at line 660 of file SDL_string.c.

References SDL_ltoa().

Referenced by SDL_memset4().

661 {
662 #ifdef HAVE_ITOA
663  return itoa(value, string, radix);
664 #else
665  return SDL_ltoa((long)value, string, radix);
666 #endif /* HAVE_ITOA */
667 }
GLsizei const GLfloat * value
char * SDL_ltoa(long value, char *string, int radix)
Definition: SDL_string.c:680

◆ SDL_lltoa()

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

Definition at line 724 of file SDL_string.c.

References SDL_ulltoa().

Referenced by SDL_memset4(), and SDL_PrintLongLong().

725 {
726 #if defined(HAVE__I64TOA)
727  return _i64toa(value, string, radix);
728 #else
729  char *bufp = string;
730 
731  if (value < 0) {
732  *bufp++ = '-';
733  SDL_ulltoa(-value, bufp, radix);
734  } else {
735  SDL_ulltoa(value, bufp, radix);
736  }
737 
738  return string;
739 #endif /* HAVE__I64TOA */
740 }
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
char * SDL_ulltoa(Uint64 value, char *string, int radix)
Definition: SDL_string.c:743

◆ SDL_log()

double SDL_log ( double  x)

Definition at line 158 of file SDL_stdlib.c.

References SDL_uclibc_log().

Referenced by SDL_memset4().

159 {
160 #if defined(HAVE_LOG)
161  return log(x);
162 #else
163  return SDL_uclibc_log(x);
164 #endif /* HAVE_LOG */
165 }
double SDL_uclibc_log(double x)
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567

◆ SDL_ltoa()

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

Definition at line 680 of file SDL_string.c.

References SDL_ultoa().

Referenced by SDL_itoa(), SDL_memset4(), and SDL_PrintLong().

681 {
682 #if defined(HAVE__LTOA)
683  return _ltoa(value, string, radix);
684 #else
685  char *bufp = string;
686 
687  if (value < 0) {
688  *bufp++ = '-';
689  SDL_ultoa(-value, bufp, radix);
690  } else {
691  SDL_ultoa(value, bufp, radix);
692  }
693 
694  return string;
695 #endif /* HAVE__LTOA */
696 }
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
char * SDL_ultoa(unsigned long value, char *string, int radix)
Definition: SDL_string.c:699

◆ SDL_malloc()

void* SDL_malloc ( size_t  size)

◆ SDL_memcmp()

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

Definition at line 391 of file SDL_string.c.

Referenced by SDL_memset4().

392 {
393 #if defined(HAVE_MEMCMP)
394  return memcmp(s1, s2, len);
395 #else
396  char *s1p = (char *) s1;
397  char *s2p = (char *) s2;
398  while (len--) {
399  if (*s1p != *s2p) {
400  return (*s1p - *s2p);
401  }
402  ++s1p;
403  ++s2p;
404  }
405  return 0;
406 #endif /* HAVE_MEMCMP */
407 }
GLenum GLsizei len
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1

◆ SDL_memcpy()

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

Definition at line 314 of file SDL_string.c.

References memcpy.

Referenced by SDL_memcpy4(), SDL_memset4(), SDL_strlcpy(), SDL_utf8strlcpy(), and SDL_wcslcpy().

315 {
316 #ifdef __GNUC__
317  /* Presumably this is well tuned for speed.
318  On my machine this is twice as fast as the C code below.
319  */
320  return __builtin_memcpy(dst, src, len);
321 #elif defined(HAVE_MEMCPY)
322  return memcpy(dst, src, len);
323 #elif defined(HAVE_BCOPY)
324  bcopy(src, dst, len);
325  return dst;
326 #else
327  /* GCC 4.9.0 with -O3 will generate movaps instructions with the loop
328  using Uint32* pointers, so we need to make sure the pointers are
329  aligned before we loop using them.
330  */
331  if (((intptr_t)src & 0x3) || ((intptr_t)dst & 0x3)) {
332  /* Do an unaligned byte copy */
333  Uint8 *srcp1 = (Uint8 *)src;
334  Uint8 *dstp1 = (Uint8 *)dst;
335 
336  while (len--) {
337  *dstp1++ = *srcp1++;
338  }
339  } else {
340  size_t left = (len % 4);
341  Uint32 *srcp4, *dstp4;
342  Uint8 *srcp1, *dstp1;
343 
344  srcp4 = (Uint32 *) src;
345  dstp4 = (Uint32 *) dst;
346  len /= 4;
347  while (len--) {
348  *dstp4++ = *srcp4++;
349  }
350 
351  srcp1 = (Uint8 *) srcp4;
352  dstp1 = (Uint8 *) dstp4;
353  switch (left) {
354  case 3:
355  *dstp1++ = *srcp1++;
356  case 2:
357  *dstp1++ = *srcp1++;
358  case 1:
359  *dstp1++ = *srcp1++;
360  }
361  }
362  return dst;
363 #endif /* __GNUC__ */
364 }
GLenum GLenum dst
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:161
GLenum GLsizei len
GLint left
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
#define memcpy
Definition: SDL_malloc.c:640
GLenum src

◆ SDL_memcpy4()

SDL_FORCE_INLINE void* SDL_memcpy4 ( SDL_OUT_BYTECAP(dwords *4) void dst,
SDL_IN_BYTECAP(dwords *4) const void src,
size_t  dwords 
)

Definition at line 520 of file SDL_stdinc.h.

References SDL_memcpy().

521 {
522  return SDL_memcpy(dst, src, dwords * 4);
523 }
GLenum GLenum dst
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:314
GLenum src

◆ SDL_memmove()

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

Definition at line 367 of file SDL_string.c.

References memmove.

Referenced by SDL_memset4().

368 {
369 #if defined(HAVE_MEMMOVE)
370  return memmove(dst, src, len);
371 #else
372  char *srcp = (char *) src;
373  char *dstp = (char *) dst;
374 
375  if (src < dst) {
376  srcp += len - 1;
377  dstp += len - 1;
378  while (len--) {
379  *dstp-- = *srcp--;
380  }
381  } else {
382  while (len--) {
383  *dstp++ = *srcp++;
384  }
385  }
386  return dst;
387 #endif /* HAVE_MEMMOVE */
388 }
GLenum GLenum dst
#define memmove
Definition: SDL_qsort.c:59
GLenum GLsizei len
GLenum src

◆ SDL_memset()

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

Definition at line 270 of file SDL_string.c.

References memset.

271 {
272 #if defined(HAVE_MEMSET)
273  return memset(dst, c, len);
274 #else
275  size_t left;
276  Uint32 *dstp4;
277  Uint8 *dstp1 = (Uint8 *) dst;
278  Uint32 value4 = (c | (c << 8) | (c << 16) | (c << 24));
279  Uint8 value1 = (Uint8) c;
280 
281  /* The destination pointer needs to be aligned on a 4-byte boundary to
282  * execute a 32-bit set. Set first bytes manually if needed until it is
283  * aligned. */
284  while ((intptr_t)dstp1 & 0x3) {
285  if (len--) {
286  *dstp1++ = value1;
287  } else {
288  return dst;
289  }
290  }
291 
292  dstp4 = (Uint32 *) dstp1;
293  left = (len % 4);
294  len /= 4;
295  while (len--) {
296  *dstp4++ = value4;
297  }
298 
299  dstp1 = (Uint8 *) dstp4;
300  switch (left) {
301  case 3:
302  *dstp1++ = value1;
303  case 2:
304  *dstp1++ = value1;
305  case 1:
306  *dstp1++ = value1;
307  }
308 
309  return dst;
310 #endif /* HAVE_MEMSET */
311 }
GLenum GLenum dst
#define memset
Definition: SDL_malloc.c:639
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:161
GLenum GLsizei len
GLint left
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
const GLubyte * c

◆ SDL_memset4()

SDL_FORCE_INLINE void SDL_memset4 ( void dst,
Uint32  val,
size_t  dwords 
)

Definition at line 365 of file SDL_stdinc.h.

References DECLSPEC, SDL_acos(), SDL_asin(), SDL_atan(), SDL_atan2(), SDL_atof(), SDL_atoi(), SDL_ceil(), SDL_copysign(), SDL_cos(), SDL_cosf(), SDL_fabs(), SDL_floor(), SDL_IN_BYTECAP, SDL_INOUT_Z_CAP, SDL_itoa(), SDL_lltoa(), SDL_log(), SDL_ltoa(), SDL_memcmp(), SDL_memcpy(), SDL_memmove(), SDL_OUT_BYTECAP, SDL_OUT_Z_CAP, SDL_pow(), SDL_PRINTF_FORMAT_STRING, SDL_PRINTF_VARARG_FUNC, SDL_scalbn(), SDL_SCANF_FORMAT_STRING, SDL_SCANF_VARARG_FUNC, SDL_sin(), SDL_sinf(), SDL_snprintf(), SDL_sqrt(), SDL_sqrtf(), SDL_sscanf(), SDL_static_cast, SDL_strcasecmp(), SDL_strchr(), SDL_strcmp(), SDL_strdup(), SDL_strlcat(), SDL_strlcpy(), SDL_strlen(), SDL_strlwr(), SDL_strncasecmp(), SDL_strncmp(), SDL_strrchr(), SDL_strrev(), SDL_strstr(), SDL_strtod(), SDL_strtol(), SDL_strtoll(), SDL_strtoul(), SDL_strtoull(), SDL_strupr(), SDL_tan(), SDL_tanf(), SDL_uitoa(), SDL_ulltoa(), SDL_ultoa(), SDL_utf8strlcpy(), SDL_vsnprintf(), SDL_vsscanf(), SDL_wcslcat(), SDL_wcslcpy(), SDL_wcslen(), SDLCALL, and text.

Referenced by SDL_FillRect1(), SDL_FillRect2(), and SDL_FillRect4().

366 {
367 #if defined(__GNUC__) && defined(i386)
368  int u0, u1, u2;
369  __asm__ __volatile__ (
370  "cld \n\t"
371  "rep ; stosl \n\t"
372  : "=&D" (u0), "=&a" (u1), "=&c" (u2)
373  : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords))
374  : "memory"
375  );
376 #else
377  size_t _n = (dwords + 3) / 4;
378  Uint32 *_p = SDL_static_cast(Uint32 *, dst);
379  Uint32 _val = (val);
380  if (dwords == 0)
381  return;
382  switch (dwords % 4)
383  {
384  case 0: do { *_p++ = _val;
385  case 3: *_p++ = _val;
386  case 2: *_p++ = _val;
387  case 1: *_p++ = _val;
388  } while ( --_n );
389  }
390 #endif
391 }
GLenum GLenum dst
GLfixed u1
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:161
GLfixed GLfixed u2
GLuint GLfloat * val
#define SDL_static_cast(type, expression)
Definition: SDL_stdinc.h:113

◆ SDL_pow()

double SDL_pow ( double  x,
double  y 
)

Definition at line 168 of file SDL_stdlib.c.

References SDL_uclibc_pow().

Referenced by SDL_memset4().

169 {
170 #if defined(HAVE_POW)
171  return pow(x, y);
172 #else
173  return SDL_uclibc_pow(x, y);
174 #endif /* HAVE_POW */
175 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_pow(double x, double y)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567

◆ SDL_qsort()

void SDL_qsort ( void base,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *)  compare 
)

◆ SDL_realloc()

void* SDL_realloc ( void mem,
size_t  size 
)

◆ SDL_scalbn()

double SDL_scalbn ( double  x,
int  n 
)

Definition at line 178 of file SDL_stdlib.c.

References scalbn, and SDL_uclibc_scalbn().

Referenced by SDL_memset4().

179 {
180 #if defined(HAVE_SCALBN)
181  return scalbn(x, n);
182 #elif defined(HAVE__SCALB)
183  return _scalb(x, n);
184 #else
185  return SDL_uclibc_scalbn(x, n);
186 #endif /* HAVE_SCALBN */
187 }
GLdouble n
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
#define scalbn
Definition: math_private.h:40
double SDL_uclibc_scalbn(double x, int n)

◆ SDL_setenv()

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

Definition at line 108 of file SDL_getenv.c.

References i, NULL, SDL_free(), SDL_getenv(), SDL_malloc, SDL_realloc, SDL_snprintf, SDL_strchr, SDL_strlen, and SDL_strncmp.

Referenced by SDL_getenv().

109 {
110  int added;
111  int len, i;
112  char **new_env;
113  char *new_variable;
114 
115  /* Input validation */
116  if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
117  return (-1);
118  }
119 
120  /* See if it already exists */
121  if (!overwrite && SDL_getenv(name)) {
122  return 0;
123  }
124 
125  /* Allocate memory for the variable */
126  len = SDL_strlen(name) + SDL_strlen(value) + 2;
127  new_variable = (char *) SDL_malloc(len);
128  if (!new_variable) {
129  return (-1);
130  }
131 
132  SDL_snprintf(new_variable, len, "%s=%s", name, value);
133  value = new_variable + SDL_strlen(name) + 1;
134  name = new_variable;
135 
136  /* Actually put it into the environment */
137  added = 0;
138  i = 0;
139  if (SDL_env) {
140  /* Check to see if it's already there... */
141  len = (value - name);
142  for (; SDL_env[i]; ++i) {
143  if (SDL_strncmp(SDL_env[i], name, len) == 0) {
144  break;
145  }
146  }
147  /* If we found it, just replace the entry */
148  if (SDL_env[i]) {
149  SDL_free(SDL_env[i]);
150  SDL_env[i] = new_variable;
151  added = 1;
152  }
153  }
154 
155  /* Didn't find it in the environment, expand and add */
156  if (!added) {
157  new_env = SDL_realloc(SDL_env, (i + 2) * sizeof(char *));
158  if (new_env) {
159  SDL_env = new_env;
160  SDL_env[i++] = new_variable;
161  SDL_env[i++] = (char *) 0;
162  added = 1;
163  } else {
164  SDL_free(new_variable);
165  }
166  }
167  return (added ? 0 : -1);
168 }
char * SDL_getenv(const char *name)
Definition: SDL_getenv.c:212
GLuint const GLchar * name
#define SDL_realloc
#define SDL_strncmp
static char ** SDL_env
Definition: SDL_getenv.c:106
GLenum GLsizei len
#define SDL_strchr
GLsizei const GLfloat * value
void SDL_free(void *mem)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:143
#define SDL_strlen
#define SDL_snprintf
#define SDL_malloc

◆ SDL_sin()

double SDL_sin ( double  x)

Definition at line 190 of file SDL_stdlib.c.

References SDL_uclibc_sin(), and sin.

Referenced by SDL_memset4(), and SDL_sinf().

191 {
192 #if defined(HAVE_SIN)
193  return sin(x);
194 #else
195  return SDL_uclibc_sin(x);
196 #endif /* HAVE_SIN */
197 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_sin(double x)
#define sin
Definition: math_private.h:41

◆ SDL_sinf()

float SDL_sinf ( float  x)

Definition at line 200 of file SDL_stdlib.c.

References SDL_sin().

Referenced by SDL_memset4().

201 {
202 #if defined(HAVE_SINF)
203  return sinf(x);
204 #else
205  return (float)SDL_sin((double)x);
206 #endif /* HAVE_SINF */
207 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_sin(double x)
Definition: SDL_stdlib.c:190

◆ SDL_snprintf()

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

Definition at line 1273 of file SDL_string.c.

References retval, SDL_OUT_Z_CAP, and SDL_vsnprintf().

Referenced by SDL_memset4().

1274 {
1275  va_list ap;
1276  int retval;
1277 
1278  va_start(ap, fmt);
1279  retval = SDL_vsnprintf(text, maxlen, fmt, ap);
1280  va_end(ap);
1281 
1282  return retval;
1283 }
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
Definition: SDL_string.c:1483
SDL_bool retval
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47

◆ SDL_sqrt()

double SDL_sqrt ( double  x)

Definition at line 210 of file SDL_stdlib.c.

References SDL_uclibc_sqrt().

Referenced by SDL_acos(), SDL_memset4(), and SDL_sqrtf().

211 {
212 #if defined(HAVE_SQRT)
213  return sqrt(x);
214 #else
215  return SDL_uclibc_sqrt(x);
216 #endif
217 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_sqrt(double x)

◆ SDL_sqrtf()

float SDL_sqrtf ( float  x)

Definition at line 220 of file SDL_stdlib.c.

References SDL_sqrt().

Referenced by SDL_memset4().

221 {
222 #if defined(HAVE_SQRTF)
223  return sqrtf(x);
224 #else
225  return (float)SDL_sqrt((double)x);
226 #endif
227 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:210

◆ SDL_sscanf()

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

Definition at line 992 of file SDL_string.c.

References SDL_vsscanf(), and text.

Referenced by SDL_memset4().

993 {
994  int rc;
995  va_list ap;
996  va_start(ap, fmt);
997  rc = SDL_vsscanf(text, fmt, ap);
998  va_end(ap);
999  return rc;
1000 }
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
Definition: SDL_string.c:1010

◆ SDL_strcasecmp()

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

Definition at line 939 of file SDL_string.c.

References SDL_toupper.

Referenced by SDL_memset4().

940 {
941 #ifdef HAVE_STRCASECMP
942  return strcasecmp(str1, str2);
943 #elif defined(HAVE__STRICMP)
944  return _stricmp(str1, str2);
945 #else
946  char a = 0;
947  char b = 0;
948  while (*str1 && *str2) {
949  a = SDL_toupper((unsigned char) *str1);
950  b = SDL_toupper((unsigned char) *str2);
951  if (a != b)
952  break;
953  ++str1;
954  ++str2;
955  }
956  a = SDL_toupper(*str1);
957  b = SDL_toupper(*str2);
958  return (int) ((unsigned char) a - (unsigned char) b);
959 #endif /* HAVE_STRCASECMP */
960 }
#define SDL_toupper
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b

◆ SDL_strchr()

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

Definition at line 596 of file SDL_string.c.

References NULL, and SDL_const_cast.

Referenced by SDL_memset4().

597 {
598 #ifdef HAVE_STRCHR
599  return SDL_const_cast(char*,strchr(string, c));
600 #elif defined(HAVE_INDEX)
601  return SDL_const_cast(char*,index(string, c));
602 #else
603  while (*string) {
604  if (*string == c) {
605  return (char *) string;
606  }
607  ++string;
608  }
609  return NULL;
610 #endif /* HAVE_STRCHR */
611 }
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:114
GLsizei const GLchar *const * string
const GLubyte * c
GLuint index
#define NULL
Definition: begin_code.h:143

◆ SDL_strcmp()

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

Definition at line 903 of file SDL_string.c.

Referenced by SDL_memset4().

904 {
905 #if defined(HAVE_STRCMP)
906  return strcmp(str1, str2);
907 #else
908  while (*str1 && *str2) {
909  if (*str1 != *str2)
910  break;
911  ++str1;
912  ++str2;
913  }
914  return (int) ((unsigned char) *str1 - (unsigned char) *str2);
915 #endif /* HAVE_STRCMP */
916 }

◆ SDL_strdup()

char* SDL_strdup ( const char *  str)

Definition at line 532 of file SDL_string.c.

References SDL_malloc, SDL_strlcpy(), and SDL_strlen().

Referenced by SDL_memset4().

533 {
534 #if defined(HAVE_STRDUP)
535  return strdup(string);
536 #else
537  size_t len = SDL_strlen(string) + 1;
538  char *newstr = SDL_malloc(len);
539  if (newstr) {
540  SDL_strlcpy(newstr, string, len);
541  }
542  return newstr;
543 #endif /* HAVE_STRDUP */
544 }
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:469
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
#define SDL_malloc

◆ SDL_strlcat()

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

Definition at line 517 of file SDL_string.c.

References SDL_strlcpy(), and SDL_strlen().

Referenced by SDL_memset4().

518 {
519 #if defined(HAVE_STRLCAT)
520  return strlcat(dst, src, maxlen);
521 #else
522  size_t dstlen = SDL_strlen(dst);
523  size_t srclen = SDL_strlen(src);
524  if (dstlen < maxlen) {
525  SDL_strlcpy(dst + dstlen, src, maxlen - dstlen);
526  }
527  return dstlen + srclen;
528 #endif /* HAVE_STRLCAT */
529 }
GLenum GLenum dst
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:469
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
GLenum src

◆ SDL_strlcpy()

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

Definition at line 469 of file SDL_string.c.

References SDL_memcpy(), SDL_min, and SDL_strlen().

Referenced by SDL_memset4(), SDL_PrintString(), SDL_strdup(), and SDL_strlcat().

470 {
471 #if defined(HAVE_STRLCPY)
472  return strlcpy(dst, src, maxlen);
473 #else
474  size_t srclen = SDL_strlen(src);
475  if (maxlen > 0) {
476  size_t len = SDL_min(srclen, maxlen - 1);
477  SDL_memcpy(dst, src, len);
478  dst[len] = '\0';
479  }
480  return srclen;
481 #endif /* HAVE_STRLCPY */
482 }
GLenum GLenum dst
#define SDL_min(x, y)
Definition: SDL_stdinc.h:351
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:314
GLenum src

◆ SDL_strlen()

size_t SDL_strlen ( const char *  str)

Definition at line 410 of file SDL_string.c.

Referenced by SDL_memset4(), SDL_PrintString(), SDL_strdup(), SDL_strlcat(), SDL_strlcpy(), SDL_strrchr(), SDL_strrev(), SDL_strstr(), SDL_strtol(), SDL_strtoll(), SDL_strtoul(), SDL_strtoull(), and SDL_utf8strlcpy().

411 {
412 #if defined(HAVE_STRLEN)
413  return strlen(string);
414 #else
415  size_t len = 0;
416  while (*string++) {
417  ++len;
418  }
419  return len;
420 #endif /* HAVE_STRLEN */
421 }
GLenum GLsizei len

◆ SDL_strlwr()

char* SDL_strlwr ( char *  str)

Definition at line 581 of file SDL_string.c.

References SDL_tolower.

Referenced by SDL_memset4(), and SDL_PrintString().

582 {
583 #if defined(HAVE__STRLWR)
584  return _strlwr(string);
585 #else
586  char *bufp = string;
587  while (*bufp) {
588  *bufp = SDL_tolower((unsigned char) *bufp);
589  ++bufp;
590  }
591  return string;
592 #endif /* HAVE__STRLWR */
593 }
GLsizei const GLchar *const * string
#define SDL_tolower

◆ SDL_strncasecmp()

int SDL_strncasecmp ( const char *  str1,
const char *  str2,
size_t  len 
)

Definition at line 963 of file SDL_string.c.

References SDL_tolower.

Referenced by SDL_memset4().

964 {
965 #ifdef HAVE_STRNCASECMP
966  return strncasecmp(str1, str2, maxlen);
967 #elif defined(HAVE__STRNICMP)
968  return _strnicmp(str1, str2, maxlen);
969 #else
970  char a = 0;
971  char b = 0;
972  while (*str1 && *str2 && maxlen) {
973  a = SDL_tolower((unsigned char) *str1);
974  b = SDL_tolower((unsigned char) *str2);
975  if (a != b)
976  break;
977  ++str1;
978  ++str2;
979  --maxlen;
980  }
981  if (maxlen == 0) {
982  return 0;
983  } else {
984  a = SDL_tolower((unsigned char) *str1);
985  b = SDL_tolower((unsigned char) *str2);
986  return (int) ((unsigned char) a - (unsigned char) b);
987  }
988 #endif /* HAVE_STRNCASECMP */
989 }
#define SDL_tolower
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b

◆ SDL_strncmp()

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

Definition at line 919 of file SDL_string.c.

Referenced by SDL_memset4(), SDL_ScanLong(), SDL_ScanLongLong(), SDL_ScanUintPtrT(), SDL_ScanUnsignedLong(), SDL_ScanUnsignedLongLong(), SDL_strstr(), SDL_strtol(), SDL_strtoll(), SDL_strtoul(), SDL_strtoull(), SDL_vsnprintf(), and SDL_vsscanf().

920 {
921 #if defined(HAVE_STRNCMP)
922  return strncmp(str1, str2, maxlen);
923 #else
924  while (*str1 && *str2 && maxlen) {
925  if (*str1 != *str2)
926  break;
927  ++str1;
928  ++str2;
929  --maxlen;
930  }
931  if (!maxlen) {
932  return 0;
933  }
934  return (int) ((unsigned char) *str1 - (unsigned char) *str2);
935 #endif /* HAVE_STRNCMP */
936 }

◆ SDL_strrchr()

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

Definition at line 614 of file SDL_string.c.

References NULL, SDL_const_cast, and SDL_strlen().

Referenced by SDL_memset4().

615 {
616 #ifdef HAVE_STRRCHR
617  return SDL_const_cast(char*,strrchr(string, c));
618 #elif defined(HAVE_RINDEX)
619  return SDL_const_cast(char*,rindex(string, c));
620 #else
621  const char *bufp = string + SDL_strlen(string) - 1;
622  while (bufp >= string) {
623  if (*bufp == c) {
624  return (char *) bufp;
625  }
626  --bufp;
627  }
628  return NULL;
629 #endif /* HAVE_STRRCHR */
630 }
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:114
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
const GLubyte * c
#define NULL
Definition: begin_code.h:143

◆ SDL_strrev()

char* SDL_strrev ( char *  str)

Definition at line 547 of file SDL_string.c.

References SDL_strlen().

Referenced by SDL_memset4(), SDL_ulltoa(), and SDL_ultoa().

548 {
549 #if defined(HAVE__STRREV)
550  return _strrev(string);
551 #else
552  size_t len = SDL_strlen(string);
553  char *a = &string[0];
554  char *b = &string[len - 1];
555  len /= 2;
556  while (len--) {
557  char c = *a;
558  *a++ = *b;
559  *b-- = c;
560  }
561  return string;
562 #endif /* HAVE__STRREV */
563 }
GLsizei const GLchar *const * string
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
const GLubyte * c
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b

◆ SDL_strstr()

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

Definition at line 633 of file SDL_string.c.

References NULL, SDL_const_cast, SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

634 {
635 #if defined(HAVE_STRSTR)
636  return SDL_const_cast(char*,strstr(haystack, needle));
637 #else
638  size_t length = SDL_strlen(needle);
639  while (*haystack) {
640  if (SDL_strncmp(haystack, needle, length) == 0) {
641  return (char *) haystack;
642  }
643  ++haystack;
644  }
645  return NULL;
646 #endif /* HAVE_STRSTR */
647 }
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:114
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
#define NULL
Definition: begin_code.h:143
GLuint GLsizei GLsizei * length

◆ SDL_strtod()

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

Definition at line 886 of file SDL_string.c.

References SDL_ScanFloat().

Referenced by SDL_atof(), and SDL_memset4().

887 {
888 #if defined(HAVE_STRTOD)
889  return strtod(string, endp);
890 #else
891  size_t len;
892  double value;
893 
894  len = SDL_ScanFloat(string, &value);
895  if (endp) {
896  *endp = (char *) string + len;
897  }
898  return value;
899 #endif /* HAVE_STRTOD */
900 }
static size_t SDL_ScanFloat(const char *text, double *valuep)
Definition: SDL_string.c:235
GLenum GLsizei len
GLsizei const GLfloat * value

◆ SDL_strtol()

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

Definition at line 786 of file SDL_string.c.

References SDL_ScanLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_atoi(), SDL_memset4(), and SDL_vsnprintf().

787 {
788 #if defined(HAVE_STRTOL)
789  return strtol(string, endp, base);
790 #else
791  size_t len;
792  long value;
793 
794  if (!base) {
795  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
796  base = 16;
797  } else {
798  base = 10;
799  }
800  }
801 
802  len = SDL_ScanLong(string, base, &value);
803  if (endp) {
804  *endp = (char *) string + len;
805  }
806  return value;
807 #endif /* HAVE_STRTOL */
808 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
Definition: SDL_string.c:57
GLsizei const GLfloat * value

◆ SDL_strtoll()

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

Definition at line 836 of file SDL_string.c.

References SDL_ScanLongLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

837 {
838 #if defined(HAVE_STRTOLL)
839  return strtoll(string, endp, base);
840 #else
841  size_t len;
842  Sint64 value;
843 
844  if (!base) {
845  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
846  base = 16;
847  } else {
848  base = 10;
849  }
850  }
851 
852  len = SDL_ScanLongLong(string, base, &value);
853  if (endp) {
854  *endp = (char *) string + len;
855  }
856  return value;
857 #endif /* HAVE_STRTOLL */
858 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
GLsizei const GLfloat * value
static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
Definition: SDL_string.c:162
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:166

◆ SDL_strtoul()

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

Definition at line 811 of file SDL_string.c.

References SDL_ScanUnsignedLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

812 {
813 #if defined(HAVE_STRTOUL)
814  return strtoul(string, endp, base);
815 #else
816  size_t len;
817  unsigned long value;
818 
819  if (!base) {
820  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
821  base = 16;
822  } else {
823  base = 10;
824  }
825  }
826 
827  len = SDL_ScanUnsignedLong(string, base, &value);
828  if (endp) {
829  *endp = (char *) string + len;
830  }
831  return value;
832 #endif /* HAVE_STRTOUL */
833 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
GLsizei const GLfloat * value
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:98

◆ SDL_strtoull()

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

Definition at line 861 of file SDL_string.c.

References SDL_ScanUnsignedLongLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

862 {
863 #if defined(HAVE_STRTOULL)
864  return strtoull(string, endp, base);
865 #else
866  size_t len;
867  Uint64 value;
868 
869  if (!base) {
870  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
871  base = 16;
872  } else {
873  base = 10;
874  }
875  }
876 
877  len = SDL_ScanUnsignedLongLong(string, base, &value);
878  if (endp) {
879  *endp = (char *) string + len;
880  }
881  return value;
882 #endif /* HAVE_STRTOULL */
883 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:170
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
GLsizei const GLfloat * value
static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
Definition: SDL_string.c:203

◆ SDL_strupr()

char* SDL_strupr ( char *  str)

Definition at line 566 of file SDL_string.c.

References SDL_toupper.

Referenced by SDL_memset4(), and SDL_PrintString().

567 {
568 #if defined(HAVE__STRUPR)
569  return _strupr(string);
570 #else
571  char *bufp = string;
572  while (*bufp) {
573  *bufp = SDL_toupper((unsigned char) *bufp);
574  ++bufp;
575  }
576  return string;
577 #endif /* HAVE__STRUPR */
578 }
GLsizei const GLchar *const * string
#define SDL_toupper

◆ SDL_tan()

double SDL_tan ( double  x)

Definition at line 230 of file SDL_stdlib.c.

References SDL_uclibc_tan(), and tan().

Referenced by SDL_memset4(), and SDL_tanf().

231 {
232 #if defined(HAVE_TAN)
233  return tan(x);
234 #else
235  return SDL_uclibc_tan(x);
236 #endif
237 }
double tan(double x)
Definition: s_tan.c:45
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_tan(double x)

◆ SDL_tanf()

float SDL_tanf ( float  x)

Definition at line 240 of file SDL_stdlib.c.

References SDL_tan().

Referenced by SDL_memset4().

241 {
242 #if defined(HAVE_TANF)
243  return tanf(x);
244 #else
245  return (float)SDL_tan((double)x);
246 #endif
247 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_tan(double x)
Definition: SDL_stdlib.c:230

◆ SDL_tolower()

int SDL_tolower ( int  x)

Definition at line 267 of file SDL_stdlib.c.

References i, L1, L2, L3, L4, L5, L6, memcpy, and pop.

Referenced by SDL_abs().

267 { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567

◆ SDL_toupper()

int SDL_toupper ( int  x)

Definition at line 266 of file SDL_stdlib.c.

Referenced by SDL_abs().

266 { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567

◆ SDL_uitoa()

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

Definition at line 670 of file SDL_string.c.

References SDL_ultoa().

Referenced by SDL_memset4().

671 {
672 #ifdef HAVE__UITOA
673  return _uitoa(value, string, radix);
674 #else
675  return SDL_ultoa((unsigned long)value, string, radix);
676 #endif /* HAVE__UITOA */
677 }
GLsizei const GLfloat * value
char * SDL_ultoa(unsigned long value, char *string, int radix)
Definition: SDL_string.c:699

◆ SDL_ulltoa()

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

Definition at line 743 of file SDL_string.c.

References SDL_strrev().

Referenced by SDL_lltoa(), SDL_memset4(), and SDL_PrintUnsignedLongLong().

744 {
745 #if defined(HAVE__UI64TOA)
746  return _ui64toa(value, string, radix);
747 #else
748  char *bufp = string;
749 
750  if (value) {
751  while (value > 0) {
752  *bufp++ = ntoa_table[value % radix];
753  value /= radix;
754  }
755  } else {
756  *bufp++ = '0';
757  }
758  *bufp = '\0';
759 
760  /* The numbers went into the string backwards. :) */
761  SDL_strrev(string);
762 
763  return string;
764 #endif /* HAVE__UI64TOA */
765 }
GLsizei const GLchar *const * string
static const char ntoa_table[]
Definition: SDL_string.c:651
char * SDL_strrev(char *string)
Definition: SDL_string.c:547
GLsizei const GLfloat * value

◆ SDL_ultoa()

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

Definition at line 699 of file SDL_string.c.

References SDL_strrev().

Referenced by SDL_ltoa(), SDL_memset4(), SDL_PrintUnsignedLong(), and SDL_uitoa().

700 {
701 #if defined(HAVE__ULTOA)
702  return _ultoa(value, string, radix);
703 #else
704  char *bufp = string;
705 
706  if (value) {
707  while (value > 0) {
708  *bufp++ = ntoa_table[value % radix];
709  value /= radix;
710  }
711  } else {
712  *bufp++ = '0';
713  }
714  *bufp = '\0';
715 
716  /* The numbers went into the string backwards. :) */
717  SDL_strrev(string);
718 
719  return string;
720 #endif /* HAVE__ULTOA */
721 }
GLsizei const GLchar *const * string
static const char ntoa_table[]
Definition: SDL_string.c:651
char * SDL_strrev(char *string)
Definition: SDL_string.c:547
GLsizei const GLfloat * value

◆ SDL_utf8strlcpy()

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

Definition at line 484 of file SDL_string.c.

References i, SDL_memcpy(), SDL_min, SDL_strlen(), UTF8_IsLeadByte, UTF8_IsTrailingByte, and UTF8_TrailingBytes().

Referenced by SDL_memset4().

485 {
486  size_t src_bytes = SDL_strlen(src);
487  size_t bytes = SDL_min(src_bytes, dst_bytes - 1);
488  size_t i = 0;
489  char trailing_bytes = 0;
490  if (bytes)
491  {
492  unsigned char c = (unsigned char)src[bytes - 1];
493  if (UTF8_IsLeadByte(c))
494  --bytes;
495  else if (UTF8_IsTrailingByte(c))
496  {
497  for (i = bytes - 1; i != 0; --i)
498  {
499  c = (unsigned char)src[i];
500  trailing_bytes = UTF8_TrailingBytes(c);
501  if (trailing_bytes)
502  {
503  if (bytes - i != trailing_bytes + 1)
504  bytes = i;
505 
506  break;
507  }
508  }
509  }
510  SDL_memcpy(dst, src, bytes);
511  }
512  dst[bytes] = '\0';
513  return bytes;
514 }
GLenum GLenum dst
#define SDL_min(x, y)
Definition: SDL_stdinc.h:351
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
#define UTF8_IsLeadByte(c)
Definition: SDL_string.c:40
const GLubyte * c
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:314
static int UTF8_TrailingBytes(unsigned char c)
Definition: SDL_string.c:43
GLenum src
#define UTF8_IsTrailingByte(c)
Definition: SDL_string.c:41

◆ SDL_vsnprintf()

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

Definition at line 1483 of file SDL_string.c.

References done, SDL_FormatInfo::force_case, SDL_FormatInfo::force_sign, SDL_FormatInfo::force_type, SDL_FormatInfo::left_justify, SDL_FormatInfo::pad_zeroes, SDL_FormatInfo::precision, SDL_FormatInfo::radix, SDL_CASE_LOWER, SDL_CASE_NOCHANGE, SDL_CASE_UPPER, SDL_FALSE, SDL_min, SDL_PrintFloat(), SDL_PrintLong(), SDL_PrintLongLong(), SDL_PrintString(), SDL_PrintUnsignedLong(), SDL_PrintUnsignedLongLong(), SDL_strncmp(), SDL_strtol(), SDL_TRUE, SDL_zero, text, and SDL_FormatInfo::width.

Referenced by SDL_memset4(), and SDL_snprintf().

1484 {
1485  size_t left = maxlen;
1486  char *textstart = text;
1487 
1488  if (!fmt) {
1489  fmt = "";
1490  }
1491  while (*fmt) {
1492  if (*fmt == '%') {
1494  size_t len = 0;
1495  SDL_bool check_flag;
1496  SDL_FormatInfo info;
1497  enum
1498  {
1499  DO_INT,
1500  DO_LONG,
1501  DO_LONGLONG
1502  } inttype = DO_INT;
1503 
1504  SDL_zero(info);
1505  info.radix = 10;
1506  info.precision = -1;
1507 
1508  check_flag = SDL_TRUE;
1509  while (check_flag) {
1510  ++fmt;
1511  switch (*fmt) {
1512  case '-':
1513  info.left_justify = SDL_TRUE;
1514  break;
1515  case '+':
1516  info.force_sign = SDL_TRUE;
1517  break;
1518  case '#':
1519  info.force_type = SDL_TRUE;
1520  break;
1521  case '0':
1522  info.pad_zeroes = SDL_TRUE;
1523  break;
1524  default:
1525  check_flag = SDL_FALSE;
1526  break;
1527  }
1528  }
1529 
1530  if (*fmt >= '0' && *fmt <= '9') {
1531  info.width = SDL_strtol(fmt, (char **)&fmt, 0);
1532  }
1533 
1534  if (*fmt == '.') {
1535  ++fmt;
1536  if (*fmt >= '0' && *fmt <= '9') {
1537  info.precision = SDL_strtol(fmt, (char **)&fmt, 0);
1538  } else {
1539  info.precision = 0;
1540  }
1541  }
1542 
1543  while (!done) {
1544  switch (*fmt) {
1545  case '%':
1546  if (left > 1) {
1547  *text = '%';
1548  }
1549  len = 1;
1550  done = SDL_TRUE;
1551  break;
1552  case 'c':
1553  /* char is promoted to int when passed through (...) */
1554  if (left > 1) {
1555  *text = (char) va_arg(ap, int);
1556  }
1557  len = 1;
1558  done = SDL_TRUE;
1559  break;
1560  case 'h':
1561  /* short is promoted to int when passed through (...) */
1562  break;
1563  case 'l':
1564  if (inttype < DO_LONGLONG) {
1565  ++inttype;
1566  }
1567  break;
1568  case 'I':
1569  if (SDL_strncmp(fmt, "I64", 3) == 0) {
1570  fmt += 2;
1571  inttype = DO_LONGLONG;
1572  }
1573  break;
1574  case 'i':
1575  case 'd':
1576  switch (inttype) {
1577  case DO_INT:
1578  len = SDL_PrintLong(text, left, &info,
1579  (long) va_arg(ap, int));
1580  break;
1581  case DO_LONG:
1582  len = SDL_PrintLong(text, left, &info,
1583  va_arg(ap, long));
1584  break;
1585  case DO_LONGLONG:
1586  len = SDL_PrintLongLong(text, left, &info,
1587  va_arg(ap, Sint64));
1588  break;
1589  }
1590  done = SDL_TRUE;
1591  break;
1592  case 'p':
1593  case 'x':
1594  info.force_case = SDL_CASE_LOWER;
1595  /* Fall through to 'X' handling */
1596  case 'X':
1597  if (info.force_case == SDL_CASE_NOCHANGE) {
1598  info.force_case = SDL_CASE_UPPER;
1599  }
1600  if (info.radix == 10) {
1601  info.radix = 16;
1602  }
1603  if (*fmt == 'p') {
1604  inttype = DO_LONG;
1605  }
1606  /* Fall through to unsigned handling */
1607  case 'o':
1608  if (info.radix == 10) {
1609  info.radix = 8;
1610  }
1611  /* Fall through to unsigned handling */
1612  case 'u':
1613  info.pad_zeroes = SDL_TRUE;
1614  switch (inttype) {
1615  case DO_INT:
1616  len = SDL_PrintUnsignedLong(text, left, &info,
1617  (unsigned long)
1618  va_arg(ap, unsigned int));
1619  break;
1620  case DO_LONG:
1621  len = SDL_PrintUnsignedLong(text, left, &info,
1622  va_arg(ap, unsigned long));
1623  break;
1624  case DO_LONGLONG:
1625  len = SDL_PrintUnsignedLongLong(text, left, &info,
1626  va_arg(ap, Uint64));
1627  break;
1628  }
1629  done = SDL_TRUE;
1630  break;
1631  case 'f':
1632  len = SDL_PrintFloat(text, left, &info, va_arg(ap, double));
1633  done = SDL_TRUE;
1634  break;
1635  case 's':
1636  len = SDL_PrintString(text, left, &info, va_arg(ap, char *));
1637  done = SDL_TRUE;
1638  break;
1639  default:
1640  done = SDL_TRUE;
1641  break;
1642  }
1643  ++fmt;
1644  }
1645  if (len >= left) {
1646  text += (left > 1) ? left - 1 : 0;
1647  left = SDL_min(left, 1);
1648  } else {
1649  text += len;
1650  left -= len;
1651  }
1652  } else {
1653  if (left > 1) {
1654  *text = *fmt;
1655  --left;
1656  }
1657  ++fmt;
1658  ++text;
1659  }
1660  }
1661  if (left > 0) {
1662  *text = '\0';
1663  }
1664  return (int)(text - textstart);
1665 }
#define SDL_min(x, y)
Definition: SDL_stdinc.h:351
SDL_bool left_justify
Definition: SDL_string.c:1304
SDL_bool pad_zeroes
Definition: SDL_string.c:1307
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
SDL_bool force_type
Definition: SDL_string.c:1306
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:170
GLenum GLsizei len
long SDL_strtol(const char *string, char **endp, int base)
Definition: SDL_string.c:786
static size_t SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
Definition: SDL_string.c:1362
static size_t SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
Definition: SDL_string.c:1344
SDL_bool force_sign
Definition: SDL_string.c:1305
GLint left
int done
Definition: checkkeys.c:28
#define SDL_zero(x)
Definition: SDL_stdinc.h:361
SDL_bool
Definition: SDL_stdinc.h:130
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
SDL_letter_case force_case
Definition: SDL_string.c:1308
static size_t SDL_PrintUnsignedLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Uint64 value)
Definition: SDL_string.c:1371
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:166
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
Definition: SDL_string.c:1315
static size_t SDL_PrintUnsignedLong(char *text, size_t maxlen, SDL_FormatInfo *info, unsigned long value)
Definition: SDL_string.c:1353
static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
Definition: SDL_string.c:1380

◆ SDL_vsscanf()

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

Definition at line 1010 of file SDL_string.c.

References done, retval, SDL_FALSE, SDL_isspace, SDL_ScanFloat(), SDL_ScanLong(), SDL_ScanLongLong(), SDL_ScanUintPtrT(), SDL_ScanUnsignedLong(), SDL_ScanUnsignedLongLong(), SDL_strncmp(), SDL_tolower, SDL_TRUE, and text.

Referenced by SDL_memset4(), and SDL_sscanf().

1011 {
1012  int retval = 0;
1013 
1014  while (*fmt) {
1015  if (*fmt == ' ') {
1016  while (SDL_isspace((unsigned char) *text)) {
1017  ++text;
1018  }
1019  ++fmt;
1020  continue;
1021  }
1022  if (*fmt == '%') {
1024  long count = 0;
1025  int radix = 10;
1026  enum
1027  {
1028  DO_SHORT,
1029  DO_INT,
1030  DO_LONG,
1031  DO_LONGLONG
1032  } inttype = DO_INT;
1033  SDL_bool suppress = SDL_FALSE;
1034 
1035  ++fmt;
1036  if (*fmt == '%') {
1037  if (*text == '%') {
1038  ++text;
1039  ++fmt;
1040  continue;
1041  }
1042  break;
1043  }
1044  if (*fmt == '*') {
1045  suppress = SDL_TRUE;
1046  ++fmt;
1047  }
1048  fmt += SDL_ScanLong(fmt, 10, &count);
1049 
1050  if (*fmt == 'c') {
1051  if (!count) {
1052  count = 1;
1053  }
1054  if (suppress) {
1055  while (count--) {
1056  ++text;
1057  }
1058  } else {
1059  char *valuep = va_arg(ap, char *);
1060  while (count--) {
1061  *valuep++ = *text++;
1062  }
1063  ++retval;
1064  }
1065  continue;
1066  }
1067 
1068  while (SDL_isspace((unsigned char) *text)) {
1069  ++text;
1070  }
1071 
1072  /* FIXME: implement more of the format specifiers */
1073  while (!done) {
1074  switch (*fmt) {
1075  case '*':
1076  suppress = SDL_TRUE;
1077  break;
1078  case 'h':
1079  if (inttype > DO_SHORT) {
1080  ++inttype;
1081  }
1082  break;
1083  case 'l':
1084  if (inttype < DO_LONGLONG) {
1085  ++inttype;
1086  }
1087  break;
1088  case 'I':
1089  if (SDL_strncmp(fmt, "I64", 3) == 0) {
1090  fmt += 2;
1091  inttype = DO_LONGLONG;
1092  }
1093  break;
1094  case 'i':
1095  {
1096  int index = 0;
1097  if (text[index] == '-') {
1098  ++index;
1099  }
1100  if (text[index] == '0') {
1101  if (SDL_tolower((unsigned char) text[index + 1]) == 'x') {
1102  radix = 16;
1103  } else {
1104  radix = 8;
1105  }
1106  }
1107  }
1108  /* Fall through to %d handling */
1109  case 'd':
1110  if (inttype == DO_LONGLONG) {
1111  Sint64 value;
1112  text += SDL_ScanLongLong(text, radix, &value);
1113  if (!suppress) {
1114  Sint64 *valuep = va_arg(ap, Sint64 *);
1115  *valuep = value;
1116  ++retval;
1117  }
1118  } else {
1119  long value;
1120  text += SDL_ScanLong(text, radix, &value);
1121  if (!suppress) {
1122  switch (inttype) {
1123  case DO_SHORT:
1124  {
1125  short *valuep = va_arg(ap, short *);
1126  *valuep = (short) value;
1127  }
1128  break;
1129  case DO_INT:
1130  {
1131  int *valuep = va_arg(ap, int *);
1132  *valuep = (int) value;
1133  }
1134  break;
1135  case DO_LONG:
1136  {
1137  long *valuep = va_arg(ap, long *);
1138  *valuep = value;
1139  }
1140  break;
1141  case DO_LONGLONG:
1142  /* Handled above */
1143  break;
1144  }
1145  ++retval;
1146  }
1147  }
1148  done = SDL_TRUE;
1149  break;
1150  case 'o':
1151  if (radix == 10) {
1152  radix = 8;
1153  }
1154  /* Fall through to unsigned handling */
1155  case 'x':
1156  case 'X':
1157  if (radix == 10) {
1158  radix = 16;
1159  }
1160  /* Fall through to unsigned handling */
1161  case 'u':
1162  if (inttype == DO_LONGLONG) {
1163  Uint64 value;
1164  text += SDL_ScanUnsignedLongLong(text, radix, &value);
1165  if (!suppress) {
1166  Uint64 *valuep = va_arg(ap, Uint64 *);
1167  *valuep = value;
1168  ++retval;
1169  }
1170  } else {
1171  unsigned long value;
1172  text += SDL_ScanUnsignedLong(text, radix, &value);
1173  if (!suppress) {
1174  switch (inttype) {
1175  case DO_SHORT:
1176  {
1177  short *valuep = va_arg(ap, short *);
1178  *valuep = (short) value;
1179  }
1180  break;
1181  case DO_INT:
1182  {
1183  int *valuep = va_arg(ap, int *);
1184  *valuep = (int) value;
1185  }
1186  break;
1187  case DO_LONG:
1188  {
1189  long *valuep = va_arg(ap, long *);
1190  *valuep = value;
1191  }
1192  break;
1193  case DO_LONGLONG:
1194  /* Handled above */
1195  break;
1196  }
1197  ++retval;
1198  }
1199  }
1200  done = SDL_TRUE;
1201  break;
1202  case 'p':
1203  {
1204  uintptr_t value;
1205  text += SDL_ScanUintPtrT(text, 16, &value);
1206  if (!suppress) {
1207  void **valuep = va_arg(ap, void **);
1208  *valuep = (void *) value;
1209  ++retval;
1210  }
1211  }
1212  done = SDL_TRUE;
1213  break;
1214  case 'f':
1215  {
1216  double value;
1217  text += SDL_ScanFloat(text, &value);
1218  if (!suppress) {
1219  float *valuep = va_arg(ap, float *);
1220  *valuep = (float) value;
1221  ++retval;
1222  }
1223  }
1224  done = SDL_TRUE;
1225  break;
1226  case 's':
1227  if (suppress) {
1228  while (!SDL_isspace((unsigned char) *text)) {
1229  ++text;
1230  if (count) {
1231  if (--count == 0) {
1232  break;
1233  }
1234  }
1235  }
1236  } else {
1237  char *valuep = va_arg(ap, char *);
1238  while (!SDL_isspace((unsigned char) *text)) {
1239  *valuep++ = *text++;
1240  if (count) {
1241  if (--count == 0) {
1242  break;
1243  }
1244  }
1245  }
1246  *valuep = '\0';
1247  ++retval;
1248  }
1249  done = SDL_TRUE;
1250  break;
1251  default:
1252  done = SDL_TRUE;
1253  break;
1254  }
1255  ++fmt;
1256  }
1257  continue;
1258  }
1259  if (*text == *fmt) {
1260  ++text;
1261  ++fmt;
1262  continue;
1263  }
1264  /* Text didn't match format specifier */
1265  break;
1266  }
1267 
1268  return retval;
1269 }
static size_t SDL_ScanFloat(const char *text, double *valuep)
Definition: SDL_string.c:235
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1564
#define SDL_tolower
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:170
static size_t SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep)
Definition: SDL_string.c:130
static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
Definition: SDL_string.c:57
SDL_bool retval
GLsizei const GLfloat * value
int done
Definition: checkkeys.c:28
unsigned int uintptr_t
#define SDL_isspace
GLuint index
SDL_bool
Definition: SDL_stdinc.h:130
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
Definition: SDL_string.c:162
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:166
static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
Definition: SDL_string.c:203
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:98

◆ SDL_wcslcat()

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

Definition at line 454 of file SDL_string.c.

References SDL_wcslcpy(), and SDL_wcslen().

Referenced by SDL_memset4().

455 {
456 #if defined(HAVE_WCSLCAT)
457  return wcslcat(dst, src, maxlen);
458 #else
459  size_t dstlen = SDL_wcslen(dst);
460  size_t srclen = SDL_wcslen(src);
461  if (dstlen < maxlen) {
462  SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen);
463  }
464  return dstlen + srclen;
465 #endif /* HAVE_WCSLCAT */
466 }
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:424
GLenum GLenum dst
size_t SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
Definition: SDL_string.c:438
GLenum src

◆ SDL_wcslcpy()

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

Definition at line 438 of file SDL_string.c.

References SDL_memcpy(), SDL_min, and SDL_wcslen().

Referenced by SDL_memset4(), and SDL_wcslcat().

439 {
440 #if defined(HAVE_WCSLCPY)
441  return wcslcpy(dst, src, maxlen);
442 #else
443  size_t srclen = SDL_wcslen(src);
444  if (maxlen > 0) {
445  size_t len = SDL_min(srclen, maxlen - 1);
446  SDL_memcpy(dst, src, len * sizeof(wchar_t));
447  dst[len] = '\0';
448  }
449  return srclen;
450 #endif /* HAVE_WCSLCPY */
451 }
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:424
GLenum GLenum dst
#define SDL_min(x, y)
Definition: SDL_stdinc.h:351
GLenum GLsizei len
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:314
GLenum src

◆ SDL_wcslen()

size_t SDL_wcslen ( const wchar_t *  wstr)

Definition at line 424 of file SDL_string.c.

Referenced by SDL_memset4(), SDL_wcslcat(), and SDL_wcslcpy().

425 {
426 #if defined(HAVE_WCSLEN)
427  return wcslen(string);
428 #else
429  size_t len = 0;
430  while (*string++) {
431  ++len;
432  }
433  return len;
434 #endif /* HAVE_WCSLEN */
435 }
GLenum GLsizei len