Commit graph

121 commits

Author SHA1 Message Date
Yuri Kunde Schlesner
9483e21015 Align pointer in SDL_memset before doing Uint32 loop
Some more recent compilers emit SSE aligned store instructions for the loop,
causing crashes if the destination buffer isn't aligned on a 32-bit boundary.
This would also crash on platforms like ARM that require aligned stores.

This fixes a crash inside SDL_FillRect that happens with the official x64 mingw
build.

--HG--
extra : rebase_source : afd0f856fd814e7345bd0c7d20ddac3ba0422813
2014-05-10 21:48:46 -03:00
Sam Lantinga
2e37831d3e Temporary fix for bug 2494 - Crashes due to the non thread-safe SDL_malloc/SDL_free on Windows
We'll define USE_LOCKS as a temporary fix until an alternative like ptmalloc, jemalloc, or nedmalloc can be investigated.
http://www.malloc.de/en/
http://www.canonware.com/jemalloc/
http://www.nedprod.com/programs/portable/nedmalloc/

SDL allocates memory very infrequently, so this is probably a decent fix for a while.
2014-05-10 11:27:43 -07:00
Andreas Schiffler
721340f510 Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite 2014-03-19 21:39:55 -07:00
Sam Lantinga
a7d2ebb8d6 Integrated David Ludwig's support for Windows RT 2014-03-09 11:36:47 -07:00
Sam Lantinga
4042f4a71d Thou shalt not use more than 4k local variables in this code. 2014-02-22 10:40:12 -08:00
Sam Lantinga
d7940a513e Fixed bug 2374 - Update copyright for 2014...
Is it that time already??
2014-02-02 00:53:27 -08:00
David Ludwig
ebfac58560 WinRT: merged with latest SDL 2.x/HG code
SDL 2.x recently accepted patches to enable OpenGL ES 2 support via Google's ANGLE library.  The thought is to try to eventually merge SDL/WinRT's OpenGL code with SDL-official's.
2013-11-28 22:09:21 -05:00
Sam Lantinga
ef7498a5c3 Fixed bug 2274 - SDL_ceil is incorrectly implemented when HAVE_LIBC is not defined
Ghassan Al-Mashareqa

The SDL_ceil function is implemented incorrectly when HAVE_CEIL is not defined (HAVE_LIBC not defined).

The following code:

    double val = SDL_ceil(2.3);
    printf("%g", val);

prints "2.0", as STD_ceil is defined as:

    double
    SDL_ceil(double x)
    {
    #ifdef HAVE_CEIL
        return ceil(x);
    #else
        return (double)(int)((x)+0.5);
    #endif /* HAVE_CEIL */
    }

This functions is used in the SDL_BuildAudioResampleCVT function of the audio subsystem (SDL_audiocvt.c), and causes a bug in that function.
2013-11-27 00:29:46 -08:00
Ryan C. Gordon
82edee6971 Make internal SDL sources include SDL_internal.h instead of SDL_config.h
The new header will include SDL_config.h, but allows for other global stuff.

--HG--
extra : rebase_source : ddf4a4c0dc2c554b98c82700798f343cd91b16e3
2013-11-24 23:56:17 -05:00
Ryan C. Gordon
1e82be1804 Patched stdlib changes to compile on Windows.
--HG--
extra : rebase_source : a782472e239edc31e70be994953d4da5a55edd95
2013-12-09 13:30:35 -05:00
Ryan C. Gordon
3003efb88d Added SDL_vsscanf().
--HG--
extra : rebase_source : 088d093790a7ed95d73c307523587e95c8356f4b
2013-11-24 23:35:38 -05:00
Sam Lantinga
f8e51377ab Fixed bug 2050 - Obvious bugs in SDL_ltoa and SDL_lltoa
pjz

SDL_ltoa(-2147483648,s,10) only returns "-" because there is a bug in the code:

    if ( value < 0 ) {
        *bufp++ = '-';
        value = -value;
    }

but -(-2147483648) is still -2147483648 (0x80000000) as signed int (or long), so the following loop doesn't run at all. Similar bug are also in SDL_lltoa.

BTW, there is no sanity check for radix.
2013-12-11 21:17:24 -08:00
Ryan C. Gordon
924207a299 Hook up SDL_acos and SDL_asin properly. 2013-12-09 15:17:20 -05:00
David Ludwig
59df93166d WinRT: merged with SDL 2.0.1 codebase 2013-10-27 21:26:46 -04:00
Sam Lantinga
a999af88e9 Fixed building using MinGW
Our SDL_windows.h needed to be included before anything else so UNICODE is defined.
2013-10-17 23:02:29 -07:00
David Ludwig
ef0a40b704 WinRT: build fixes and additional WinRT-related integrations with SDL 2.0.0 2013-08-13 20:09:52 -04:00
Sam Lantinga
a7954b42d0 Fixed SDL printf output for 0x%.8x 2013-07-23 12:44:14 -07:00
Ryan C. Gordon
30b6bedb57 Fixed some compiler warnings that Visual Studio reported. 2013-07-20 19:51:51 -04:00
Philipp Wiesemann
e96e39d53b Removed not needed variable and work in standard library.
Found by Cppcheck (that variable's value was never used).
2013-07-20 21:35:26 +02:00
Sam Lantinga
e74da38529 Fixed bug 2082 - SDL stdlib implementation does not force upper case for %X format specifier
norfanin

When SDL_vsnprintf handles the %x format specifier, a boolean is set to signal forced lower case. It also should be able to signal forced upper case for the %X specifier. A boolean is not sufficient anymore. The attached patch adds an enum for the three cases: lower, upper and no change.
2013-09-05 06:59:34 -07:00
Sam Lantinga
08dfaaa2e6 Christoph Mallon: Remove pointless if (x) before SDL_free(x) 2013-08-29 08:29:21 -07:00
Philipp Wiesemann
6aa8bc33bd Fixed SDL's implementation of isspace() to check form feed and vertical tab. 2013-07-06 16:05:09 +02:00
Sam Lantinga
8ad9316ca3 Fixed mingw32 build 2013-07-06 00:15:01 -07:00
Sam Lantinga
ed07a40c62 Fixed build errors on Mac OS X 2013-07-06 00:06:44 -07:00
Sam Lantinga
cfd541e89c Removed the inline functions from SDL_stdinc.h
Having the SDL functions inline is causing build issues, and in the case of malloc(), etc. causing malloc/free mismatches, if the application build environment differs from the SDL build environment.

In the interest of safety and consistency, the functions will always be in the SDL library and will only be redirected to the C library there, if they are available.

See the following threads on the SDL mailing list for the gruesome details:
* SDL_stdinc.h inlines problematic when application not compiled in exact same feature environment
* Error compiling program against SDL2 with -std=c++11 g++ flag
2013-07-05 23:57:19 -07:00
Sam Lantinga
f004771cf2 Fixed detection of overlong sequences (thanks Tommy!) 2013-07-05 21:25:32 -07:00
Sam Lantinga
b3ec1b660b Fixed crash with movaps instruction in SDL_memcpy(), due to unaligned Uint32* cast and -O3 vectorization optimizations with gcc 4.9.0 2013-05-27 16:18:11 -07:00
Sam Lantinga
f423813732 Fixed Windows build 2013-05-24 03:29:31 -07:00
Sam Lantinga
03210bff7e Added the beginning of automated tests for the standard C library routines.
Implemented more SDL_snprintf format specifiers.
2013-05-24 03:23:21 -07:00
Sam Lantinga
0cb6385637 File style cleanup for the SDL 2.0 release 2013-05-18 14:17:52 -07:00
Sam Lantinga
128b8ca895 Fixed bug 1846 - _allmul implementation in SDL_stdlib.c doesn't clean up the stack
Colin Barrett

I see this manifest itself (VS2012 x86) as:

"Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.  This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."

in the first call to SDL_GetTicks in my application. The disassembly at the problem line is:

        hires_now.QuadPart *= 1000;
00AD0792  push        0
00AD0794  push        3E8h
00AD0799  mov         eax,dword ptr [ebp-10h]
00AD079C  push        eax
00AD079D  mov         ecx,dword ptr [hires_now]
00AD07A0  push        ecx
00AD07A1  call        _allmul (0AE7D40h)
00AD07A6  mov         dword ptr [hires_now],eax
00AD07A9  mov         dword ptr [ebp-10h],edx

Apparently _allmul should be popping the stack but isn't (other similar functions in SDL_stdlib.c - _alldiv and whatnot - DO pop the stack).

A 'ret 10h' at the end of _allmul appears to do the trick
2013-05-16 00:43:22 -07:00
Ryan C. Gordon
280675858c Fixed another infinite recursion accident in stdlib. 2013-04-05 16:34:59 -04:00
Ryan C. Gordon
6bcac2ad67 Fixed infinite recursion (thanks, Rainer!). 2013-04-03 10:36:15 -04:00
Ryan C. Gordon
7e934f8f75 Improvements to stdlib.
All SDL_* functions are always available as real symbols, so you can always
link against them as a stable ABI. By default, however, all the things that
might have dithered down to macros in your application are now force-inlined,
to give you the same effect as before and theoretically better performance,
but still solve the classic macro problems.

Elsewhere, we provide real functions for these things that simply wrap the
inline functions, in case one needs to have a real function available.

Also: this exposed bugs: SDL_abs() does something different if you had the
macro vs the libc function, SDL_memcpy() returns a void* in the function
but not the macro, etc.
2013-03-15 01:01:20 -04:00
Sam Lantinga
95dcfa4c28 Happy New Year! 2013-02-15 08:47:44 -08:00
Sam Lantinga
acdd875c64 Fixed bug in SDL_strcasecmp() with strings of different sizes 2012-12-22 16:52:33 -08:00
Sam Lantinga
75cb962de6 It turns out that UCS2 and UCS4 are defined as big-endian encodings 2012-10-28 13:03:45 -07:00
Sam Lantinga
f380ecb137 Removed executable bit from source files 2012-09-27 14:35:28 -07:00
Ryan C. Gordon
5c732d6324 Removed Windows CE support from SDL 2.0.
It's a long-dead platform, and we don't have any way to build for, test, or
maintain it, so there's no sense in doing acrobatics to support it.

If you need Windows CE support, use SDL 1.2. If you need Windows Phone support,
send SDL 2.0 patches for the newer Windows Mobile platform.
2012-09-15 10:59:39 -04:00
Sam Lantinga
6590f3daa3 Fixed bug 1540: SDL 2.0 won't link on Visual Studio 2012 RC for x64
Thanks to Marek Pokorny for tracking this down and providing a fix.
2012-07-11 08:51:16 -04:00
Ryan C. Gordon
df8784cd61 Replaced some assert macros with SDL_assert. 2012-02-07 02:11:15 -05:00
Sam Lantinga
028e5dcdbd Happy New Year! 2011-12-31 09:28:07 -05:00
Sam Lantinga
ad2a21d404 Lots of fixes importing SDL source wholesale into a new iOS project
--HG--
rename : src/libm/math.h => src/libm/math_libm.h
2011-10-31 05:56:58 -04:00
Sam Lantinga
ee56d1a748 Added SDL_GetScancodeFromName() and SDL_GetKeyFromName() 2011-10-24 21:34:54 -04:00
Ryan C. Gordon
3b667bacd5 Apple's C runtime has the non-const iconv(), too. 2011-08-22 14:25:11 -04:00
Sam Lantinga
b0660ba5ff SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
Sam Lantinga
5c01c4797c SDL 1.3 requires a 64-bit type for the platform. 2011-03-25 13:47:49 -07:00
Sam Lantinga
45d991f20d Fixed permissions for C source files 2011-03-11 11:52:41 -08:00
Sam Lantinga
5f55b90cbd Fixed linking x64 with Visual Studio 2010. 2011-03-08 22:48:21 -08:00
Sam Lantinga
ac662b8421 Fixed compiler warning 2011-03-06 21:17:44 -08:00