diff --git a/VisualC.zip b/VisualC.zip index b99187216..2d00f7719 100644 Binary files a/VisualC.zip and b/VisualC.zip differ diff --git a/VisualCE.zip b/VisualCE.zip index e568a8a07..75d5d22cb 100644 Binary files a/VisualCE.zip and b/VisualCE.zip differ diff --git a/include/SDL_config_win32.h b/include/SDL_config_win32.h index f393ea4f7..5404aa626 100644 --- a/include/SDL_config_win32.h +++ b/include/SDL_config_win32.h @@ -51,14 +51,64 @@ typedef signed int int32_t; typedef unsigned int uint32_t; typedef signed long long int64_t; typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ typedef unsigned int size_t; +#endif typedef unsigned int uintptr_t; #endif /* _MSC_VER */ #define SDL_HAS_64BIT_TYPE 1 +/* Enabled for SDL 1.2 (binary compatibility) */ +#define HAVE_LIBC 0 +#if HAVE_LIBC /* Useful headers */ +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#ifndef _WIN32_WCE +#define HAVE_SIGNAL_H 1 +#endif + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE__LTOA 1 +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRICMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_SSCANF 1 +#else #define HAVE_STDARG_H 1 #define HAVE_STDDEF_H 1 +#endif /* Enable various audio drivers */ #ifndef _WIN32_WCE diff --git a/include/SDL_thread.h b/include/SDL_thread.h index 79eca0964..80746fe38 100644 --- a/include/SDL_thread.h +++ b/include/SDL_thread.h @@ -45,7 +45,7 @@ struct SDL_Thread; typedef struct SDL_Thread SDL_Thread; /* Create a thread */ -#if defined(__WIN32__) || defined(__OS2__) +#if (defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__) /* We compile SDL into a DLL on OS/2. This means, that it's the DLL which creates a new thread for the calling process with the SDL_CreateThread() @@ -59,11 +59,9 @@ typedef struct SDL_Thread SDL_Thread; So, in short: Always use the _beginthread() and _endthread() of the calling runtime library! */ +#define SDL_PASSED_BEGINTHREAD_ENDTHREAD #ifndef _WIN32_WCE -#include // This has _beginthread() and _endthread() defined! -#endif -#ifdef __EMX__ -#include // This has _beginthread() and _endthread() defined, if -Zmt flag is used! +#include /* This has _beginthread() and _endthread() defined! */ #endif #ifdef __OS2__ diff --git a/src/thread/SDL_systhread.h b/src/thread/SDL_systhread.h index 960d21868..ab9545c54 100644 --- a/src/thread/SDL_systhread.h +++ b/src/thread/SDL_systhread.h @@ -32,7 +32,7 @@ saves a system-dependent thread id in thread->id, and returns 0 on success. */ -#if defined(__WIN32__) || defined(__OS2__) +#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD extern int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); #else extern int SDL_SYS_CreateThread(SDL_Thread *thread, void *args); diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index 2b673d175..ffb69713a 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -209,7 +209,7 @@ void SDL_RunThread(void *data) *statusloc = userfunc(userdata); } -#if defined(__WIN32__) || defined(__OS2__) +#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD #undef SDL_CreateThread DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread) #else @@ -250,7 +250,7 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data) SDL_AddThread(thread); /* Create the thread and go! */ -#if defined(__WIN32__) || defined(__OS2__) +#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD ret = SDL_SYS_CreateThread(thread, args, pfnBeginThread, pfnEndThread); #else ret = SDL_SYS_CreateThread(thread, args); diff --git a/src/thread/win32/SDL_systhread.c b/src/thread/win32/SDL_systhread.c index cb5809043..2bee82c2d 100644 --- a/src/thread/win32/SDL_systhread.c +++ b/src/thread/win32/SDL_systhread.c @@ -30,6 +30,26 @@ #include "../SDL_thread_c.h" #include "../SDL_systhread.h" +#ifndef SDL_PASSED_BEGINTHREAD_ENDTHREAD +#ifndef _WIN32_WCE +/* We'll use the C library from this DLL */ +#include +#endif + +#if __GNUC__ +typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall *func)(void *), void *arg, + unsigned, unsigned *threadID); +typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); +#else +typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall *func)(void *), void *arg, + unsigned, unsigned *threadID); +typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); +#endif +#endif /* !SDL_PASSED_BEGINTHREAD_ENDTHREAD */ + + typedef struct ThreadStartParms { void *args; @@ -56,8 +76,20 @@ static unsigned __stdcall RunThread(void *data) return(0); } +#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread) { +#else +int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) +{ +#ifdef _WIN32_WCE + pfnSDL_CurrentBeginThread pfnBeginThread = NULL; + pfnSDL_CurrentEndThread pfnEndThread = NULL; +#else + pfnSDL_CurrentBeginThread pfnBeginThread = _beginthreadex; + pfnSDL_CurrentEndThread pfnEndThread = _endthreadex; +#endif +#endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */ unsigned threadid; pThreadStartParms pThreadParms = (pThreadStartParms)SDL_malloc(sizeof(tThreadStartParms)); if (!pThreadParms) {