From 112b44c6bc5bc45d58c58207845f269b36078bab Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Tue, 28 Jul 2009 13:58:51 +0200 Subject: fixed messagepump_free to work with pthread --- threading_pthread.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'threading_pthread.c') diff --git a/threading_pthread.c b/threading_pthread.c index 76dd65a5..17ad59e3 100644 --- a/threading_pthread.c +++ b/threading_pthread.c @@ -4,37 +4,23 @@ #include "threading.h" void thread_start (void (*fn)(uintptr_t ctx), uintptr_t ctx) { - printf ("thread_start called!\n"); pthread_t tid; pthread_attr_t attr; - printf ("pthread_attr_init!\n"); int s = pthread_attr_init (&attr); if (s) { printf ("pthread_attr_init failed\n"); return; } - printf ("pthread_create!\n"); if (pthread_create (&tid, &attr, (void *(*)(void *))fn, (void*)ctx)) { printf ("pthread_create failed\n"); return; } - printf ("pthread_attr_destroy!\n"); s = pthread_attr_destroy (&attr); if (s) { printf ("pthread_attr_destroy failed\n"); return; } -#if 0 - void *res; - printf ("pthread_join!\n"); - s = pthread_join (tid, &res); - if (s) { - printf ("pthread_join failed\n"); - return; - } - free (res); -#endif } uintptr_t mutex_create (void) { pthread_mutex_t *mtx = malloc (sizeof (pthread_mutex_t)); @@ -52,10 +38,14 @@ void mutex_free (uintptr_t _mtx) { } int mutex_lock (uintptr_t _mtx) { pthread_mutex_t *mtx = (pthread_mutex_t *)_mtx; - pthread_mutex_lock (mtx); + if (pthread_mutex_lock (mtx)) { + printf ("pthread_mutex_lock failed\n"); + } } int mutex_unlock (uintptr_t _mtx) { pthread_mutex_t *mtx = (pthread_mutex_t *)_mtx; - pthread_mutex_unlock (mtx); + if (pthread_mutex_unlock (mtx)) { + printf ("pthread_mutex_unlock failed\n"); + }; } -- cgit v1.2.3