It's now possible to build SDL without any C runtime at all on Windows,

using Visual C++ 2005

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401334
This commit is contained in:
Sam Lantinga 2006-02-06 08:28:51 +00:00
parent 5372bfd326
commit 6c3f928cd8
101 changed files with 8882 additions and 601 deletions

View file

@ -28,7 +28,7 @@
saves a system-dependent thread id in thread->id, and returns 0
on success.
*/
#ifdef __OS2__
#if defined(_WIN32) || defined(__OS2__)
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);

View file

@ -22,13 +22,11 @@
/* System independent thread management routines for SDL */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_error.h"
#include "SDL_mutex.h"
#include "SDL_thread.h"
#include "SDL_stdlib.h"
#include "SDL_string.h"
#include "SDL_thread_c.h"
#include "SDL_systhread.h"
@ -213,8 +211,9 @@ void SDL_RunThread(void *data)
*statusloc = userfunc(userdata);
}
#ifdef __OS2__
DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread_Core(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
#if defined(_WIN32) || defined(__OS2__)
#undef SDL_CreateThread
DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
#else
DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data)
#endif
@ -253,8 +252,8 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data)
SDL_AddThread(thread);
/* Create the thread and go! */
#ifdef __OS2__
ret = SDL_SYS_CreateThread(thread, args, pfnBeginThread, pfnEndThread);
#if defined(_WIN32) || defined(__OS2__)
ret = SDL_SYS_CreateThread(thread, args, pfnBeginThread, pfnEndThread);
#else
ret = SDL_SYS_CreateThread(thread, args);
#endif

View file

@ -26,11 +26,9 @@
implementation, written by Christopher Tate and Owen Smith. Thanks!
*/
#include <stdio.h>
#include <stdlib.h>
#include "SDL_error.h"
#include "SDL_thread.h"
#include "SDL_stdlib.h"
struct SDL_cond
{

View file

@ -22,11 +22,9 @@
/* An implementation of mutexes using semaphores */
#include <stdio.h>
#include <stdlib.h>
#include "SDL_error.h"
#include "SDL_thread.h"
#include "SDL_stdlib.h"
#include "SDL_systhread_c.h"

View file

@ -22,11 +22,10 @@
/* An implementation of semaphores using mutexes and condition variables */
#include <stdlib.h>
#include "SDL_error.h"
#include "SDL_timer.h"
#include "SDL_thread.h"
#include "SDL_stdlib.h"
#include "SDL_systhread_c.h"

View file

@ -72,7 +72,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThre
// Also save the real parameters we have to pass to thread function
pThreadParms->args = args;
// Start the thread using the runtime library of calling app!
thread->threadid = thread->handle = (*pfnBeginThread)(threadfunc, 512*1024, pThreadParms);
thread->threadid = thread->handle = (*pfnBeginThread)(threadfunc, NULL, 512*1024, pThreadParms);
if (thread->threadid<=0)
{
SDL_SetError("Not enough resources to create thread");

View file

@ -22,12 +22,11 @@
/* Mutex functions using the Win32 API */
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "SDL_windows.h"
#include "SDL_error.h"
#include "SDL_mutex.h"
#include "SDL_stdlib.h"
struct SDL_mutex {

View file

@ -22,12 +22,11 @@
/* Semaphore functions using the Win32 API */
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "SDL_windows.h"
#include "SDL_error.h"
#include "SDL_thread.h"
#include "SDL_stdlib.h"
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
#include "win_ce_semaphore.h"
#endif

View file

@ -22,43 +22,59 @@
/* Win32 thread management routines for SDL */
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#ifndef _WIN32_WCE
#include <process.h>
#endif
#include "SDL_windows.h"
#include "SDL_error.h"
#include "SDL_thread.h"
#include "SDL_stdlib.h"
#include "SDL_systhread.h"
typedef struct ThreadStartParms
{
void *args;
pfnSDL_CurrentEndThread pfnCurrentEndThread;
} tThreadStartParms, *pThreadStartParms;
static unsigned __stdcall RunThread(void *data)
{
SDL_RunThread(data);
return(0);
pThreadStartParms pThreadParms = (pThreadStartParms)data;
pfnSDL_CurrentEndThread pfnCurrentEndThread = NULL;
// Call the thread function!
SDL_RunThread(pThreadParms->args);
// Get the current endthread we have to use!
if (pThreadParms)
{
pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread;
free(pThreadParms);
}
// Call endthread!
if (pfnCurrentEndThread)
(*pfnCurrentEndThread)(0);
return(0);
}
int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
{
unsigned threadid;
pThreadStartParms pThreadParms = (pThreadStartParms)malloc(sizeof(tThreadStartParms));
if (!pThreadParms) {
SDL_OutOfMemory();
return(-1);
}
/*
* Avoid CreateThread: https://bugzilla.libsdl.org/show_bug.cgi?id=22
*
* have to use _beginthreadex if we want the returned handle
* to be accessible after the thread exits
* threads created with _beginthread auto-close the handle
* Windows CE still use CreateThread.
*/
#ifdef _WIN32_WCE
thread->handle = CreateThread(NULL, 0, RunThread, args, 0, &threadid);
#else
thread->handle = (SYS_ThreadHandle) _beginthreadex(NULL, 0, RunThread,
args, 0, &threadid);
#endif
// Save the function which we will have to call to clear the RTL of calling app!
pThreadParms->pfnCurrentEndThread = pfnEndThread;
// Also save the real parameters we have to pass to thread function
pThreadParms->args = args;
if (pfnBeginThread) {
thread->handle = (SYS_ThreadHandle) pfnBeginThread(NULL, 0, RunThread,
pThreadParms, 0, &threadid);
} else {
thread->handle = CreateThread(NULL, 0, RunThread, pThreadParms, 0, &threadid);
}
if (thread->handle == NULL) {
SDL_SetError("Not enough resources to create thread");
return(-1);

View file

@ -20,7 +20,7 @@
slouken@libsdl.org
*/
#include <windows.h>
#include "SDL_windows.h"
typedef HANDLE SYS_ThreadHandle;

View file

@ -28,7 +28,7 @@
and it is not clear how to handle a mixture of WCE semaphores and normal
events and mutexes. */
#include <windows.h>
#include "SDL_windows.h"
#include "win_ce_semaphore.h"
static SYNCHHANDLE CleanUp (SYNCHHANDLE hSynch, DWORD Flags);