Enabled libc support on Win32, so we don't break binary compatibility in 1.2
authorSam Lantinga <slouken@libsdl.org>
Mon, 06 Mar 2006 07:42:36 +0000
changeset 14719fb0eee04dd9
parent 1470 d47d96962fcc
child 1472 4aac8563c296
Enabled libc support on Win32, so we don't break binary compatibility in 1.2
VisualC.zip
VisualCE.zip
include/SDL_config_win32.h
include/SDL_thread.h
src/thread/SDL_systhread.h
src/thread/SDL_thread.c
src/thread/win32/SDL_systhread.c
     1.1 Binary file VisualC.zip has changed
     2.1 Binary file VisualCE.zip has changed
     3.1 --- a/include/SDL_config_win32.h	Mon Mar 06 06:00:45 2006 +0000
     3.2 +++ b/include/SDL_config_win32.h	Mon Mar 06 07:42:36 2006 +0000
     3.3 @@ -51,14 +51,64 @@
     3.4  typedef unsigned int uint32_t;
     3.5  typedef signed long long int64_t;
     3.6  typedef unsigned long long uint64_t;
     3.7 +#ifndef _SIZE_T_DEFINED_
     3.8 +#define _SIZE_T_DEFINED_
     3.9  typedef unsigned int size_t;
    3.10 +#endif
    3.11  typedef unsigned int uintptr_t;
    3.12  #endif /* _MSC_VER */
    3.13  #define SDL_HAS_64BIT_TYPE	1
    3.14  
    3.15 +/* Enabled for SDL 1.2 (binary compatibility) */
    3.16 +#define HAVE_LIBC	0
    3.17 +#if HAVE_LIBC
    3.18  /* Useful headers */
    3.19 +#define HAVE_STDIO_H 1
    3.20 +#define STDC_HEADERS 1
    3.21 +#define HAVE_STRING_H 1
    3.22 +#define HAVE_CTYPE_H 1
    3.23 +#define HAVE_MATH_H 1
    3.24 +#ifndef _WIN32_WCE
    3.25 +#define HAVE_SIGNAL_H 1
    3.26 +#endif
    3.27 +
    3.28 +/* C library functions */
    3.29 +#define HAVE_MALLOC 1
    3.30 +#define HAVE_CALLOC 1
    3.31 +#define HAVE_REALLOC 1
    3.32 +#define HAVE_FREE 1
    3.33 +#define HAVE_ALLOCA 1
    3.34 +#define HAVE_QSORT 1
    3.35 +#define HAVE_ABS 1
    3.36 +#define HAVE_MEMSET 1
    3.37 +#define HAVE_MEMCPY 1
    3.38 +#define HAVE_MEMMOVE 1
    3.39 +#define HAVE_MEMCMP 1
    3.40 +#define HAVE_STRLEN 1
    3.41 +#define HAVE__STRREV 1
    3.42 +#define HAVE__STRUPR 1
    3.43 +#define HAVE__STRLWR 1
    3.44 +#define HAVE_STRCHR 1
    3.45 +#define HAVE_STRRCHR 1
    3.46 +#define HAVE_STRSTR 1
    3.47 +#define HAVE_ITOA 1
    3.48 +#define HAVE__LTOA 1
    3.49 +#define HAVE__ULTOA 1
    3.50 +#define HAVE_STRTOL 1
    3.51 +#define HAVE_STRTOUL 1
    3.52 +#define HAVE_STRTOLL 1
    3.53 +#define HAVE_STRTOD 1
    3.54 +#define HAVE_ATOI 1
    3.55 +#define HAVE_ATOF 1
    3.56 +#define HAVE_STRCMP 1
    3.57 +#define HAVE_STRNCMP 1
    3.58 +#define HAVE_STRICMP 1
    3.59 +#define HAVE_STRCASECMP 1
    3.60 +#define HAVE_SSCANF 1
    3.61 +#else
    3.62  #define HAVE_STDARG_H	1
    3.63  #define HAVE_STDDEF_H	1
    3.64 +#endif
    3.65  
    3.66  /* Enable various audio drivers */
    3.67  #ifndef _WIN32_WCE
     4.1 --- a/include/SDL_thread.h	Mon Mar 06 06:00:45 2006 +0000
     4.2 +++ b/include/SDL_thread.h	Mon Mar 06 07:42:36 2006 +0000
     4.3 @@ -45,7 +45,7 @@
     4.4  typedef struct SDL_Thread SDL_Thread;
     4.5  
     4.6  /* Create a thread */
     4.7 -#if defined(__WIN32__) || defined(__OS2__)
     4.8 +#if (defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)
     4.9  /*
    4.10     We compile SDL into a DLL on OS/2. This means, that it's the DLL which
    4.11     creates a new thread for the calling process with the SDL_CreateThread()
    4.12 @@ -59,11 +59,9 @@
    4.13     So, in short:
    4.14     Always use the _beginthread() and _endthread() of the calling runtime library!
    4.15  */
    4.16 +#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
    4.17  #ifndef _WIN32_WCE
    4.18 -#include <process.h> // This has _beginthread() and _endthread() defined!
    4.19 -#endif
    4.20 -#ifdef __EMX__
    4.21 -#include <stdlib.h> // This has _beginthread() and _endthread() defined, if -Zmt flag is used!
    4.22 +#include <process.h> /* This has _beginthread() and _endthread() defined! */
    4.23  #endif
    4.24  
    4.25  #ifdef __OS2__
     5.1 --- a/src/thread/SDL_systhread.h	Mon Mar 06 06:00:45 2006 +0000
     5.2 +++ b/src/thread/SDL_systhread.h	Mon Mar 06 07:42:36 2006 +0000
     5.3 @@ -32,7 +32,7 @@
     5.4     saves a system-dependent thread id in thread->id, and returns 0
     5.5     on success.
     5.6  */
     5.7 -#if defined(__WIN32__) || defined(__OS2__)
     5.8 +#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
     5.9  extern int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
    5.10  #else
    5.11  extern int SDL_SYS_CreateThread(SDL_Thread *thread, void *args);
     6.1 --- a/src/thread/SDL_thread.c	Mon Mar 06 06:00:45 2006 +0000
     6.2 +++ b/src/thread/SDL_thread.c	Mon Mar 06 07:42:36 2006 +0000
     6.3 @@ -209,7 +209,7 @@
     6.4  	*statusloc = userfunc(userdata);
     6.5  }
     6.6  
     6.7 -#if defined(__WIN32__) || defined(__OS2__)
     6.8 +#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
     6.9  #undef SDL_CreateThread
    6.10  DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
    6.11  #else
    6.12 @@ -250,7 +250,7 @@
    6.13  	SDL_AddThread(thread);
    6.14  
    6.15  	/* Create the thread and go! */
    6.16 -#if defined(__WIN32__) || defined(__OS2__)
    6.17 +#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
    6.18  	ret = SDL_SYS_CreateThread(thread, args, pfnBeginThread, pfnEndThread);
    6.19  #else
    6.20  	ret = SDL_SYS_CreateThread(thread, args);
     7.1 --- a/src/thread/win32/SDL_systhread.c	Mon Mar 06 06:00:45 2006 +0000
     7.2 +++ b/src/thread/win32/SDL_systhread.c	Mon Mar 06 07:42:36 2006 +0000
     7.3 @@ -30,6 +30,26 @@
     7.4  #include "../SDL_thread_c.h"
     7.5  #include "../SDL_systhread.h"
     7.6  
     7.7 +#ifndef SDL_PASSED_BEGINTHREAD_ENDTHREAD
     7.8 +#ifndef _WIN32_WCE
     7.9 +/* We'll use the C library from this DLL */
    7.10 +#include <process.h>
    7.11 +#endif
    7.12 +
    7.13 +#if __GNUC__
    7.14 +typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
    7.15 +        unsigned (__stdcall *func)(void *), void *arg, 
    7.16 +        unsigned, unsigned *threadID);
    7.17 +typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
    7.18 +#else
    7.19 +typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
    7.20 +        unsigned (__stdcall *func)(void *), void *arg, 
    7.21 +        unsigned, unsigned *threadID);
    7.22 +typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
    7.23 +#endif
    7.24 +#endif /* !SDL_PASSED_BEGINTHREAD_ENDTHREAD */
    7.25 +
    7.26 +
    7.27  typedef struct ThreadStartParms
    7.28  {
    7.29    void *args;
    7.30 @@ -56,8 +76,20 @@
    7.31    return(0);
    7.32  }
    7.33  
    7.34 +#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
    7.35  int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
    7.36  {
    7.37 +#else
    7.38 +int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
    7.39 +{
    7.40 +#ifdef _WIN32_WCE
    7.41 +	pfnSDL_CurrentBeginThread pfnBeginThread = NULL;
    7.42 +	pfnSDL_CurrentEndThread pfnEndThread = NULL;
    7.43 +#else
    7.44 +	pfnSDL_CurrentBeginThread pfnBeginThread = _beginthreadex;
    7.45 +	pfnSDL_CurrentEndThread pfnEndThread = _endthreadex;
    7.46 +#endif
    7.47 +#endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */
    7.48  	unsigned threadid;
    7.49  	pThreadStartParms pThreadParms = (pThreadStartParms)SDL_malloc(sizeof(tThreadStartParms));
    7.50  	if (!pThreadParms) {