update SDL3 from 3.2.20 to 3.4.2
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
@@ -222,7 +222,7 @@ char **SDL_GetEnvironmentVariables(SDL_Environment *env)
|
||||
{
|
||||
char **result = NULL;
|
||||
|
||||
if (!env) {
|
||||
CHECK_PARAM(!env) {
|
||||
SDL_InvalidParamError("env");
|
||||
return NULL;
|
||||
}
|
||||
@@ -253,11 +253,13 @@ bool SDL_SetEnvironmentVariable(SDL_Environment *env, const char *name, const ch
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (!env) {
|
||||
CHECK_PARAM(!env) {
|
||||
return SDL_InvalidParamError("env");
|
||||
} else if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL) {
|
||||
}
|
||||
CHECK_PARAM(!name || *name == '\0' || SDL_strchr(name, '=') != NULL) {
|
||||
return SDL_InvalidParamError("name");
|
||||
} else if (!value) {
|
||||
}
|
||||
CHECK_PARAM(!value) {
|
||||
return SDL_InvalidParamError("value");
|
||||
}
|
||||
|
||||
@@ -292,9 +294,10 @@ bool SDL_UnsetEnvironmentVariable(SDL_Environment *env, const char *name)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (!env) {
|
||||
CHECK_PARAM(!env) {
|
||||
return SDL_InvalidParamError("env");
|
||||
} else if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL) {
|
||||
}
|
||||
CHECK_PARAM(!name || *name == '\0' || SDL_strchr(name, '=') != NULL) {
|
||||
return SDL_InvalidParamError("name");
|
||||
}
|
||||
|
||||
@@ -334,7 +337,9 @@ int SDL_setenv_unsafe(const char *name, const char *value, int overwrite)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_SetEnvironmentVariable(SDL_GetEnvironment(), name, value, (overwrite != 0));
|
||||
if (SDL_environment) {
|
||||
SDL_SetEnvironmentVariable(SDL_environment, name, value, (overwrite != 0));
|
||||
}
|
||||
|
||||
return setenv(name, value, overwrite);
|
||||
}
|
||||
@@ -349,7 +354,9 @@ int SDL_setenv_unsafe(const char *name, const char *value, int overwrite)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_SetEnvironmentVariable(SDL_GetEnvironment(), name, value, (overwrite != 0));
|
||||
if (SDL_environment) {
|
||||
SDL_SetEnvironmentVariable(SDL_environment, name, value, (overwrite != 0));
|
||||
}
|
||||
|
||||
if (getenv(name) != NULL) {
|
||||
if (!overwrite) {
|
||||
@@ -373,7 +380,9 @@ int SDL_setenv_unsafe(const char *name, const char *value, int overwrite)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_SetEnvironmentVariable(SDL_GetEnvironment(), name, value, (overwrite != 0));
|
||||
if (SDL_environment) {
|
||||
SDL_SetEnvironmentVariable(SDL_environment, name, value, (overwrite != 0));
|
||||
}
|
||||
|
||||
if (!overwrite) {
|
||||
if (GetEnvironmentVariableA(name, NULL, 0) > 0) {
|
||||
@@ -404,7 +413,9 @@ int SDL_setenv_unsafe(const char *name, const char *value, int overwrite)
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_SetEnvironmentVariable(SDL_GetEnvironment(), name, value, (overwrite != 0));
|
||||
if (SDL_environment) {
|
||||
SDL_SetEnvironmentVariable(SDL_environment, name, value, (overwrite != 0));
|
||||
}
|
||||
|
||||
// Allocate memory for the variable
|
||||
len = SDL_strlen(name) + SDL_strlen(value) + 2;
|
||||
@@ -459,7 +470,9 @@ int SDL_unsetenv_unsafe(const char *name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_UnsetEnvironmentVariable(SDL_GetEnvironment(), name);
|
||||
if (SDL_environment) {
|
||||
SDL_UnsetEnvironmentVariable(SDL_environment, name);
|
||||
}
|
||||
|
||||
return unsetenv(name);
|
||||
}
|
||||
@@ -472,7 +485,9 @@ int SDL_unsetenv_unsafe(const char *name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_UnsetEnvironmentVariable(SDL_GetEnvironment(), name);
|
||||
if (SDL_environment) {
|
||||
SDL_UnsetEnvironmentVariable(SDL_environment, name);
|
||||
}
|
||||
|
||||
// Hope this environment uses the non-standard extension of removing the environment variable if it has no '='
|
||||
return putenv(name);
|
||||
@@ -486,7 +501,9 @@ int SDL_unsetenv_unsafe(const char *name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_UnsetEnvironmentVariable(SDL_GetEnvironment(), name);
|
||||
if (SDL_environment) {
|
||||
SDL_UnsetEnvironmentVariable(SDL_environment, name);
|
||||
}
|
||||
|
||||
if (!SetEnvironmentVariableA(name, NULL)) {
|
||||
return -1;
|
||||
@@ -503,7 +520,9 @@ int SDL_unsetenv_unsafe(const char *name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_UnsetEnvironmentVariable(SDL_GetEnvironment(), name);
|
||||
if (SDL_environment) {
|
||||
SDL_UnsetEnvironmentVariable(SDL_environment, name);
|
||||
}
|
||||
|
||||
if (environ) {
|
||||
len = SDL_strlen(name);
|
||||
@@ -561,9 +580,7 @@ const char *SDL_getenv_unsafe(const char *name)
|
||||
maxlen = length;
|
||||
} else {
|
||||
if (GetLastError() != ERROR_SUCCESS) {
|
||||
if (string) {
|
||||
SDL_free(string);
|
||||
}
|
||||
SDL_free(string);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
@@ -3042,7 +3042,7 @@ static size_t traverse_and_check(mstate m);
|
||||
http://www.usenix.org/events/lisa03/tech/robertson.html The footer
|
||||
of an inuse chunk holds the xor of its mstate and a random seed,
|
||||
that is checked upon calls to free() and realloc(). This is
|
||||
(probabalistically) unguessable from outside the program, but can be
|
||||
(probabilistically) unguessable from outside the program, but can be
|
||||
computed by any code successfully malloc'ing any chunk, so does not
|
||||
itself provide protection against code that has already broken
|
||||
security through some other means. Unlike Robertson et al, we
|
||||
@@ -6419,16 +6419,16 @@ bool SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
|
||||
SDL_realloc_func realloc_func,
|
||||
SDL_free_func free_func)
|
||||
{
|
||||
if (!malloc_func) {
|
||||
CHECK_PARAM(!malloc_func) {
|
||||
return SDL_InvalidParamError("malloc_func");
|
||||
}
|
||||
if (!calloc_func) {
|
||||
CHECK_PARAM(!calloc_func) {
|
||||
return SDL_InvalidParamError("calloc_func");
|
||||
}
|
||||
if (!realloc_func) {
|
||||
CHECK_PARAM(!realloc_func) {
|
||||
return SDL_InvalidParamError("realloc_func");
|
||||
}
|
||||
if (!free_func) {
|
||||
CHECK_PARAM(!free_func) {
|
||||
return SDL_InvalidParamError("free_func");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
@@ -95,6 +95,39 @@ void _ftol2()
|
||||
_ftol();
|
||||
}
|
||||
|
||||
void __declspec(naked) _ftoul2_legacy()
|
||||
{
|
||||
static const Uint64 LLONG_MAX_PLUS_ONE = 0x43e0000000000000ULL;
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
fld qword ptr [LLONG_MAX_PLUS_ONE]
|
||||
fcom
|
||||
fnstsw ax
|
||||
test ah, 41h
|
||||
jnp greater_than_int64
|
||||
|
||||
fstp st(0)
|
||||
jmp _ftol
|
||||
|
||||
greater_than_int64:
|
||||
fsub st(1), st(0)
|
||||
fcomp
|
||||
fnstsw ax
|
||||
test ah, 41h
|
||||
jnz greater_than_uint64
|
||||
|
||||
call _ftol
|
||||
add edx, 80000000h
|
||||
ret
|
||||
|
||||
greater_than_uint64:
|
||||
xor eax, eax
|
||||
mov edx, 80000000h
|
||||
ret
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
// 64-bit math operators for 32-bit systems
|
||||
void __declspec(naked) _allmul()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
@@ -333,7 +333,7 @@ typedef struct { char * first; char * last; } stack_entry;
|
||||
char *test; \
|
||||
/* Find the right place for |first|. \
|
||||
* My apologies for var reuse. */ \
|
||||
for (test=first-size;compare(userdata,test,first)>0;test-=size) ; \
|
||||
for (test=first-size;test>=(char*)base&&compare(userdata,test,first)>0;test-=size) ; \
|
||||
test+=size; \
|
||||
if (test!=first) { \
|
||||
/* Shift everything in [test,first) \
|
||||
@@ -418,6 +418,7 @@ static void qsort_r_nonaligned(void *base, size_t nmemb, size_t size,
|
||||
while (1) {
|
||||
/* Select pivot */
|
||||
{ char * mid=first+size*((last-first)/size >> 1);
|
||||
if (mid>=last) break;
|
||||
Pivot(SWAP_nonaligned,size);
|
||||
memcpy(pivot,mid,size);
|
||||
}
|
||||
@@ -449,6 +450,7 @@ static void qsort_r_aligned(void *base, size_t nmemb, size_t size,
|
||||
while (1) {
|
||||
/* Select pivot */
|
||||
{ char * mid=first+size*((last-first)/size >> 1);
|
||||
if (mid>=last) break;
|
||||
Pivot(SWAP_aligned,size);
|
||||
memcpy(pivot,mid,size);
|
||||
}
|
||||
@@ -484,6 +486,7 @@ fprintf(stderr,"Doing %d:%d: ",
|
||||
#endif
|
||||
/* Select pivot */
|
||||
{ char * mid=first+WORD_BYTES*((last-first) / (2*WORD_BYTES));
|
||||
if (mid>=last) break;
|
||||
Pivot(SWAP_words,WORD_BYTES);
|
||||
*(int*)pivot=*(int*)mid;
|
||||
#ifdef DEBUG_QSORT
|
||||
@@ -506,7 +509,7 @@ fprintf(stderr, "after partitioning first=#%lu last=#%lu\n", (first-(char*)base)
|
||||
/* Find the right place for |first|. My apologies for var reuse */
|
||||
int *pl=(int*)(first-WORD_BYTES),*pr=(int*)first;
|
||||
*(int*)pivot=*(int*)first;
|
||||
for (;compare(userdata,pl,pivot)>0;pr=pl,--pl) {
|
||||
for (;pl>=(int*)base&&compare(userdata,pl,pivot)>0;pr=pl,--pl) {
|
||||
*pr=*pl; }
|
||||
if (pr!=(int*)first) *pr=*(int*)pivot;
|
||||
}
|
||||
@@ -571,4 +574,3 @@ void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size,
|
||||
// qsort_non_r_bridge just happens to match calling conventions, so reuse it.
|
||||
return SDL_bsearch_r(key, base, nmemb, size, qsort_non_r_bridge, compare);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
@@ -140,12 +140,6 @@ double SDL_copysign(double x, double y)
|
||||
return copysign(x, y);
|
||||
#elif defined(HAVE__COPYSIGN)
|
||||
return _copysign(x, y);
|
||||
#elif defined(__WATCOMC__) && defined(__386__)
|
||||
// this is nasty as hell, but it works..
|
||||
unsigned int *xi = (unsigned int *)&x,
|
||||
*yi = (unsigned int *)&y;
|
||||
xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff);
|
||||
return x;
|
||||
#else
|
||||
return SDL_uclibc_copysign(x, y);
|
||||
#endif // HAVE_COPYSIGN
|
||||
@@ -535,8 +529,8 @@ void *SDL_aligned_alloc(size_t alignment, size_t size)
|
||||
Uint8 *result = NULL;
|
||||
size_t requested_size = size;
|
||||
|
||||
if (alignment < sizeof(void*)) {
|
||||
alignment = sizeof(void*);
|
||||
if (alignment < sizeof(void *)) {
|
||||
alignment = sizeof(void *);
|
||||
}
|
||||
padding = (alignment - (size % alignment));
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
#if defined(__SIZEOF_WCHAR_T__)
|
||||
#define SDL_SIZEOF_WCHAR_T __SIZEOF_WCHAR_T__
|
||||
#elif defined(SDL_PLATFORM_NGAGE)
|
||||
#define SDL_SIZEOF_WCHAR_T 2
|
||||
#elif defined(SDL_PLATFORM_WINDOWS)
|
||||
#define SDL_SIZEOF_WCHAR_T 2
|
||||
#else // assume everything else is UTF-32 (add more tests if compiler-assert fails below!)
|
||||
@@ -1828,24 +1830,7 @@ int SDL_swprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_
|
||||
return result;
|
||||
}
|
||||
|
||||
#if defined(HAVE_LIBC) && defined(__WATCOMC__)
|
||||
// _vsnprintf() doesn't ensure nul termination
|
||||
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||
{
|
||||
int result;
|
||||
if (!fmt) {
|
||||
fmt = "";
|
||||
}
|
||||
result = _vsnprintf(text, maxlen, fmt, ap);
|
||||
if (maxlen > 0) {
|
||||
text[maxlen - 1] = '\0';
|
||||
}
|
||||
if (result < 0) {
|
||||
result = (int)maxlen;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#elif defined(HAVE_VSNPRINTF)
|
||||
#if defined(HAVE_VSNPRINTF)
|
||||
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||
{
|
||||
if (!fmt) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
@@ -20,11 +20,12 @@
|
||||
*/
|
||||
|
||||
// Do our best to make sure va_copy is working
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1800
|
||||
#if (defined(_MSC_VER) && _MSC_VER <= 1800) || defined(__SYMBIAN32__)
|
||||
// Visual Studio 2013 tries to link with _vacopy in the C runtime. Newer versions do an inline assignment
|
||||
#undef va_copy
|
||||
#define va_copy(dst, src) dst = src
|
||||
|
||||
#elif defined(__GNUC__) && (__GNUC__ < 3)
|
||||
#define va_copy(dst, src) __va_copy(dst, src)
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user