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:
parent
5372bfd326
commit
6c3f928cd8
101 changed files with 8882 additions and 601 deletions
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include "SDL_windows.h"
|
||||
|
||||
typedef HANDLE SYS_ThreadHandle;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue