From 0ff36e7874bbedd7bcf44d9d98511c1457699300 Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Thu, 22 Nov 2012 23:12:06 -0500 Subject: [PATCH] WinRT: made the skeleton C++11 thread implementation use .cpp files, not .c --- VisualC/SDL/SDL_VS2012_WinRT.vcxproj | 6 +++--- src/thread/stdcpp/{SDL_syscond.c => SDL_syscond.cpp} | 6 ++++++ src/thread/stdcpp/{SDL_sysmutex.c => SDL_sysmutex.cpp} | 4 ++++ src/thread/stdcpp/{SDL_systhread.c => SDL_systhread.cpp} | 7 +++++++ 4 files changed, 20 insertions(+), 3 deletions(-) rename src/thread/stdcpp/{SDL_syscond.c => SDL_syscond.cpp} (98%) rename src/thread/stdcpp/{SDL_sysmutex.c => SDL_sysmutex.cpp} (98%) rename src/thread/stdcpp/{SDL_systhread.c => SDL_systhread.cpp} (95%) diff --git a/VisualC/SDL/SDL_VS2012_WinRT.vcxproj b/VisualC/SDL/SDL_VS2012_WinRT.vcxproj index 3bb971a7b..bdf0478d6 100644 --- a/VisualC/SDL/SDL_VS2012_WinRT.vcxproj +++ b/VisualC/SDL/SDL_VS2012_WinRT.vcxproj @@ -91,9 +91,9 @@ - - - + + + diff --git a/src/thread/stdcpp/SDL_syscond.c b/src/thread/stdcpp/SDL_syscond.cpp similarity index 98% rename from src/thread/stdcpp/SDL_syscond.c rename to src/thread/stdcpp/SDL_syscond.cpp index 7304badc1..a603a1ba3 100644 --- a/src/thread/stdcpp/SDL_syscond.c +++ b/src/thread/stdcpp/SDL_syscond.cpp @@ -38,6 +38,7 @@ struct SDL_cond }; /* Create a condition variable */ +extern "C" SDL_cond * SDL_CreateCond(void) { @@ -60,6 +61,7 @@ SDL_CreateCond(void) } /* Destroy a condition variable */ +extern "C" void SDL_DestroyCond(SDL_cond * cond) { @@ -78,6 +80,7 @@ SDL_DestroyCond(SDL_cond * cond) } /* Restart one of the threads that are waiting on the condition variable */ +extern "C" int SDL_CondSignal(SDL_cond * cond) { @@ -103,6 +106,7 @@ SDL_CondSignal(SDL_cond * cond) } /* Restart all threads that are waiting on the condition variable */ +extern "C" int SDL_CondBroadcast(SDL_cond * cond) { @@ -158,6 +162,7 @@ Thread B: SDL_CondSignal(cond); SDL_UnlockMutex(lock); */ +extern "C" int SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) { @@ -214,6 +219,7 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) } /* Wait on the condition variable forever */ +extern "C" int SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) { diff --git a/src/thread/stdcpp/SDL_sysmutex.c b/src/thread/stdcpp/SDL_sysmutex.cpp similarity index 98% rename from src/thread/stdcpp/SDL_sysmutex.c rename to src/thread/stdcpp/SDL_sysmutex.cpp index 1a6b2715c..e220bc5df 100644 --- a/src/thread/stdcpp/SDL_sysmutex.c +++ b/src/thread/stdcpp/SDL_sysmutex.cpp @@ -34,6 +34,7 @@ struct SDL_mutex }; /* Create a mutex */ +extern "C" SDL_mutex * SDL_CreateMutex(void) { @@ -57,6 +58,7 @@ SDL_CreateMutex(void) } /* Free the mutex */ +extern "C" void SDL_DestroyMutex(SDL_mutex * mutex) { @@ -69,6 +71,7 @@ SDL_DestroyMutex(SDL_mutex * mutex) } /* Lock the semaphore */ +extern "C" int SDL_mutexP(SDL_mutex * mutex) { @@ -100,6 +103,7 @@ SDL_mutexP(SDL_mutex * mutex) } /* Unlock the mutex */ +extern "C" int SDL_mutexV(SDL_mutex * mutex) { diff --git a/src/thread/stdcpp/SDL_systhread.c b/src/thread/stdcpp/SDL_systhread.cpp similarity index 95% rename from src/thread/stdcpp/SDL_systhread.c rename to src/thread/stdcpp/SDL_systhread.cpp index ed557a461..e40d8f277 100644 --- a/src/thread/stdcpp/SDL_systhread.c +++ b/src/thread/stdcpp/SDL_systhread.cpp @@ -22,9 +22,12 @@ /* Thread management routines for SDL */ +extern "C" { #include "SDL_thread.h" #include "../SDL_systhread.h" +} +extern "C" int SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { @@ -32,24 +35,28 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) return (-1); } +extern "C" void SDL_SYS_SetupThread(const char *name) { return; } +extern "C" SDL_threadID SDL_ThreadID(void) { return (0); } +extern "C" int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { return (0); } +extern "C" void SDL_SYS_WaitThread(SDL_Thread * thread) {