Skip to content

Commit

Permalink
Update SDL2 to 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MAN-AT-ARMS authored and zturtleman committed Mar 9, 2014
1 parent 9ec7931 commit dafed0f
Show file tree
Hide file tree
Showing 93 changed files with 7,246 additions and 608 deletions.
14 changes: 7 additions & 7 deletions Makefile
Expand Up @@ -621,19 +621,19 @@ ifeq ($(PLATFORM),mingw32)
$(LIBSDIR)/win32/libSDL2.dll.a
RENDERER_LIBS += $(LIBSDIR)/win32/libSDL2main.a \
$(LIBSDIR)/win32/libSDL2.dll.a
SDLDLL=libSDL2.dll
SDLDLL=SDL2.dll
else
CLIENT_LIBS += $(LIBSDIR)/win64/libSDL2main.a \
$(LIBSDIR)/win64/libSDL2.dll.a
RENDERER_LIBS += $(LIBSDIR)/win64/libSDL2main.a \
$(LIBSDIR)/win64/libSDL2.dll.a
SDLDLL=libSDL2.dll
CLIENT_LIBS += $(LIBSDIR)/win64/libSDL264main.a \
$(LIBSDIR)/win64/libSDL264.dll.a
RENDERER_LIBS += $(LIBSDIR)/win64/libSDL264main.a \
$(LIBSDIR)/win64/libSDL264.dll.a
SDLDLL=SDL264.dll
endif
else
CLIENT_CFLAGS += $(SDL_CFLAGS)
CLIENT_LIBS += $(SDL_LIBS)
RENDERER_LIBS += $(SDL_LIBS)
SDLDLL=libSDL2.dll
SDLDLL=SDL2.dll
endif

else # ifeq mingw32
Expand Down
29 changes: 16 additions & 13 deletions code/SDL2/include/SDL.h
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2014 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
Expand Down Expand Up @@ -32,18 +32,20 @@
*
* \section intro_sec Introduction
*
* This is the Simple DirectMedia Layer, a general API that provides low
* level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
* and 2D framebuffer across multiple platforms.
* Simple DirectMedia Layer is a cross-platform development library designed
* to provide low level access to audio, keyboard, mouse, joystick, and
* graphics hardware via OpenGL and Direct3D. It is used by video playback
* software, emulators, and popular games including Valve's award winning
* catalog and many Humble Bundle games.
*
* SDL is written in C, but works with C++ natively, and has bindings to
* several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
* Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP,
* Pike, Pliant, Python, Ruby, and Smalltalk.
* SDL officially supports Windows, Mac OS X, Linux, iOS, and Android.
* Support for other platforms may be found in the source code.
*
* This library is distributed under the zlib license, which can be
* found in the file "COPYING". This license allows you to use SDL
* freely for any purpose as long as you retain the copyright notice.
* SDL is written in C, works natively with C++, and there are bindings
* available for several other languages, including C# and Python.
*
* This library is distributed under the zlib license, which can be found
* in the file "COPYING.txt".
*
* The best way to learn how to use SDL is to check out the header files in
* the "include" subdirectory and the programs in the "test" subdirectory.
Expand Down Expand Up @@ -72,6 +74,7 @@
#include "SDL_endian.h"
#include "SDL_error.h"
#include "SDL_events.h"
#include "SDL_filesystem.h"
#include "SDL_joystick.h"
#include "SDL_gamecontroller.h"
#include "SDL_haptic.h"
Expand Down Expand Up @@ -103,7 +106,7 @@ extern "C" {
* These are the flags which may be passed to SDL_Init(). You should
* specify the subsystems which you will be using in your application.
*/
/*@{*/
/* @{ */
#define SDL_INIT_TIMER 0x00000001
#define SDL_INIT_AUDIO 0x00000010
#define SDL_INIT_VIDEO 0x00000020 /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */
Expand All @@ -116,7 +119,7 @@ extern "C" {
SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \
)
/*@}*/
/* @} */

/**
* This function initializes the subsystems specified by \c flags
Expand Down
55 changes: 51 additions & 4 deletions code/SDL2/include/SDL_assert.h
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2014 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
Expand Down Expand Up @@ -86,8 +86,14 @@ This also solves the problem of...
disable assertions.
*/

#ifdef _MSC_VER /* stupid /W4 warnings. */
#define SDL_NULL_WHILE_LOOP_CONDITION (-1 == __LINE__)
#else
#define SDL_NULL_WHILE_LOOP_CONDITION (0)
#endif

#define SDL_disabled_assert(condition) \
do { (void) sizeof ((condition)); } while (0)
do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)

typedef enum
{
Expand All @@ -114,7 +120,16 @@ typedef struct SDL_assert_data
/* Never call this directly. Use the SDL_assert* macros. */
extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
const char *,
const char *, int);
const char *, int)
#if defined(__clang__)
#if __has_feature(attribute_analyzer_noreturn)
/* this tells Clang's static analysis that we're a custom assert function,
and that the analyzer should assume the condition was always true past this
SDL_assert test. */
__attribute__((analyzer_noreturn))
#endif
#endif
;

/* the do {} while(0) avoids dangling else problems:
if (x) SDL_assert(y); else blah();
Expand All @@ -140,7 +155,7 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
} \
break; /* not retrying. */ \
} \
} while (0)
} while (SDL_NULL_WHILE_LOOP_CONDITION)

#endif /* enabled assertions support code */

Expand All @@ -165,6 +180,9 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
# error Unknown assertion level.
#endif

/* this assertion is never disabled at any level. */
#define SDL_assert_always(condition) SDL_enabled_assert(condition)


typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)(
const SDL_assert_data* data, void* userdata);
Expand Down Expand Up @@ -193,6 +211,35 @@ extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
SDL_AssertionHandler handler,
void *userdata);

/**
* \brief Get the default assertion handler.
*
* This returns the function pointer that is called by default when an
* assertion is triggered. This is an internal function provided by SDL,
* that is used for assertions when SDL_SetAssertionHandler() hasn't been
* used to provide a different function.
*
* \return The default SDL_AssertionHandler that is called when an assert triggers.
*/
extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void);

/**
* \brief Get the current assertion handler.
*
* This returns the function pointer that is called when an assertion is
* triggered. This is either the value last passed to
* SDL_SetAssertionHandler(), or if no application-specified function is
* set, is equivalent to calling SDL_GetDefaultAssertionHandler().
*
* \param puserdata Pointer to a void*, which will store the "userdata"
* pointer that was passed to SDL_SetAssertionHandler().
* This value will always be NULL for the default handler.
* If you don't care about this data, it is safe to pass
* a NULL pointer to this function to ignore it.
* \return The SDL_AssertionHandler that is called when an assert triggers.
*/
extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata);

/**
* \brief Get a list of all assertion failures.
*
Expand Down
117 changes: 9 additions & 108 deletions code/SDL2/include/SDL_atomic.h
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2014 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
Expand Down Expand Up @@ -64,13 +64,6 @@

#include "begin_code.h"

/* Need to do this here because intrin.h has C++ code in it */
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
#include <intrin.h>
#define HAVE_MSC_ATOMICS 1
#endif

/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
Expand All @@ -91,7 +84,7 @@ extern "C" {
* The spin lock functions and type are required and can not be
* emulated because they are used in the atomic emulation code.
*/
/*@{*/
/* @{ */

typedef int SDL_SpinLock;

Expand All @@ -118,7 +111,7 @@ extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock);
*/
extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock);

/*@}*//*SDL AtomicLock*/
/* @} *//* SDL AtomicLock */


/**
Expand Down Expand Up @@ -181,57 +174,11 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquire();
#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier()
#endif


/* Platform specific optimized versions of the atomic functions,
* you can disable these by defining SDL_DISABLE_ATOMIC_INLINE
*/
#if defined(SDL_ATOMIC_DISABLED) && SDL_ATOMIC_DISABLED
#define SDL_DISABLE_ATOMIC_INLINE
#endif
#ifndef SDL_DISABLE_ATOMIC_INLINE

#ifdef HAVE_MSC_ATOMICS

#define SDL_AtomicSet(a, v) _InterlockedExchange((long*)&(a)->value, (v))
#define SDL_AtomicAdd(a, v) _InterlockedExchangeAdd((long*)&(a)->value, (v))
#define SDL_AtomicCAS(a, oldval, newval) (_InterlockedCompareExchange((long*)&(a)->value, (newval), (oldval)) == (oldval))
#define SDL_AtomicSetPtr(a, v) _InterlockedExchangePointer((a), (v))
#if _M_IX86
#define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchange((long*)(a), (long)(newval), (long)(oldval)) == (long)(oldval))
#else
#define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchangePointer((a), (newval), (oldval)) == (oldval))
#endif

#elif defined(__MACOSX__)
#include <libkern/OSAtomic.h>

#define SDL_AtomicCAS(a, oldval, newval) OSAtomicCompareAndSwap32Barrier((oldval), (newval), &(a)->value)
#ifdef __LP64__
#define SDL_AtomicCASPtr(a, oldval, newval) OSAtomicCompareAndSwap64Barrier((int64_t)(oldval), (int64_t)(newval), (int64_t*)(a))
#else
#define SDL_AtomicCASPtr(a, oldval, newval) OSAtomicCompareAndSwap32Barrier((int32_t)(oldval), (int32_t)(newval), (int32_t*)(a))
#endif

#elif defined(HAVE_GCC_ATOMICS)

#define SDL_AtomicSet(a, v) __sync_lock_test_and_set(&(a)->value, v)
#define SDL_AtomicAdd(a, v) __sync_fetch_and_add(&(a)->value, v)
#define SDL_AtomicSetPtr(a, v) __sync_lock_test_and_set(a, v)
#define SDL_AtomicCAS(a, oldval, newval) __sync_bool_compare_and_swap(&(a)->value, oldval, newval)
#define SDL_AtomicCASPtr(a, oldval, newval) __sync_bool_compare_and_swap(a, oldval, newval)

#endif

#endif /* !SDL_DISABLE_ATOMIC_INLINE */


/**
* \brief A type representing an atomic integer value. It is a struct
* so people don't accidentally use numeric operations on it.
*/
#ifndef SDL_atomic_t_defined
typedef struct { int value; } SDL_atomic_t;
#endif

/**
* \brief Set an atomic variable to a new value if it is currently an old value.
Expand All @@ -240,37 +187,19 @@ typedef struct { int value; } SDL_atomic_t;
*
* \note If you don't know what this function is for, you shouldn't use it!
*/
#ifndef SDL_AtomicCAS
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval);
#endif

/**
* \brief Set an atomic variable to a value.
*
* \return The previous value of the atomic variable.
*/
#ifndef SDL_AtomicSet
SDL_FORCE_INLINE int SDL_AtomicSet(SDL_atomic_t *a, int v)
{
int value;
do {
value = a->value;
} while (!SDL_AtomicCAS(a, value, v));
return value;
}
#endif
extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v);

/**
* \brief Get the value of an atomic variable
*/
#ifndef SDL_AtomicGet
SDL_FORCE_INLINE int SDL_AtomicGet(SDL_atomic_t *a)
{
int value = a->value;
SDL_CompilerBarrier();
return value;
}
#endif
extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a);

/**
* \brief Add to an atomic variable.
Expand All @@ -279,16 +208,7 @@ SDL_FORCE_INLINE int SDL_AtomicGet(SDL_atomic_t *a)
*
* \note This same style can be used for any number operation
*/
#ifndef SDL_AtomicAdd
SDL_FORCE_INLINE int SDL_AtomicAdd(SDL_atomic_t *a, int v)
{
int value;
do {
value = a->value;
} while (!SDL_AtomicCAS(a, value, (value + v)));
return value;
}
#endif
extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v);

/**
* \brief Increment an atomic variable used as a reference count.
Expand All @@ -314,38 +234,19 @@ SDL_FORCE_INLINE int SDL_AtomicAdd(SDL_atomic_t *a, int v)
*
* \note If you don't know what this function is for, you shouldn't use it!
*/
#ifndef SDL_AtomicCASPtr
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void* *a, void *oldval, void *newval);
#endif
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval);

/**
* \brief Set a pointer to a value atomically.
*
* \return The previous value of the pointer.
*/
#ifndef SDL_AtomicSetPtr
SDL_FORCE_INLINE void* SDL_AtomicSetPtr(void* *a, void* v)
{
void* value;
do {
value = *a;
} while (!SDL_AtomicCASPtr(a, value, v));
return value;
}
#endif
extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v);

/**
* \brief Get the value of a pointer atomically.
*/
#ifndef SDL_AtomicGetPtr
SDL_FORCE_INLINE void* SDL_AtomicGetPtr(void* *a)
{
void* value = *a;
SDL_CompilerBarrier();
return value;
}
#endif

extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void **a);

/* Ends C function definitions when using C++ */
#ifdef __cplusplus
Expand Down

0 comments on commit dafed0f

Please sign in to comment.