Commit Graph

55 Commits

Author SHA1 Message Date
Sam Lantinga
48bcdfd8cc Added float versions of SDL's math functions 2017-11-04 15:34:14 -07:00
Ryan C. Gordon
f285a037e2 stdlib: An implementation of SDL_scalbn using ldexp() (thanks, Ozkan!).
Fixes Bugzilla #3767.
2017-08-29 00:36:17 -04:00
Sam Lantinga
7d193c1273 Fixed bug 3768 - provide a quick copysign() solution for watcom
Ozkan Sezer

The following patch provides a quick copysign solution for Watcom/x86
2017-08-21 16:30:24 -07:00
Sam Lantinga
d77ab77a7a Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
d516ea5ace Fixed bug 3468 - _allshr in SDL_stdlib.c is not working properly
Mark Pizzolato

On Windows with Visual Studio, when building SDL as a static library using the x86 (32bit) mode, several intrinsic operations are implemented in code in SDL_stdlib.c.

One of these, _allshr() is not properly implemented and fails for some input.  As a result, some operations on 64bit data elements (long long) don't always work.

I classified this bug as a blocker since things absolutely don't work when the affected code is invoked.  The affected code is only invoked when SDL is compiled in x86 mode on Visual Studio when building a SDL as a static library.  This build environment isn't common, and hence the bug hasn't been noticed previously.

I reopened #2537 and mentioned this problem and provided a fix.  That fix is provided again here along with test code which could be added to some of the SDL test code.  This test code verifies that the x86 intrinsic routines produce the same results as the native x64 instructions which these routines emulate under the Microsoft compiler.  The point of the tests is to make sure that Visual Studio x86 code produces the same results as Visual Studio x64 code.  Some of the arguments (or boundary conditions) may produce different results on other compiler environments, so the tests really shouldn't be run on all compilers.  The test driver only actually exercised code when the compiler defines _MSC_VER, so the driver can generically be invoked without issue.
2016-11-06 10:01:08 -08:00
Sam Lantinga
35c8dd13a1 Partial fix for bug 3092 - Statically link sdl2 with /MT for msvc
Mike Linford

I'm also having trouble statically linking SDL2 on Visual Studio 2015 with /MT. My symptom is that memcpy is being defined twice.
2016-10-17 21:47:33 -07:00
Sam Lantinga
76e94353c3 Made #if defined(X) consistent 2016-10-10 02:58:29 -07:00
Sam Lantinga
8e517b0a99 Backed out commit 4de94185790e, this causes Visual Studio build failure on buildbot 2016-01-02 11:17:06 -08:00
Sam Lantinga
04718bc407 Fixed bug 3092 - Statically link sdl2 with /MT for msvc
Martin Gerhardy

According to https://msdn.microsoft.com/de-de/library/2kzt1wy3%28v=vs.120%29.aspx when one is using /MT for msvc compilations the libcmt.lib is already linked to the binary. This lib includes the symbol that is now guarded (see attached patch) by the #ifndef _MT.
2016-01-02 10:25:53 -08:00
Sam Lantinga
255c182471 Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Ryan C. Gordon
d6d623bb68 Let's assume that if VS2005 and VS2010 do it, VS2008 probably does, too. 2015-06-07 20:00:20 -04:00
Ryan C. Gordon
2b86b61fdb VS2005 tweaks (thanks, Ozkan!).
Fixes Bugzilla #2895.

His notes:

The following trivial changes make SDL2 tree (mostly) compatible with Visual
Studio 2005:

* SDL_stdlib.c: Similar to VS2010 and newer, VS2005 also generates memcpy(),
  (it also generates memset(), see below), so propagate the #if condition to
  cover VS2005.

* SDL_pixels.c (SDL_CalculateGammaRamp): VS2005 generates a memset() call for
  gamma==0 case, so replace the if loop with SDL_memset().

* SDL_windowsvideo.h: Include msctf.h only with VS2008 and newer, otherwise
  include SDL_msctf.h

* SDL_windowskeyboard.c: Adjust the #ifdefs so that SDL_msctf.h inclusion is
  always recognized correctly.
2015-06-07 19:58:42 -04:00
Sam Lantinga
78f2198e6c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Ryan C. Gordon
bf02bb2582 Clang static analysis builds should use C runtime directly.
This is a little macro magic to use malloc() directly instead of SDL_malloc(),
 etc, so static analysis tests that know about the C runtime can function
 properly, and understand that we are dealing with heap allocations, etc.

This changed our static analysis report from 5 outstanding bugs to 30.

5x as many bugs were hidden by SDL_malloc() not being recognized as malloc()
 by the static analyzer!
2015-01-05 01:41:42 -05:00
Sam Lantinga
47f40262b5 Removed SDL_round() because the license wasn't compatible with zlib 2014-08-17 13:11:55 -07:00
Sam Lantinga
18fc7db9e2 Added SDL_round(), contributed by Benoit Pierre - thanks! 2014-08-16 23:23:15 -07:00
Sam Lantinga
b5bb6cf028 Fixed bug 2537 - _allmul in SDL_lib.c is not working properly 2014-07-27 17:44:10 -07:00
Sam Lantinga
e1683fad67 Added SDL_sqrtf(), SDL_tan(), SDL_tanf() 2014-06-07 18:20:01 -07:00
Sam Lantinga
0ae88759fb Integrated David Ludwig's support for Windows RT 2014-03-09 11:36:47 -07:00
Sam Lantinga
3f171c3331 Thou shalt not use more than 4k local variables in this code. 2014-02-22 10:40:12 -08:00
Sam Lantinga
dba255c1e5 Fixed bug 2374 - Update copyright for 2014...
Is it that time already??
2014-02-02 00:53:27 -08:00
David Ludwig
c96c4f3dc4 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
beacc372d4 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
03d5719413 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.
2013-11-24 23:56:17 -05:00
Ryan C. Gordon
fac8b02737 Hook up SDL_acos and SDL_asin properly. 2013-12-09 15:17:20 -05:00
David Ludwig
1ae5d8dea3 WinRT: build fixes and additional WinRT-related integrations with SDL 2.0.0 2013-08-13 20:09:52 -04:00
Philipp Wiesemann
1a101f252b Fixed SDL's implementation of isspace() to check form feed and vertical tab. 2013-07-06 16:05:09 +02:00
Sam Lantinga
69bede6d35 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
57fad12ba2 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
1fa34e72be 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
019c60c1e8 Happy New Year! 2013-02-15 08:47:44 -08:00
Sam Lantinga
b3d60cfcbb Removed executable bit from source files 2012-09-27 14:35:28 -07:00
Sam Lantinga
a14df76c17 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
Sam Lantinga
e256711bb9 Happy New Year! 2011-12-31 09:28:07 -05:00
Sam Lantinga
6196aa221e SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
Sam Lantinga
ac080d02da Fixed permissions for C source files 2011-03-11 11:52:41 -08:00
Sam Lantinga
f69f8b93cd Fixed linking x64 with Visual Studio 2010. 2011-03-08 22:48:21 -08:00
Sam Lantinga
a2cdcf5486 Happy 2011! :) 2011-02-11 22:37:15 -08:00
Sam Lantinga
ec39fffe84 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008 2011-01-24 15:46:11 -08:00
Sam Lantinga
d343754786 Fixed compiling with Visual Studio 2008 2010-08-29 14:22:22 -07:00
Sam Lantinga
7052036491 Fixed bug #926
Updated copyright to LGPL version 2.1 and year 2010
2010-01-24 21:10:53 +00:00
Sam Lantinga
b6ec478790 Fixed compiling on 64-bit Windows 2009-09-06 04:40:54 +00:00
Sam Lantinga
b856e71f8d Fixed issues building 64-bit Windows binary 2009-09-05 23:37:35 +00:00
Sam Lantinga
befb0f7f42 Updated copyright date 2008-12-08 00:27:32 +00:00
Sam Lantinga
6a2047e7ea Added software fallback for YUV overlay code when YUV textures aren't available. 2008-11-24 23:25:36 +00:00
Sam Lantinga
e6e45a547d Updated Visual C++ build 2008-09-15 07:34:36 +00:00
Sam Lantinga
9c4b835e49 Final merge of Google Summer of Code 2008 work...
Port SDL 1.3 to the Nintendo DS
by Darren Alton, mentored by Sam Lantinga
2008-08-27 15:10:03 +00:00
Sam Lantinga
6bc598ea61 SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head. 2006-07-10 21:04:37 +00:00
Sam Lantinga
2861771aa5 SDL_windows.h is no longer necessary 2006-02-25 22:18:25 +00:00
Sam Lantinga
190b425364 Use consistent identifiers for the various platforms we support.
Make sure every source file includes SDL_config.h, so the proper system
headers are chosen.
2006-02-21 08:46:50 +00:00