mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-17 00:55:45 -04:00
dep: Update SDL2 to 2.24.2
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -80,9 +80,9 @@
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
#ifdef HAVE_MATH_H
|
||||
# if defined(__WINRT__)
|
||||
# if defined(_MSC_VER)
|
||||
/* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on
|
||||
WinRT. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
|
||||
Visual Studio. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
|
||||
for more information.
|
||||
*/
|
||||
# define _USE_MATH_DEFINES
|
||||
@ -115,6 +115,23 @@ char *alloca();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef SIZE_MAX
|
||||
# define SDL_SIZE_MAX SIZE_MAX
|
||||
#else
|
||||
# define SDL_SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Check if the compiler supports a given builtin.
|
||||
* Supported by virtually all clang versions and recent gcc. Use this
|
||||
* instead of checking the clang version if possible.
|
||||
*/
|
||||
#ifdef __has_builtin
|
||||
#define _SDL_HAS_BUILTIN(x) __has_builtin(x)
|
||||
#else
|
||||
#define _SDL_HAS_BUILTIN(x) 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The number of elements in an array.
|
||||
*/
|
||||
@ -223,13 +240,26 @@ typedef uint64_t Uint64;
|
||||
|
||||
/* @} *//* Basic data types */
|
||||
|
||||
/**
|
||||
* \name Floating-point constants
|
||||
*/
|
||||
/* @{ */
|
||||
|
||||
#ifdef FLT_EPSILON
|
||||
#define SDL_FLT_EPSILON FLT_EPSILON
|
||||
#else
|
||||
#define SDL_FLT_EPSILON 1.1920928955078125e-07F /* 0x0.000002p0 */
|
||||
#endif
|
||||
|
||||
/* @} *//* Floating-point constants */
|
||||
|
||||
/* Make sure we have macros for printing width-based integers.
|
||||
* <stdint.h> should define these but this is not true all platforms.
|
||||
* (for example win32) */
|
||||
#ifndef SDL_PRIs64
|
||||
#ifdef PRIs64
|
||||
#define SDL_PRIs64 PRIs64
|
||||
#elif defined(__WIN32__)
|
||||
#elif defined(__WIN32__) || defined(__GDK__)
|
||||
#define SDL_PRIs64 "I64d"
|
||||
#elif defined(__LINUX__) && defined(__LP64__)
|
||||
#define SDL_PRIs64 "ld"
|
||||
@ -240,7 +270,7 @@ typedef uint64_t Uint64;
|
||||
#ifndef SDL_PRIu64
|
||||
#ifdef PRIu64
|
||||
#define SDL_PRIu64 PRIu64
|
||||
#elif defined(__WIN32__)
|
||||
#elif defined(__WIN32__) || defined(__GDK__)
|
||||
#define SDL_PRIu64 "I64u"
|
||||
#elif defined(__LINUX__) && defined(__LP64__)
|
||||
#define SDL_PRIu64 "lu"
|
||||
@ -251,7 +281,7 @@ typedef uint64_t Uint64;
|
||||
#ifndef SDL_PRIx64
|
||||
#ifdef PRIx64
|
||||
#define SDL_PRIx64 PRIx64
|
||||
#elif defined(__WIN32__)
|
||||
#elif defined(__WIN32__) || defined(__GDK__)
|
||||
#define SDL_PRIx64 "I64x"
|
||||
#elif defined(__LINUX__) && defined(__LP64__)
|
||||
#define SDL_PRIx64 "lx"
|
||||
@ -262,7 +292,7 @@ typedef uint64_t Uint64;
|
||||
#ifndef SDL_PRIX64
|
||||
#ifdef PRIX64
|
||||
#define SDL_PRIX64 PRIX64
|
||||
#elif defined(__WIN32__)
|
||||
#elif defined(__WIN32__) || defined(__GDK__)
|
||||
#define SDL_PRIX64 "I64X"
|
||||
#elif defined(__LINUX__) && defined(__LP64__)
|
||||
#define SDL_PRIX64 "lX"
|
||||
@ -343,8 +373,22 @@ typedef uint64_t Uint64;
|
||||
#endif
|
||||
#endif /* SDL_DISABLE_ANALYZE_MACROS */
|
||||
|
||||
#ifndef SDL_COMPILE_TIME_ASSERT
|
||||
#if defined(__cplusplus)
|
||||
#if (__cplusplus >= 201103L)
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
|
||||
#endif
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
|
||||
#endif
|
||||
#endif /* !SDL_COMPILE_TIME_ASSERT */
|
||||
|
||||
#ifndef SDL_COMPILE_TIME_ASSERT
|
||||
/* universal, but may trigger -Wunused-local-typedefs */
|
||||
#define SDL_COMPILE_TIME_ASSERT(name, x) \
|
||||
typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
|
||||
#endif
|
||||
|
||||
/** \cond */
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
|
||||
@ -402,8 +446,20 @@ typedef void *(SDLCALL *SDL_calloc_func)(size_t nmemb, size_t size);
|
||||
typedef void *(SDLCALL *SDL_realloc_func)(void *mem, size_t size);
|
||||
typedef void (SDLCALL *SDL_free_func)(void *mem);
|
||||
|
||||
/**
|
||||
* Get the original set of SDL memory functions
|
||||
*
|
||||
* \since This function is available since SDL 2.24.0.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetOriginalMemoryFunctions(SDL_malloc_func *malloc_func,
|
||||
SDL_calloc_func *calloc_func,
|
||||
SDL_realloc_func *realloc_func,
|
||||
SDL_free_func *free_func);
|
||||
|
||||
/**
|
||||
* Get the current set of SDL memory functions
|
||||
*
|
||||
* \since This function is available since SDL 2.0.7.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func,
|
||||
SDL_calloc_func *calloc_func,
|
||||
@ -412,6 +468,8 @@ extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func
|
||||
|
||||
/**
|
||||
* Replace SDL's memory allocation functions with a custom set
|
||||
*
|
||||
* \since This function is available since SDL 2.0.7.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
|
||||
SDL_calloc_func calloc_func,
|
||||
@ -420,20 +478,23 @@ extern DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
|
||||
|
||||
/**
|
||||
* Get the number of outstanding (unfreed) allocations
|
||||
*
|
||||
* \since This function is available since SDL 2.0.7.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumAllocations(void);
|
||||
|
||||
extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
|
||||
extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
|
||||
|
||||
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *));
|
||||
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *));
|
||||
extern DECLSPEC void * SDLCALL SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *));
|
||||
|
||||
extern DECLSPEC int SDLCALL SDL_abs(int x);
|
||||
|
||||
/* !!! FIXME: these have side effects. You probably shouldn't use them. */
|
||||
/* !!! FIXME: Maybe we do forceinline functions of SDL_mini, SDL_minf, etc? */
|
||||
/* NOTE: these double-evaluate their arguments, so you should never have side effects in the parameters */
|
||||
#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
|
||||
#define SDL_clamp(x, a, b) (((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x)))
|
||||
|
||||
extern DECLSPEC int SDLCALL SDL_isalpha(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_isalnum(int x);
|
||||
@ -450,6 +511,7 @@ extern DECLSPEC int SDLCALL SDL_isgraph(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_toupper(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_tolower(int x);
|
||||
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_crc16(Uint16 crc, const void *data, size_t len);
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_crc32(Uint32 crc, const void *data, size_t len);
|
||||
|
||||
extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len);
|
||||
@ -458,6 +520,11 @@ extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c,
|
||||
#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
|
||||
#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x)))
|
||||
|
||||
#define SDL_copyp(dst, src) \
|
||||
{ SDL_COMPILE_TIME_ASSERT(SDL_copyp, sizeof (*(dst)) == sizeof (*(src))); } \
|
||||
SDL_memcpy((dst), (src), sizeof (*(src)))
|
||||
|
||||
|
||||
/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */
|
||||
SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
|
||||
{
|
||||
@ -479,25 +546,13 @@ SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
|
||||
if (dwords == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* !!! FIXME: there are better ways to do this, but this is just to clean this up for now. */
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
|
||||
#endif
|
||||
|
||||
switch (dwords % 4) {
|
||||
case 0: do { *_p++ = _val; /* fallthrough */
|
||||
case 3: *_p++ = _val; /* fallthrough */
|
||||
case 2: *_p++ = _val; /* fallthrough */
|
||||
case 1: *_p++ = _val; /* fallthrough */
|
||||
case 0: do { *_p++ = _val; SDL_FALLTHROUGH;
|
||||
case 3: *_p++ = _val; SDL_FALLTHROUGH;
|
||||
case 2: *_p++ = _val; SDL_FALLTHROUGH;
|
||||
case 1: *_p++ = _val;
|
||||
} while ( --_n );
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -530,6 +585,7 @@ extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
|
||||
extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
|
||||
extern DECLSPEC char *SDLCALL SDL_strtokr(char *s1, const char *s2, char **saveptr);
|
||||
extern DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str);
|
||||
extern DECLSPEC size_t SDLCALL SDL_utf8strnlen(const char *str, size_t bytes);
|
||||
|
||||
extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix);
|
||||
extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix);
|
||||
@ -555,6 +611,8 @@ extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING
|
||||
extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, const char *fmt, va_list ap);
|
||||
extern DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... ) SDL_PRINTF_VARARG_FUNC(3);
|
||||
extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap);
|
||||
extern DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
|
||||
extern DECLSPEC int SDLCALL SDL_vasprintf(char **strp, const char *fmt, va_list ap);
|
||||
|
||||
#ifndef HAVE_M_PI
|
||||
#ifndef M_PI
|
||||
@ -562,14 +620,28 @@ extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Use this function to compute arc cosine of `x`.
|
||||
*
|
||||
* The definition of `y = acos(x)` is `x = cos(y)`.
|
||||
*
|
||||
* Domain: `-1 <= x <= 1`
|
||||
*
|
||||
* Range: `0 <= y <= Pi`
|
||||
*
|
||||
* \param x floating point value, in radians.
|
||||
* \returns arc cosine of `x`.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
*/
|
||||
extern DECLSPEC double SDLCALL SDL_acos(double x);
|
||||
extern DECLSPEC float SDLCALL SDL_acosf(float x);
|
||||
extern DECLSPEC double SDLCALL SDL_asin(double x);
|
||||
extern DECLSPEC float SDLCALL SDL_asinf(float x);
|
||||
extern DECLSPEC double SDLCALL SDL_atan(double x);
|
||||
extern DECLSPEC float SDLCALL SDL_atanf(float x);
|
||||
extern DECLSPEC double SDLCALL SDL_atan2(double x, double y);
|
||||
extern DECLSPEC float SDLCALL SDL_atan2f(float x, float y);
|
||||
extern DECLSPEC double SDLCALL SDL_atan2(double y, double x);
|
||||
extern DECLSPEC float SDLCALL SDL_atan2f(float y, float x);
|
||||
extern DECLSPEC double SDLCALL SDL_ceil(double x);
|
||||
extern DECLSPEC float SDLCALL SDL_ceilf(float x);
|
||||
extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
|
||||
@ -619,9 +691,12 @@ extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
|
||||
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
|
||||
size_t * inbytesleft, char **outbuf,
|
||||
size_t * outbytesleft);
|
||||
|
||||
/**
|
||||
* This function converts a string between encodings in one pass, returning a
|
||||
* string that must be freed with SDL_free() or NULL on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
|
||||
const char *fromcode,
|
||||
@ -630,6 +705,7 @@ extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
|
||||
#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)
|
||||
#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t))
|
||||
|
||||
/* force builds using Clang's static analysis tools to use literal C runtime
|
||||
here, since there are possibly tests that are ineffective otherwise. */
|
||||
@ -683,6 +759,65 @@ SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_B
|
||||
return SDL_memcpy(dst, src, dwords * 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* If a * b would overflow, return -1. Otherwise store a * b via ret
|
||||
* and return 0.
|
||||
*
|
||||
* \since This function is available since SDL 2.24.0.
|
||||
*/
|
||||
SDL_FORCE_INLINE int SDL_size_mul_overflow (size_t a,
|
||||
size_t b,
|
||||
size_t *ret)
|
||||
{
|
||||
if (a != 0 && b > SDL_SIZE_MAX / a) {
|
||||
return -1;
|
||||
}
|
||||
*ret = a * b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if _SDL_HAS_BUILTIN(__builtin_mul_overflow)
|
||||
/* This needs to be wrapped in an inline rather than being a direct #define,
|
||||
* because __builtin_mul_overflow() is type-generic, but we want to be
|
||||
* consistent about interpreting a and b as size_t. */
|
||||
SDL_FORCE_INLINE int _SDL_size_mul_overflow_builtin (size_t a,
|
||||
size_t b,
|
||||
size_t *ret)
|
||||
{
|
||||
return __builtin_mul_overflow(a, b, ret) == 0 ? 0 : -1;
|
||||
}
|
||||
#define SDL_size_mul_overflow(a, b, ret) (_SDL_size_mul_overflow_builtin(a, b, ret))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* If a + b would overflow, return -1. Otherwise store a + b via ret
|
||||
* and return 0.
|
||||
*
|
||||
* \since This function is available since SDL 2.24.0.
|
||||
*/
|
||||
SDL_FORCE_INLINE int SDL_size_add_overflow (size_t a,
|
||||
size_t b,
|
||||
size_t *ret)
|
||||
{
|
||||
if (b > SDL_SIZE_MAX - a) {
|
||||
return -1;
|
||||
}
|
||||
*ret = a + b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if _SDL_HAS_BUILTIN(__builtin_add_overflow)
|
||||
/* This needs to be wrapped in an inline rather than being a direct #define,
|
||||
* the same as the call to __builtin_mul_overflow() above. */
|
||||
SDL_FORCE_INLINE int _SDL_size_add_overflow_builtin (size_t a,
|
||||
size_t b,
|
||||
size_t *ret)
|
||||
{
|
||||
return __builtin_add_overflow(a, b, ret) == 0 ? 0 : -1;
|
||||
}
|
||||
#define SDL_size_add_overflow(a, b, ret) (_SDL_size_add_overflow_builtin(a, b, ret))
|
||||
#endif
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user