summaryrefslogtreecommitdiffstats
path: root/common/thread_calls.c
diff options
context:
space:
mode:
authorjsorg71 <jsorg71>2007-02-03 06:17:24 +0000
committerjsorg71 <jsorg71>2007-02-03 06:17:24 +0000
commitc94344a6f4d9f033a4ae84acfc4bb622f6c945e7 (patch)
treeee5327af989a970eeb0cd32b737ad96af18b463a /common/thread_calls.c
parent96fd0b8a000f3d1c871bf0276c1ec39fd0885a37 (diff)
downloadxrdp-proprietary-c94344a6f4d9f033a4ae84acfc4bb622f6c945e7.tar.gz
xrdp-proprietary-c94344a6f4d9f033a4ae84acfc4bb622f6c945e7.zip
work on threads
Diffstat (limited to 'common/thread_calls.c')
-rw-r--r--common/thread_calls.c63
1 files changed, 60 insertions, 3 deletions
diff --git a/common/thread_calls.c b/common/thread_calls.c
index 8bd399ad..62bc2be4 100644
--- a/common/thread_calls.c
+++ b/common/thread_calls.c
@@ -27,12 +27,13 @@
#endif
#include "arch.h"
#include "thread_calls.h"
+#include "os_calls.h"
/*****************************************************************************/
/* returns error */
#if defined(_WIN32)
int APP_CC
-g_thread_create(unsigned long (__stdcall * start_routine)(void*), void* arg)
+tc_thread_create(unsigned long (__stdcall * start_routine)(void*), void* arg)
{
DWORD thread_id;
HANDLE thread;
@@ -46,7 +47,7 @@ g_thread_create(unsigned long (__stdcall * start_routine)(void*), void* arg)
}
#else
int APP_CC
-g_thread_create(void* (* start_routine)(void*), void* arg)
+tc_thread_create(void* (* start_routine)(void*), void* arg)
{
pthread_t thread;
int rv;
@@ -60,7 +61,7 @@ g_thread_create(void* (* start_routine)(void*), void* arg)
/*****************************************************************************/
long APP_CC
-g_get_threadid(void)
+tc_get_threadid(void)
{
#if defined(_WIN32)
return (long)GetCurrentThreadId();
@@ -68,3 +69,59 @@ g_get_threadid(void)
return (long)pthread_self();
#endif
}
+
+/*****************************************************************************/
+long APP_CC
+tc_create_mutex(void)
+{
+#if defined(_WIN32)
+ return (long)CreateMutex(0, 0, 0);
+#else
+ pthread_mutex_t* lmutex;
+
+ lmutex = (pthread_mutex_t*)g_malloc(sizeof(pthread_mutex_t), 0);
+ pthread_mutex_init(lmutex, 0);
+ return (long)lmutex;
+#endif
+}
+
+/*****************************************************************************/
+void APP_CC
+tc_delete_mutex(long mutex)
+{
+#if defined(_WIN32)
+ CloseHandle((HANDLE)mutex);
+#else
+ pthread_mutex_t* lmutex;
+
+ lmutex = (pthread_mutex_t*)mutex;
+ pthread_mutex_destroy(lmutex);
+ g_free(lmutex);
+#endif
+}
+
+/*****************************************************************************/
+int APP_CC
+tc_lock_mutex(long mutex)
+{
+#if defined(_WIN32)
+ WaitForSingleObject((HANDLE)mutex, INFINITE);
+ return 0;
+#else
+ pthread_mutex_lock((pthread_mutex_t*)mutex);
+ return 0;
+#endif
+}
+
+/*****************************************************************************/
+int APP_CC
+tc_unlock_mutex(long mutex)
+{
+#if defined(_WIN32)
+ ReleaseMutex((HANDLE)mutex);
+ return 0;
+#else
+ pthread_mutex_unlock((pthread_mutex_t*)mutex);
+ return 0;
+#endif
+}