properly support POSIX threads kthx

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1838 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
bushing
2009-01-09 12:10:02 +00:00
parent 96f9e7a82e
commit 969496d93b
2 changed files with 48 additions and 31 deletions

View File

@ -18,28 +18,27 @@
#ifndef _THREAD_H
#define _THREAD_H
#ifdef _WIN32
#include <windows.h>
#else
#include <pthread.h>
#endif
#ifdef _WIN32
#define THREAD_RETURN DWORD WINAPI
#else
#define THREAD_RETURN void*
#include <unistd.h>
#ifdef _POSIX_THREADS
#include <pthread.h>
#else
#error unsupported platform (no pthreads?)
#endif
#endif
#include "Common.h"
namespace Common
{
class CriticalSection
{
#ifdef _WIN32
CRITICAL_SECTION section;
#elif __GNUC__
#else
pthread_mutex_t mutex;
#endif
public:
@ -53,7 +52,7 @@ public:
#ifdef _WIN32
typedef DWORD (WINAPI * ThreadFunc)(void* arg);
#elif __GNUC__
#else
typedef void* (*ThreadFunc)(void* arg);
#endif
@ -73,7 +72,7 @@ private:
#ifdef _WIN32
HANDLE m_hThread;
DWORD m_threadId;
#elif __GNUC__
#else
pthread_t thread_id;
#endif
};
@ -96,13 +95,14 @@ class Event
#ifdef _WIN32
HANDLE m_hEvent;
#elif __GNUC__
#else
bool is_set_;
pthread_cond_t event_;
pthread_mutex_t mutex_;
#endif
};
void InitThreading(void);
void SleepCurrentThread(int ms);
void SetCurrentThreadName(const char *name);