early-access version 1617

This commit is contained in:
pineappleEA
2021-04-20 21:40:33 +02:00
parent 242b6f6b49
commit f46563104f
510 changed files with 141726 additions and 62846 deletions

52
externals/SDL/src/stdlib/SDL_crc32.c vendored Executable file
View File

@@ -0,0 +1,52 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2020 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
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_internal.h"
#include "SDL_stdinc.h"
/* Public domain CRC implementation adapted from:
http://home.thep.lu.se/~bjorn/crc/crc32_simple.c
*/
/* NOTE: DO NOT CHANGE THIS ALGORITHM
There is code that relies on this in the joystick code
*/
static Uint32 crc32_for_byte(Uint32 r)
{
int i;
for(i = 0; i < 8; ++i) {
r = (r & 1? 0: (Uint32)0xEDB88320L) ^ r >> 1;
}
return r ^ (Uint32)0xFF000000L;
}
Uint32 SDL_crc32(Uint32 crc, const void *data, size_t len)
{
/* As an optimization we can precalculate a 256 entry table for each byte */
size_t i;
for(i = 0; i < len; ++i) {
crc = crc32_for_byte((Uint8)crc ^ ((const Uint8*)data)[i]) ^ crc >> 8;
}
return crc;
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -110,7 +110,7 @@ int
SDL_setenv(const char *name, const char *value, int overwrite)
{
int added;
int len, i;
size_t len, i;
char **new_env;
char *new_variable;
@@ -218,7 +218,7 @@ SDL_getenv(const char *name)
char *
SDL_getenv(const char *name)
{
int len, i;
size_t len, i;
char *value;
/* Input validation */

View File

@@ -37,7 +37,7 @@
iconv() may or may not use const char ** for the inbuf param.
If we get this wrong, it's just a warning, so no big deal.
*/
#if defined(_XGP6) || defined(__APPLE__) || defined(__RISCOS__) || \
#if defined(_XGP6) || defined(__APPLE__) || defined(__RISCOS__) || defined(__FREEBSD__) || \
defined(__EMSCRIPTEN__) || \
(defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) || \
(defined(_NEWLIB_VERSION)))

View File

@@ -26,7 +26,6 @@
#include "../SDL_internal.h"
#include "SDL_stdinc.h"
#include "SDL_assert.h"
#if defined(HAVE_QSORT)
void

View File

@@ -260,6 +260,30 @@ SDL_floorf(float x)
#endif
}
double
SDL_trunc(double x)
{
#if defined(HAVE_TRUNC)
return trunc(x);
#else
if (x >= 0.0f) {
return SDL_floor(x);
} else {
return SDL_ceil(x);
}
#endif
}
float
SDL_truncf(float x)
{
#if defined(HAVE_TRUNCF)
return truncf(x);
#else
return (float)SDL_trunc((double)x);
#endif
}
double
SDL_fmod(double x, double y)
{
@@ -462,42 +486,28 @@ int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) :
__declspec(selectany) int _fltused = 1;
#endif
/* The optimizer on Visual Studio 2005 and later generates memcpy() calls */
#if (_MSC_VER >= 1400) && defined(_WIN64) && !defined(_DEBUG) && !(_MSC_VER >= 1900 && defined(_MT))
#include <intrin.h>
/* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls */
#if _MSC_VER >= 1400
extern void *memcpy(void* dst, const void* src, size_t len);
#pragma intrinsic(memcpy)
#pragma function(memcpy)
void * memcpy ( void * destination, const void * source, size_t num )
void *
memcpy(void *dst, const void *src, size_t len)
{
const Uint8 *src = (const Uint8 *)source;
Uint8 *dst = (Uint8 *)destination;
size_t i;
/* All WIN64 architectures have SSE, right? */
if (!((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) {
__m128 values[4];
for (i = num / 64; i--;) {
_mm_prefetch(src, _MM_HINT_NTA);
values[0] = *(__m128 *) (src + 0);
values[1] = *(__m128 *) (src + 16);
values[2] = *(__m128 *) (src + 32);
values[3] = *(__m128 *) (src + 48);
_mm_stream_ps((float *) (dst + 0), values[0]);
_mm_stream_ps((float *) (dst + 16), values[1]);
_mm_stream_ps((float *) (dst + 32), values[2]);
_mm_stream_ps((float *) (dst + 48), values[3]);
src += 64;
dst += 64;
}
num &= 63;
}
while (num--) {
*dst++ = *src++;
}
return destination;
return SDL_memcpy(dst, src, len);
}
#endif /* _MSC_VER == 1600 && defined(_WIN64) && !defined(_DEBUG) */
extern void *memset(void* dst, int c, size_t len);
#pragma intrinsic(memset)
#pragma function(memset)
void *
memset(void *dst, int c, size_t len)
{
return SDL_memset(dst, c, len);
}
#endif /* _MSC_VER >= 1400 */
#ifdef _M_IX86

View File

@@ -516,16 +516,100 @@ SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
#if defined(HAVE_WCSNCMP)
return wcsncmp(str1, str2, maxlen);
#else
while (*str1 && *str2) {
while (*str1 && *str2 && maxlen) {
if (*str1 != *str2)
break;
++str1;
++str2;
--maxlen;
}
return (int)(*str1 - *str2);
if (!maxlen) {
return 0;
}
return (int) (*str1 - *str2);
#endif /* HAVE_WCSNCMP */
}
int
SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2)
{
#if defined(HAVE_WCSCASECMP)
return wcscasecmp(str1, str2);
#elif defined(HAVE__WCSICMP)
return _wcsicmp(str1, str2);
#else
wchar_t a = 0;
wchar_t b = 0;
while (*str1 && *str2) {
/* FIXME: This doesn't actually support wide characters */
if (*str1 >= 0x80 || *str2 >= 0x80) {
a = *str1;
b = *str2;
} else {
a = SDL_toupper((unsigned char) *str1);
b = SDL_toupper((unsigned char) *str2);
}
if (a != b)
break;
++str1;
++str2;
}
/* FIXME: This doesn't actually support wide characters */
if (*str1 >= 0x80 || *str2 >= 0x80) {
a = *str1;
b = *str2;
} else {
a = SDL_toupper((unsigned char) *str1);
b = SDL_toupper((unsigned char) *str2);
}
return (int) ((unsigned int) a - (unsigned int) b);
#endif /* HAVE__WCSICMP */
}
int
SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
{
#if defined(HAVE_WCSNCASECMP)
return wcsncasecmp(str1, str2, maxlen);
#elif defined(HAVE__WCSNICMP)
return _wcsnicmp(str1, str2, maxlen);
#else
wchar_t a = 0;
wchar_t b = 0;
while (*str1 && *str2 && maxlen) {
/* FIXME: This doesn't actually support wide characters */
if (*str1 >= 0x80 || *str2 >= 0x80) {
a = *str1;
b = *str2;
} else {
a = SDL_toupper((unsigned char) *str1);
b = SDL_toupper((unsigned char) *str2);
}
if (a != b)
break;
++str1;
++str2;
--maxlen;
}
if (maxlen == 0) {
return 0;
} else {
/* FIXME: This doesn't actually support wide characters */
if (*str1 >= 0x80 || *str2 >= 0x80) {
a = *str1;
b = *str2;
} else {
a = SDL_toupper((unsigned char) *str1);
b = SDL_toupper((unsigned char) *str2);
}
return (int) ((unsigned int) a - (unsigned int) b);
}
#endif /* HAVE__WCSNICMP */
}
size_t
SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
{
@@ -1815,10 +1899,15 @@ SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt,
{
/* In practice this is used on Windows for WCHAR strings */
wchar_t *wide_arg = va_arg(ap, wchar_t *);
char *arg = SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(wide_arg), (SDL_wcslen(wide_arg)+1)*sizeof(*wide_arg));
info.pad_zeroes = SDL_FALSE;
len = SDL_PrintString(text, left, &info, arg);
SDL_free(arg);
if (wide_arg) {
char *arg = SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(wide_arg), (SDL_wcslen(wide_arg)+1)*sizeof(*wide_arg));
info.pad_zeroes = SDL_FALSE;
len = SDL_PrintString(text, left, &info, arg);
SDL_free(arg);
} else {
info.pad_zeroes = SDL_FALSE;
len = SDL_PrintString(text, left, &info, NULL);
}
done = SDL_TRUE;
}
break;