mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
Updates SDL to version 2.0.4, which makes it compatible with VS2015.
This commit is contained in:
parent
7b52fed504
commit
b63ef177f4
924 changed files with 79241 additions and 39934 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 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
|
||||
|
|
@ -18,6 +18,11 @@
|
|||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
|
||||
#define SDL_DISABLE_ANALYZE_MACROS 1
|
||||
#endif
|
||||
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#if defined(__WIN32__)
|
||||
|
|
@ -33,16 +38,27 @@ static size_t SDL_envmemlen = 0;
|
|||
#endif
|
||||
|
||||
/* Put a variable into the environment */
|
||||
/* Note: Name may not contain a '=' character. (Reference: http://www.unix.com/man-page/Linux/3/setenv/) */
|
||||
#if defined(HAVE_SETENV)
|
||||
int
|
||||
SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return setenv(name, value, overwrite);
|
||||
}
|
||||
#elif defined(__WIN32__)
|
||||
int
|
||||
SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (!overwrite) {
|
||||
char ch = 0;
|
||||
const size_t len = GetEnvironmentVariableA(name, &ch, sizeof (ch));
|
||||
|
|
@ -63,6 +79,11 @@ SDL_setenv(const char *name, const char *value, int overwrite)
|
|||
size_t len;
|
||||
char *new_variable;
|
||||
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (getenv(name) != NULL) {
|
||||
if (overwrite) {
|
||||
unsetenv(name);
|
||||
|
|
@ -91,8 +112,8 @@ SDL_setenv(const char *name, const char *value, int overwrite)
|
|||
char **new_env;
|
||||
char *new_variable;
|
||||
|
||||
/* A little error checking */
|
||||
if (!name || !value) {
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
|
@ -152,6 +173,11 @@ SDL_setenv(const char *name, const char *value, int overwrite)
|
|||
char *
|
||||
SDL_getenv(const char *name)
|
||||
{
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name)==0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return getenv(name);
|
||||
}
|
||||
#elif defined(__WIN32__)
|
||||
|
|
@ -160,6 +186,11 @@ SDL_getenv(const char *name)
|
|||
{
|
||||
size_t bufferlen;
|
||||
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name)==0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bufferlen =
|
||||
GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen);
|
||||
if (bufferlen == 0) {
|
||||
|
|
@ -183,6 +214,11 @@ SDL_getenv(const char *name)
|
|||
int len, i;
|
||||
char *value;
|
||||
|
||||
/* Input validation */
|
||||
if (!name || SDL_strlen(name)==0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
value = (char *) 0;
|
||||
if (SDL_env) {
|
||||
len = SDL_strlen(name);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 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
|
||||
|
|
@ -18,6 +18,11 @@
|
|||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
|
||||
#define SDL_DISABLE_ANALYZE_MACROS 1
|
||||
#endif
|
||||
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
/* This file contains portable iconv functions for SDL */
|
||||
|
|
@ -32,7 +37,8 @@
|
|||
If we get this wrong, it's just a warning, so no big deal.
|
||||
*/
|
||||
#if defined(_XGP6) || defined(__APPLE__) || \
|
||||
(defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)))
|
||||
(defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) || \
|
||||
(defined(_NEWLIB_VERSION)))
|
||||
#define ICONV_INBUF_NONCONST
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 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
|
||||
|
|
@ -18,6 +18,11 @@
|
|||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
|
||||
#define SDL_DISABLE_ANALYZE_MACROS 1
|
||||
#endif
|
||||
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
/* This file contains portable memory management functions for SDL */
|
||||
|
|
@ -54,6 +59,7 @@ void SDL_free(void *ptr)
|
|||
#define LACKS_STRING_H
|
||||
#define LACKS_STDLIB_H
|
||||
#define ABORT
|
||||
#define USE_LOCKS 1
|
||||
|
||||
/*
|
||||
This is a version (aka dlmalloc) of malloc/free/realloc written by
|
||||
|
|
|
|||
|
|
@ -41,6 +41,11 @@
|
|||
*
|
||||
* Gareth McCaughan Peterhouse Cambridge 1998
|
||||
*/
|
||||
|
||||
#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
|
||||
#define SDL_DISABLE_ANALYZE_MACROS 1
|
||||
#endif
|
||||
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 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
|
||||
|
|
@ -18,6 +18,11 @@
|
|||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
|
||||
#define SDL_DISABLE_ANALYZE_MACROS 1
|
||||
#endif
|
||||
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
/* This file contains portable stdlib functions for SDL */
|
||||
|
|
@ -211,6 +216,36 @@ SDL_sqrt(double x)
|
|||
#endif
|
||||
}
|
||||
|
||||
float
|
||||
SDL_sqrtf(float x)
|
||||
{
|
||||
#if defined(HAVE_SQRTF)
|
||||
return sqrtf(x);
|
||||
#else
|
||||
return (float)SDL_sqrt((double)x);
|
||||
#endif
|
||||
}
|
||||
|
||||
double
|
||||
SDL_tan(double x)
|
||||
{
|
||||
#if defined(HAVE_TAN)
|
||||
return tan(x);
|
||||
#else
|
||||
return SDL_uclibc_tan(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
float
|
||||
SDL_tanf(float x)
|
||||
{
|
||||
#if defined(HAVE_TANF)
|
||||
return tanf(x);
|
||||
#else
|
||||
return (float)SDL_tan((double)x);
|
||||
#endif
|
||||
}
|
||||
|
||||
int SDL_abs(int x)
|
||||
{
|
||||
#ifdef HAVE_ABS
|
||||
|
|
@ -243,8 +278,8 @@ int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) :
|
|||
__declspec(selectany) int _fltused = 1;
|
||||
#endif
|
||||
|
||||
/* The optimizer on Visual Studio 2010/2012 generates memcpy() calls */
|
||||
#if _MSC_VER >= 1600 && defined(_WIN64) && !defined(_DEBUG)
|
||||
/* The optimizer on Visual Studio 2005 and later generates memcpy() calls */
|
||||
#if (_MSC_VER >= 1400) && defined(_WIN64) && !defined(_DEBUG)
|
||||
#include <intrin.h>
|
||||
|
||||
#pragma function(memcpy)
|
||||
|
|
@ -347,34 +382,25 @@ _allmul()
|
|||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
push edi
|
||||
push esi
|
||||
mov eax, dword ptr[esp+8]
|
||||
mov ecx, dword ptr[esp+10h]
|
||||
or ecx, eax
|
||||
mov ecx, dword ptr[esp+0Ch]
|
||||
jne hard
|
||||
mov eax, dword ptr[esp+4]
|
||||
mul ecx
|
||||
ret 10h
|
||||
hard:
|
||||
push ebx
|
||||
sub esp,0Ch
|
||||
mov eax,dword ptr [ebp+10h]
|
||||
mov edi,dword ptr [ebp+8]
|
||||
mov ebx,eax
|
||||
mov esi,eax
|
||||
sar esi,1Fh
|
||||
mov eax,dword ptr [ebp+8]
|
||||
mul ebx
|
||||
imul edi,esi
|
||||
mov ecx,edx
|
||||
mov dword ptr [ebp-18h],eax
|
||||
mov edx,dword ptr [ebp+0Ch]
|
||||
add ecx,edi
|
||||
imul ebx,edx
|
||||
mov eax,dword ptr [ebp-18h]
|
||||
lea ebx,[ebx+ecx]
|
||||
mov dword ptr [ebp-14h],ebx
|
||||
mov edx,dword ptr [ebp-14h]
|
||||
add esp,0Ch
|
||||
mul ecx
|
||||
mov ebx, eax
|
||||
mov eax, dword ptr[esp+8]
|
||||
mul dword ptr[esp+14h]
|
||||
add ebx, eax
|
||||
mov eax, dword ptr[esp+8]
|
||||
mul ecx
|
||||
add edx, ebx
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
pop ebp
|
||||
ret 10h
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 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
|
||||
|
|
@ -18,6 +18,15 @@
|
|||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
|
||||
#define SDL_DISABLE_ANALYZE_MACROS 1
|
||||
#endif
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
/* This file contains portable string manipulation functions for SDL */
|
||||
|
|
@ -258,18 +267,30 @@ SDL_ScanFloat(const char *text, double *valuep)
|
|||
#endif
|
||||
|
||||
void *
|
||||
SDL_memset(void *dst, int c, size_t len)
|
||||
SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
|
||||
{
|
||||
#if defined(HAVE_MEMSET)
|
||||
return memset(dst, c, len);
|
||||
#else
|
||||
size_t left = (len % 4);
|
||||
size_t left;
|
||||
Uint32 *dstp4;
|
||||
Uint8 *dstp1;
|
||||
Uint8 *dstp1 = (Uint8 *) dst;
|
||||
Uint32 value4 = (c | (c << 8) | (c << 16) | (c << 24));
|
||||
Uint8 value1 = (Uint8) c;
|
||||
|
||||
dstp4 = (Uint32 *) dst;
|
||||
/* The destination pointer needs to be aligned on a 4-byte boundary to
|
||||
* execute a 32-bit set. Set first bytes manually if needed until it is
|
||||
* aligned. */
|
||||
while ((intptr_t)dstp1 & 0x3) {
|
||||
if (len--) {
|
||||
*dstp1++ = value1;
|
||||
} else {
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
|
||||
dstp4 = (Uint32 *) dstp1;
|
||||
left = (len % 4);
|
||||
len /= 4;
|
||||
while (len--) {
|
||||
*dstp4++ = value4;
|
||||
|
|
@ -290,7 +311,7 @@ SDL_memset(void *dst, int c, size_t len)
|
|||
}
|
||||
|
||||
void *
|
||||
SDL_memcpy(void *dst, const void *src, size_t len)
|
||||
SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
/* Presumably this is well tuned for speed.
|
||||
|
|
@ -343,7 +364,7 @@ SDL_memcpy(void *dst, const void *src, size_t len)
|
|||
}
|
||||
|
||||
void *
|
||||
SDL_memmove(void *dst, const void *src, size_t len)
|
||||
SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
|
||||
{
|
||||
#if defined(HAVE_MEMMOVE)
|
||||
return memmove(dst, src, len);
|
||||
|
|
@ -414,7 +435,7 @@ SDL_wcslen(const wchar_t * string)
|
|||
}
|
||||
|
||||
size_t
|
||||
SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen)
|
||||
SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
|
||||
{
|
||||
#if defined(HAVE_WCSLCPY)
|
||||
return wcslcpy(dst, src, maxlen);
|
||||
|
|
@ -430,7 +451,7 @@ SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen)
|
|||
}
|
||||
|
||||
size_t
|
||||
SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen)
|
||||
SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
|
||||
{
|
||||
#if defined(HAVE_WCSLCAT)
|
||||
return wcslcat(dst, src, maxlen);
|
||||
|
|
@ -445,7 +466,7 @@ SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen)
|
|||
}
|
||||
|
||||
size_t
|
||||
SDL_strlcpy(char *dst, const char *src, size_t maxlen)
|
||||
SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
|
||||
{
|
||||
#if defined(HAVE_STRLCPY)
|
||||
return strlcpy(dst, src, maxlen);
|
||||
|
|
@ -460,7 +481,7 @@ SDL_strlcpy(char *dst, const char *src, size_t maxlen)
|
|||
#endif /* HAVE_STRLCPY */
|
||||
}
|
||||
|
||||
size_t SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes)
|
||||
size_t SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes)
|
||||
{
|
||||
size_t src_bytes = SDL_strlen(src);
|
||||
size_t bytes = SDL_min(src_bytes, dst_bytes - 1);
|
||||
|
|
@ -493,7 +514,7 @@ size_t SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes)
|
|||
}
|
||||
|
||||
size_t
|
||||
SDL_strlcat(char *dst, const char *src, size_t maxlen)
|
||||
SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
|
||||
{
|
||||
#if defined(HAVE_STRLCAT)
|
||||
return strlcat(dst, src, maxlen);
|
||||
|
|
@ -968,7 +989,7 @@ SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen)
|
|||
}
|
||||
|
||||
int
|
||||
SDL_sscanf(const char *text, const char *fmt, ...)
|
||||
SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...)
|
||||
{
|
||||
int rc;
|
||||
va_list ap;
|
||||
|
|
@ -1249,7 +1270,7 @@ SDL_vsscanf(const char *text, const char *fmt, va_list ap)
|
|||
#endif /* HAVE_VSSCANF */
|
||||
|
||||
int
|
||||
SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...)
|
||||
SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int retval;
|
||||
|
|
@ -1262,8 +1283,11 @@ SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...)
|
|||
}
|
||||
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||
{
|
||||
if (!fmt) {
|
||||
fmt = "";
|
||||
}
|
||||
return vsnprintf(text, maxlen, fmt, ap);
|
||||
}
|
||||
#else
|
||||
|
|
@ -1451,11 +1475,14 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
|
|||
}
|
||||
|
||||
int
|
||||
SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||
SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||
{
|
||||
size_t left = maxlen;
|
||||
char *textstart = text;
|
||||
|
||||
if (!fmt) {
|
||||
fmt = "";
|
||||
}
|
||||
while (*fmt) {
|
||||
if (*fmt == '%') {
|
||||
SDL_bool done = SDL_FALSE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue