mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-03 20:40:35 +00:00
Updates the SDL library to the latest standard bugfix release
This commit is contained in:
parent
cb766f2878
commit
083d2175ea
1280 changed files with 343926 additions and 179615 deletions
57
Engine/lib/sdl/src/stdlib/SDL_crc16.c
Normal file
57
Engine/lib/sdl/src/stdlib/SDL_crc16.c
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 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
|
||||
|
||||
This algorithm is compatible with the 16-bit CRC described here:
|
||||
https://www.lammertbies.nl/comm/info/crc-calculation
|
||||
*/
|
||||
/* NOTE: DO NOT CHANGE THIS ALGORITHM
|
||||
There is code that relies on this in the joystick code
|
||||
*/
|
||||
|
||||
static Uint16 crc16_for_byte(Uint8 r)
|
||||
{
|
||||
Uint16 crc = 0;
|
||||
int i;
|
||||
for (i = 0; i < 8; ++i) {
|
||||
crc = ((crc ^ r) & 1 ? 0xA001 : 0) ^ crc >> 1;
|
||||
r >>= 1;
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
Uint16 SDL_crc16(Uint16 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 = crc16_for_byte((Uint8)crc ^ ((const Uint8 *)data)[i]) ^ crc >> 8;
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 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
|
||||
|
|
@ -25,6 +25,9 @@
|
|||
|
||||
/* Public domain CRC implementation adapted from:
|
||||
http://home.thep.lu.se/~bjorn/crc/crc32_simple.c
|
||||
|
||||
This algorithm is compatible with the 32-bit CRC described here:
|
||||
https://www.lammertbies.nl/comm/info/crc-calculation
|
||||
*/
|
||||
/* NOTE: DO NOT CHANGE THIS ALGORITHM
|
||||
There is code that relies on this in the joystick code
|
||||
|
|
@ -33,8 +36,8 @@
|
|||
static Uint32 crc32_for_byte(Uint32 r)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 8; ++i) {
|
||||
r = (r & 1? 0: (Uint32)0xEDB88320L) ^ r >> 1;
|
||||
for (i = 0; i < 8; ++i) {
|
||||
r = (r & 1 ? 0 : (Uint32)0xEDB88320L) ^ r >> 1;
|
||||
}
|
||||
return r ^ (Uint32)0xFF000000L;
|
||||
}
|
||||
|
|
@ -43,8 +46,8 @@ 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;
|
||||
for (i = 0; i < len; ++i) {
|
||||
crc = crc32_for_byte((Uint8)crc ^ ((const Uint8 *)data)[i]) ^ crc >> 8;
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 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
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#if defined(__WIN32__) || defined(__WINGDK__)
|
||||
#include "../core/windows/SDL_windows.h"
|
||||
#endif
|
||||
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#if defined(__WIN32__) && (!defined(HAVE_SETENV) || !defined(HAVE_GETENV))
|
||||
#if (defined(__WIN32__) || defined(__WINGDK__)) && (!defined(HAVE_SETENV) || !defined(HAVE_GETENV))
|
||||
/* Note this isn't thread-safe! */
|
||||
static char *SDL_envmem = NULL; /* Ugh, memory leak */
|
||||
static size_t SDL_envmemlen = 0;
|
||||
|
|
@ -44,28 +44,26 @@ static size_t SDL_envmemlen = 0;
|
|||
/* 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)
|
||||
int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
/* Input validation */
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return (-1);
|
||||
if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return setenv(name, value, overwrite);
|
||||
}
|
||||
#elif defined(__WIN32__)
|
||||
int
|
||||
SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
#elif defined(__WIN32__) || defined(__WINGDK__)
|
||||
int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
/* Input validation */
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return (-1);
|
||||
if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (!overwrite) {
|
||||
if (GetEnvironmentVariableA(name, NULL, 0) > 0) {
|
||||
return 0; /* asked not to overwrite existing value. */
|
||||
return 0; /* asked not to overwrite existing value. */
|
||||
}
|
||||
}
|
||||
if (!SetEnvironmentVariableA(name, *value ? value : NULL)) {
|
||||
|
|
@ -75,39 +73,37 @@ SDL_setenv(const char *name, const char *value, int overwrite)
|
|||
}
|
||||
/* We have a real environment table, but no real setenv? Fake it w/ putenv. */
|
||||
#elif (defined(HAVE_GETENV) && defined(HAVE_PUTENV) && !defined(HAVE_SETENV))
|
||||
int
|
||||
SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
size_t len;
|
||||
char *new_variable;
|
||||
|
||||
/* Input validation */
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return (-1);
|
||||
if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (getenv(name) != NULL) {
|
||||
if (overwrite) {
|
||||
unsetenv(name);
|
||||
} else {
|
||||
return 0; /* leave the existing one there. */
|
||||
return 0; /* leave the existing one there. */
|
||||
}
|
||||
}
|
||||
|
||||
/* This leaks. Sorry. Get a better OS so we don't have to do this. */
|
||||
len = SDL_strlen(name) + SDL_strlen(value) + 2;
|
||||
new_variable = (char *) SDL_malloc(len);
|
||||
if (!new_variable) {
|
||||
return (-1);
|
||||
new_variable = (char *)SDL_malloc(len);
|
||||
if (new_variable == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_snprintf(new_variable, len, "%s=%s", name, value);
|
||||
return putenv(new_variable);
|
||||
}
|
||||
#else /* roll our own */
|
||||
static char **SDL_env = (char **) 0;
|
||||
int
|
||||
SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
static char **SDL_env = (char **)0;
|
||||
int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
int added;
|
||||
size_t len, i;
|
||||
|
|
@ -115,8 +111,8 @@ SDL_setenv(const char *name, const char *value, int overwrite)
|
|||
char *new_variable;
|
||||
|
||||
/* Input validation */
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return (-1);
|
||||
if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See if it already exists */
|
||||
|
|
@ -126,9 +122,9 @@ SDL_setenv(const char *name, const char *value, int overwrite)
|
|||
|
||||
/* Allocate memory for the variable */
|
||||
len = SDL_strlen(name) + SDL_strlen(value) + 2;
|
||||
new_variable = (char *) SDL_malloc(len);
|
||||
if (!new_variable) {
|
||||
return (-1);
|
||||
new_variable = (char *)SDL_malloc(len);
|
||||
if (new_variable == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_snprintf(new_variable, len, "%s=%s", name, value);
|
||||
|
|
@ -160,20 +156,19 @@ SDL_setenv(const char *name, const char *value, int overwrite)
|
|||
if (new_env) {
|
||||
SDL_env = new_env;
|
||||
SDL_env[i++] = new_variable;
|
||||
SDL_env[i++] = (char *) 0;
|
||||
SDL_env[i++] = (char *)0;
|
||||
added = 1;
|
||||
} else {
|
||||
SDL_free(new_variable);
|
||||
}
|
||||
}
|
||||
return (added ? 0 : -1);
|
||||
return added ? 0 : -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Retrieve a variable named "name" from the environment */
|
||||
#if defined(HAVE_GETENV)
|
||||
char *
|
||||
SDL_getenv(const char *name)
|
||||
char *SDL_getenv(const char *name)
|
||||
{
|
||||
#if defined(__ANDROID__)
|
||||
/* Make sure variables from the application manifest are available */
|
||||
|
|
@ -181,55 +176,53 @@ SDL_getenv(const char *name)
|
|||
#endif
|
||||
|
||||
/* Input validation */
|
||||
if (!name || *name == '\0') {
|
||||
if (name == NULL || *name == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return getenv(name);
|
||||
}
|
||||
#elif defined(__WIN32__)
|
||||
char *
|
||||
SDL_getenv(const char *name)
|
||||
#elif defined(__WIN32__) || defined(__WINGDK__)
|
||||
char *SDL_getenv(const char *name)
|
||||
{
|
||||
size_t bufferlen;
|
||||
|
||||
/* Input validation */
|
||||
if (!name || *name == '\0') {
|
||||
if (name == NULL || *name == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bufferlen =
|
||||
GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen);
|
||||
GetEnvironmentVariableA(name, SDL_envmem, (DWORD)SDL_envmemlen);
|
||||
if (bufferlen == 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (bufferlen > SDL_envmemlen) {
|
||||
char *newmem = (char *) SDL_realloc(SDL_envmem, bufferlen);
|
||||
char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen);
|
||||
if (newmem == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
SDL_envmem = newmem;
|
||||
SDL_envmemlen = bufferlen;
|
||||
GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen);
|
||||
GetEnvironmentVariableA(name, SDL_envmem, (DWORD)SDL_envmemlen);
|
||||
}
|
||||
return SDL_envmem;
|
||||
}
|
||||
#else
|
||||
char *
|
||||
SDL_getenv(const char *name)
|
||||
char *SDL_getenv(const char *name)
|
||||
{
|
||||
size_t len, i;
|
||||
char *value;
|
||||
|
||||
/* Input validation */
|
||||
if (!name || *name == '\0') {
|
||||
if (name == NULL || *name == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
value = (char *) 0;
|
||||
|
||||
value = (char *)0;
|
||||
if (SDL_env) {
|
||||
len = SDL_strlen(name);
|
||||
for (i = 0; SDL_env[i] && !value; ++i) {
|
||||
for (i = 0; SDL_env[i] && value == NULL; ++i) {
|
||||
if ((SDL_strncmp(SDL_env[i], name, len) == 0) &&
|
||||
(SDL_env[i][len] == '=')) {
|
||||
value = &SDL_env[i][len + 1];
|
||||
|
|
@ -240,12 +233,10 @@ SDL_getenv(const char *name)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TEST_MAIN
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *value;
|
||||
|
||||
|
|
@ -308,7 +299,7 @@ main(int argc, char *argv[])
|
|||
} else {
|
||||
printf("failed\n");
|
||||
}
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif /* TEST_MAIN */
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
719
Engine/lib/sdl/src/stdlib/SDL_mslibc.c
Normal file
719
Engine/lib/sdl/src/stdlib/SDL_mslibc.c
Normal file
|
|
@ -0,0 +1,719 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 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.
|
||||
*/
|
||||
|
||||
#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
|
||||
#define SDL_DISABLE_ANALYZE_MACROS 1
|
||||
#endif
|
||||
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
/* This file contains SDL replacements for functions in the C library */
|
||||
|
||||
#if !defined(HAVE_LIBC) && !defined(SDL_STATIC_LIB)
|
||||
|
||||
/* These are some C runtime intrinsics that need to be defined */
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
#ifndef __FLTUSED__
|
||||
#define __FLTUSED__
|
||||
__declspec(selectany) int _fltused = 1;
|
||||
#endif
|
||||
|
||||
/* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls.
|
||||
Always provide it for the SDL2 DLL, but skip it when building static lib w/ static runtime. */
|
||||
#if (_MSC_VER >= 1400) && (!defined(_MT) || defined(DLL_EXPORT))
|
||||
/* NOLINTNEXTLINE(readability-redundant-declaration) */
|
||||
extern void *memcpy(void *dst, const void *src, size_t len);
|
||||
#pragma intrinsic(memcpy)
|
||||
|
||||
#if !defined(__clang__)
|
||||
#pragma function(memcpy)
|
||||
#endif
|
||||
/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */
|
||||
void *memcpy(void *dst, const void *src, size_t len)
|
||||
{
|
||||
return SDL_memcpy(dst, src, len);
|
||||
}
|
||||
|
||||
/* NOLINTNEXTLINE(readability-redundant-declaration) */
|
||||
extern void *memset(void *dst, int c, size_t len);
|
||||
#pragma intrinsic(memset)
|
||||
|
||||
#if !defined(__clang__)
|
||||
#pragma function(memset)
|
||||
#endif
|
||||
/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */
|
||||
void *memset(void *dst, int c, size_t len)
|
||||
{
|
||||
return SDL_memset(dst, c, len);
|
||||
}
|
||||
#endif /* (_MSC_VER >= 1400) && (!defined(_MT) || defined(DLL_EXPORT)) */
|
||||
|
||||
#ifdef _M_IX86
|
||||
|
||||
/* Float to long */
|
||||
void __declspec(naked) _ftol()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
sub esp,20h
|
||||
and esp,0FFFFFFF0h
|
||||
fld st(0)
|
||||
fst dword ptr [esp+18h]
|
||||
fistp qword ptr [esp+10h]
|
||||
fild qword ptr [esp+10h]
|
||||
mov edx,dword ptr [esp+18h]
|
||||
mov eax,dword ptr [esp+10h]
|
||||
test eax,eax
|
||||
je integer_QnaN_or_zero
|
||||
arg_is_not_integer_QnaN:
|
||||
fsubp st(1),st
|
||||
test edx,edx
|
||||
jns positive
|
||||
fstp dword ptr [esp]
|
||||
mov ecx,dword ptr [esp]
|
||||
xor ecx,80000000h
|
||||
add ecx,7FFFFFFFh
|
||||
adc eax,0
|
||||
mov edx,dword ptr [esp+14h]
|
||||
adc edx,0
|
||||
jmp localexit
|
||||
positive:
|
||||
fstp dword ptr [esp]
|
||||
mov ecx,dword ptr [esp]
|
||||
add ecx,7FFFFFFFh
|
||||
sbb eax,0
|
||||
mov edx,dword ptr [esp+14h]
|
||||
sbb edx,0
|
||||
jmp localexit
|
||||
integer_QnaN_or_zero:
|
||||
mov edx,dword ptr [esp+14h]
|
||||
test edx,7FFFFFFFh
|
||||
jne arg_is_not_integer_QnaN
|
||||
fstp dword ptr [esp+18h]
|
||||
fstp dword ptr [esp+18h]
|
||||
localexit:
|
||||
leave
|
||||
ret
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void _ftol2_sse()
|
||||
{
|
||||
_ftol();
|
||||
}
|
||||
|
||||
void _ftol2()
|
||||
{
|
||||
_ftol();
|
||||
}
|
||||
|
||||
/* 64-bit math operators for 32-bit systems */
|
||||
void __declspec(naked) _allmul()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
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
|
||||
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
|
||||
ret 10h
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void __declspec(naked) _alldiv()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
xor edi,edi
|
||||
mov eax,dword ptr [esp+14h]
|
||||
or eax,eax
|
||||
jge L1
|
||||
inc edi
|
||||
mov edx,dword ptr [esp+10h]
|
||||
neg eax
|
||||
neg edx
|
||||
sbb eax,0
|
||||
mov dword ptr [esp+14h],eax
|
||||
mov dword ptr [esp+10h],edx
|
||||
L1:
|
||||
mov eax,dword ptr [esp+1Ch]
|
||||
or eax,eax
|
||||
jge L2
|
||||
inc edi
|
||||
mov edx,dword ptr [esp+18h]
|
||||
neg eax
|
||||
neg edx
|
||||
sbb eax,0
|
||||
mov dword ptr [esp+1Ch],eax
|
||||
mov dword ptr [esp+18h],edx
|
||||
L2:
|
||||
or eax,eax
|
||||
jne L3
|
||||
mov ecx,dword ptr [esp+18h]
|
||||
mov eax,dword ptr [esp+14h]
|
||||
xor edx,edx
|
||||
div ecx
|
||||
mov ebx,eax
|
||||
mov eax,dword ptr [esp+10h]
|
||||
div ecx
|
||||
mov edx,ebx
|
||||
jmp L4
|
||||
L3:
|
||||
mov ebx,eax
|
||||
mov ecx,dword ptr [esp+18h]
|
||||
mov edx,dword ptr [esp+14h]
|
||||
mov eax,dword ptr [esp+10h]
|
||||
L5:
|
||||
shr ebx,1
|
||||
rcr ecx,1
|
||||
shr edx,1
|
||||
rcr eax,1
|
||||
or ebx,ebx
|
||||
jne L5
|
||||
div ecx
|
||||
mov esi,eax
|
||||
mul dword ptr [esp+1Ch]
|
||||
mov ecx,eax
|
||||
mov eax,dword ptr [esp+18h]
|
||||
mul esi
|
||||
add edx,ecx
|
||||
jb L6
|
||||
cmp edx,dword ptr [esp+14h]
|
||||
ja L6
|
||||
jb L7
|
||||
cmp eax,dword ptr [esp+10h]
|
||||
jbe L7
|
||||
L6:
|
||||
dec esi
|
||||
L7:
|
||||
xor edx,edx
|
||||
mov eax,esi
|
||||
L4:
|
||||
dec edi
|
||||
jne L8
|
||||
neg edx
|
||||
neg eax
|
||||
sbb edx,0
|
||||
L8:
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
ret 10h
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void __declspec(naked) _aulldiv()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
push ebx
|
||||
push esi
|
||||
mov eax,dword ptr [esp+18h]
|
||||
or eax,eax
|
||||
jne L1
|
||||
mov ecx,dword ptr [esp+14h]
|
||||
mov eax,dword ptr [esp+10h]
|
||||
xor edx,edx
|
||||
div ecx
|
||||
mov ebx,eax
|
||||
mov eax,dword ptr [esp+0Ch]
|
||||
div ecx
|
||||
mov edx,ebx
|
||||
jmp L2
|
||||
L1:
|
||||
mov ecx,eax
|
||||
mov ebx,dword ptr [esp+14h]
|
||||
mov edx,dword ptr [esp+10h]
|
||||
mov eax,dword ptr [esp+0Ch]
|
||||
L3:
|
||||
shr ecx,1
|
||||
rcr ebx,1
|
||||
shr edx,1
|
||||
rcr eax,1
|
||||
or ecx,ecx
|
||||
jne L3
|
||||
div ebx
|
||||
mov esi,eax
|
||||
mul dword ptr [esp+18h]
|
||||
mov ecx,eax
|
||||
mov eax,dword ptr [esp+14h]
|
||||
mul esi
|
||||
add edx,ecx
|
||||
jb L4
|
||||
cmp edx,dword ptr [esp+10h]
|
||||
ja L4
|
||||
jb L5
|
||||
cmp eax,dword ptr [esp+0Ch]
|
||||
jbe L5
|
||||
L4:
|
||||
dec esi
|
||||
L5:
|
||||
xor edx,edx
|
||||
mov eax,esi
|
||||
L2:
|
||||
pop esi
|
||||
pop ebx
|
||||
ret 10h
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void __declspec(naked) _allrem()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
push ebx
|
||||
push edi
|
||||
xor edi,edi
|
||||
mov eax,dword ptr [esp+10h]
|
||||
or eax,eax
|
||||
jge L1
|
||||
inc edi
|
||||
mov edx,dword ptr [esp+0Ch]
|
||||
neg eax
|
||||
neg edx
|
||||
sbb eax,0
|
||||
mov dword ptr [esp+10h],eax
|
||||
mov dword ptr [esp+0Ch],edx
|
||||
L1:
|
||||
mov eax,dword ptr [esp+18h]
|
||||
or eax,eax
|
||||
jge L2
|
||||
mov edx,dword ptr [esp+14h]
|
||||
neg eax
|
||||
neg edx
|
||||
sbb eax,0
|
||||
mov dword ptr [esp+18h],eax
|
||||
mov dword ptr [esp+14h],edx
|
||||
L2:
|
||||
or eax,eax
|
||||
jne L3
|
||||
mov ecx,dword ptr [esp+14h]
|
||||
mov eax,dword ptr [esp+10h]
|
||||
xor edx,edx
|
||||
div ecx
|
||||
mov eax,dword ptr [esp+0Ch]
|
||||
div ecx
|
||||
mov eax,edx
|
||||
xor edx,edx
|
||||
dec edi
|
||||
jns L4
|
||||
jmp L8
|
||||
L3:
|
||||
mov ebx,eax
|
||||
mov ecx,dword ptr [esp+14h]
|
||||
mov edx,dword ptr [esp+10h]
|
||||
mov eax,dword ptr [esp+0Ch]
|
||||
L5:
|
||||
shr ebx,1
|
||||
rcr ecx,1
|
||||
shr edx,1
|
||||
rcr eax,1
|
||||
or ebx,ebx
|
||||
jne L5
|
||||
div ecx
|
||||
mov ecx,eax
|
||||
mul dword ptr [esp+18h]
|
||||
xchg eax,ecx
|
||||
mul dword ptr [esp+14h]
|
||||
add edx,ecx
|
||||
jb L6
|
||||
cmp edx,dword ptr [esp+10h]
|
||||
ja L6
|
||||
jb L7
|
||||
cmp eax,dword ptr [esp+0Ch]
|
||||
jbe L7
|
||||
L6:
|
||||
sub eax,dword ptr [esp+14h]
|
||||
sbb edx,dword ptr [esp+18h]
|
||||
L7:
|
||||
sub eax,dword ptr [esp+0Ch]
|
||||
sbb edx,dword ptr [esp+10h]
|
||||
dec edi
|
||||
jns L8
|
||||
L4:
|
||||
neg edx
|
||||
neg eax
|
||||
sbb edx,0
|
||||
L8:
|
||||
pop edi
|
||||
pop ebx
|
||||
ret 10h
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void __declspec(naked) _aullrem()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
push ebx
|
||||
mov eax,dword ptr [esp+14h]
|
||||
or eax,eax
|
||||
jne L1
|
||||
mov ecx,dword ptr [esp+10h]
|
||||
mov eax,dword ptr [esp+0Ch]
|
||||
xor edx,edx
|
||||
div ecx
|
||||
mov eax,dword ptr [esp+8]
|
||||
div ecx
|
||||
mov eax,edx
|
||||
xor edx,edx
|
||||
jmp L2
|
||||
L1:
|
||||
mov ecx,eax
|
||||
mov ebx,dword ptr [esp+10h]
|
||||
mov edx,dword ptr [esp+0Ch]
|
||||
mov eax,dword ptr [esp+8]
|
||||
L3:
|
||||
shr ecx,1
|
||||
rcr ebx,1
|
||||
shr edx,1
|
||||
rcr eax,1
|
||||
or ecx,ecx
|
||||
jne L3
|
||||
div ebx
|
||||
mov ecx,eax
|
||||
mul dword ptr [esp+14h]
|
||||
xchg eax,ecx
|
||||
mul dword ptr [esp+10h]
|
||||
add edx,ecx
|
||||
jb L4
|
||||
cmp edx,dword ptr [esp+0Ch]
|
||||
ja L4
|
||||
jb L5
|
||||
cmp eax,dword ptr [esp+8]
|
||||
jbe L5
|
||||
L4:
|
||||
sub eax,dword ptr [esp+10h]
|
||||
sbb edx,dword ptr [esp+14h]
|
||||
L5:
|
||||
sub eax,dword ptr [esp+8]
|
||||
sbb edx,dword ptr [esp+0Ch]
|
||||
neg edx
|
||||
neg eax
|
||||
sbb edx,0
|
||||
L2:
|
||||
pop ebx
|
||||
ret 10h
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void __declspec(naked) _alldvrm()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
push edi
|
||||
push esi
|
||||
push ebp
|
||||
xor edi,edi
|
||||
xor ebp,ebp
|
||||
mov eax,dword ptr [esp+14h]
|
||||
or eax,eax
|
||||
jge L1
|
||||
inc edi
|
||||
inc ebp
|
||||
mov edx,dword ptr [esp+10h]
|
||||
neg eax
|
||||
neg edx
|
||||
sbb eax,0
|
||||
mov dword ptr [esp+14h],eax
|
||||
mov dword ptr [esp+10h],edx
|
||||
L1:
|
||||
mov eax,dword ptr [esp+1Ch]
|
||||
or eax,eax
|
||||
jge L2
|
||||
inc edi
|
||||
mov edx,dword ptr [esp+18h]
|
||||
neg eax
|
||||
neg edx
|
||||
sbb eax,0
|
||||
mov dword ptr [esp+1Ch],eax
|
||||
mov dword ptr [esp+18h],edx
|
||||
L2:
|
||||
or eax,eax
|
||||
jne L3
|
||||
mov ecx,dword ptr [esp+18h]
|
||||
mov eax,dword ptr [esp+14h]
|
||||
xor edx,edx
|
||||
div ecx
|
||||
mov ebx,eax
|
||||
mov eax,dword ptr [esp+10h]
|
||||
div ecx
|
||||
mov esi,eax
|
||||
mov eax,ebx
|
||||
mul dword ptr [esp+18h]
|
||||
mov ecx,eax
|
||||
mov eax,esi
|
||||
mul dword ptr [esp+18h]
|
||||
add edx,ecx
|
||||
jmp L4
|
||||
L3:
|
||||
mov ebx,eax
|
||||
mov ecx,dword ptr [esp+18h]
|
||||
mov edx,dword ptr [esp+14h]
|
||||
mov eax,dword ptr [esp+10h]
|
||||
L5:
|
||||
shr ebx,1
|
||||
rcr ecx,1
|
||||
shr edx,1
|
||||
rcr eax,1
|
||||
or ebx,ebx
|
||||
jne L5
|
||||
div ecx
|
||||
mov esi,eax
|
||||
mul dword ptr [esp+1Ch]
|
||||
mov ecx,eax
|
||||
mov eax,dword ptr [esp+18h]
|
||||
mul esi
|
||||
add edx,ecx
|
||||
jb L6
|
||||
cmp edx,dword ptr [esp+14h]
|
||||
ja L6
|
||||
jb L7
|
||||
cmp eax,dword ptr [esp+10h]
|
||||
jbe L7
|
||||
L6:
|
||||
dec esi
|
||||
sub eax,dword ptr [esp+18h]
|
||||
sbb edx,dword ptr [esp+1Ch]
|
||||
L7:
|
||||
xor ebx,ebx
|
||||
L4:
|
||||
sub eax,dword ptr [esp+10h]
|
||||
sbb edx,dword ptr [esp+14h]
|
||||
dec ebp
|
||||
jns L9
|
||||
neg edx
|
||||
neg eax
|
||||
sbb edx,0
|
||||
L9:
|
||||
mov ecx,edx
|
||||
mov edx,ebx
|
||||
mov ebx,ecx
|
||||
mov ecx,eax
|
||||
mov eax,esi
|
||||
dec edi
|
||||
jne L8
|
||||
neg edx
|
||||
neg eax
|
||||
sbb edx,0
|
||||
L8:
|
||||
pop ebp
|
||||
pop esi
|
||||
pop edi
|
||||
ret 10h
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void __declspec(naked) _aulldvrm()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
push esi
|
||||
mov eax,dword ptr [esp+14h]
|
||||
or eax,eax
|
||||
jne L1
|
||||
mov ecx,dword ptr [esp+10h]
|
||||
mov eax,dword ptr [esp+0Ch]
|
||||
xor edx,edx
|
||||
div ecx
|
||||
mov ebx,eax
|
||||
mov eax,dword ptr [esp+8]
|
||||
div ecx
|
||||
mov esi,eax
|
||||
mov eax,ebx
|
||||
mul dword ptr [esp+10h]
|
||||
mov ecx,eax
|
||||
mov eax,esi
|
||||
mul dword ptr [esp+10h]
|
||||
add edx,ecx
|
||||
jmp L2
|
||||
L1:
|
||||
mov ecx,eax
|
||||
mov ebx,dword ptr [esp+10h]
|
||||
mov edx,dword ptr [esp+0Ch]
|
||||
mov eax,dword ptr [esp+8]
|
||||
L3:
|
||||
shr ecx,1
|
||||
rcr ebx,1
|
||||
shr edx,1
|
||||
rcr eax,1
|
||||
or ecx,ecx
|
||||
jne L3
|
||||
div ebx
|
||||
mov esi,eax
|
||||
mul dword ptr [esp+14h]
|
||||
mov ecx,eax
|
||||
mov eax,dword ptr [esp+10h]
|
||||
mul esi
|
||||
add edx,ecx
|
||||
jb L4
|
||||
cmp edx,dword ptr [esp+0Ch]
|
||||
ja L4
|
||||
jb L5
|
||||
cmp eax,dword ptr [esp+8]
|
||||
jbe L5
|
||||
L4:
|
||||
dec esi
|
||||
sub eax,dword ptr [esp+10h]
|
||||
sbb edx,dword ptr [esp+14h]
|
||||
L5:
|
||||
xor ebx,ebx
|
||||
L2:
|
||||
sub eax,dword ptr [esp+8]
|
||||
sbb edx,dword ptr [esp+0Ch]
|
||||
neg edx
|
||||
neg eax
|
||||
sbb edx,0
|
||||
mov ecx,edx
|
||||
mov edx,ebx
|
||||
mov ebx,ecx
|
||||
mov ecx,eax
|
||||
mov eax,esi
|
||||
pop esi
|
||||
ret 10h
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void __declspec(naked) _allshl()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
cmp cl,40h
|
||||
jae RETZERO
|
||||
cmp cl,20h
|
||||
jae MORE32
|
||||
shld edx,eax,cl
|
||||
shl eax,cl
|
||||
ret
|
||||
MORE32:
|
||||
mov edx,eax
|
||||
xor eax,eax
|
||||
and cl,1Fh
|
||||
shl edx,cl
|
||||
ret
|
||||
RETZERO:
|
||||
xor eax,eax
|
||||
xor edx,edx
|
||||
ret
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void __declspec(naked) _allshr()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
cmp cl,3Fh
|
||||
jae RETSIGN
|
||||
cmp cl,20h
|
||||
jae MORE32
|
||||
shrd eax,edx,cl
|
||||
sar edx,cl
|
||||
ret
|
||||
MORE32:
|
||||
mov eax,edx
|
||||
sar edx,1Fh
|
||||
and cl,1Fh
|
||||
sar eax,cl
|
||||
ret
|
||||
RETSIGN:
|
||||
sar edx,1Fh
|
||||
mov eax,edx
|
||||
ret
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void __declspec(naked) _aullshr()
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
cmp cl,40h
|
||||
jae RETZERO
|
||||
cmp cl,20h
|
||||
jae MORE32
|
||||
shrd eax,edx,cl
|
||||
shr edx,cl
|
||||
ret
|
||||
MORE32:
|
||||
mov eax,edx
|
||||
xor edx,edx
|
||||
and cl,1Fh
|
||||
shr eax,cl
|
||||
ret
|
||||
RETZERO:
|
||||
xor eax,eax
|
||||
xor edx,edx
|
||||
ret
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
#endif /* _M_IX86 */
|
||||
|
||||
#endif /* MSC_VER */
|
||||
|
||||
#if defined(__ICL)
|
||||
/* The classic Intel compiler generates calls to _intel_fast_memcpy
|
||||
* and _intel_fast_memset when building an optimized SDL library */
|
||||
void *_intel_fast_memcpy(void *dst, const void *src, size_t len)
|
||||
{
|
||||
return SDL_memcpy(dst, src, len);
|
||||
}
|
||||
void *_intel_fast_memset(void *dst, int c, size_t len)
|
||||
{
|
||||
return SDL_memset(dst, c, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !HAVE_LIBC && !SDL_STATIC_LIB */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 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
|
||||
|
|
@ -28,8 +28,7 @@
|
|||
#include "SDL_stdinc.h"
|
||||
|
||||
#if defined(HAVE_QSORT)
|
||||
void
|
||||
SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *))
|
||||
void SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *))
|
||||
{
|
||||
qsort(base, nmemb, size, compare);
|
||||
}
|
||||
|
|
@ -414,7 +413,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size,
|
|||
char *first,*last;
|
||||
char *pivot=malloc(size);
|
||||
size_t trunc=TRUNC_nonaligned*size;
|
||||
assert(pivot!=0);
|
||||
assert(pivot != NULL);
|
||||
|
||||
first=(char*)base; last=first+(nmemb-1)*size;
|
||||
|
||||
|
|
@ -445,7 +444,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size,
|
|||
char *first,*last;
|
||||
char *pivot=malloc(size);
|
||||
size_t trunc=TRUNC_aligned*size;
|
||||
assert(pivot!=0);
|
||||
assert(pivot != NULL);
|
||||
|
||||
first=(char*)base; last=first+(nmemb-1)*size;
|
||||
|
||||
|
|
@ -475,7 +474,7 @@ static void qsort_words(void *base, size_t nmemb,
|
|||
int stacktop=0;
|
||||
char *first,*last;
|
||||
char *pivot=malloc(WORD_BYTES);
|
||||
assert(pivot!=0);
|
||||
assert(pivot != NULL);
|
||||
|
||||
first=(char*)base; last=first+(nmemb-1)*WORD_BYTES;
|
||||
|
||||
|
|
@ -534,8 +533,7 @@ extern void qsortG(void *base, size_t nmemb, size_t size,
|
|||
|
||||
#endif /* HAVE_QSORT */
|
||||
|
||||
void *
|
||||
SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *))
|
||||
void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *))
|
||||
{
|
||||
#if defined(HAVE_BSEARCH)
|
||||
return bsearch(key, base, nmemb, size, compare);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 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-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 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
|
||||
|
|
@ -22,15 +22,15 @@
|
|||
/* Do our best to make sure va_copy is working */
|
||||
#if defined(__NGAGE__)
|
||||
#undef va_copy
|
||||
#define va_copy(dst, src) dst = src
|
||||
#define va_copy(dst, src) dst = src
|
||||
|
||||
#elif defined(_MSC_VER) && _MSC_VER <= 1800
|
||||
/* 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
|
||||
#define va_copy(dst, src) dst = src
|
||||
|
||||
#elif defined(__GNUC__) && (__GNUC__ < 3)
|
||||
#define va_copy(dst, src) __va_copy(dst, src)
|
||||
#define va_copy(dst, src) __va_copy(dst, src)
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue