From 6ef6490c3136141b346596d2aad81b9cb5d478e9 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sat, 23 Jan 2010 12:11:49 +0100 Subject: more diagnostics for bsd --- threading_pthread.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'threading_pthread.c') diff --git a/threading_pthread.c b/threading_pthread.c index 83341770..29362c9d 100644 --- a/threading_pthread.c +++ b/threading_pthread.c @@ -58,7 +58,7 @@ uintptr_t mutex_create (void) { pthread_mutex_t *mtx = malloc (sizeof (pthread_mutex_t)); if (pthread_mutex_init (mtx, NULL)) { - printf ("pthread_mutex_init failed!\n"); + fprintf (stderr, "pthread_mutex_init failed!\n"); } return (uintptr_t)mtx; } @@ -75,17 +75,21 @@ mutex_free (uintptr_t _mtx) { int mutex_lock (uintptr_t _mtx) { pthread_mutex_t *mtx = (pthread_mutex_t *)_mtx; - if (pthread_mutex_lock (mtx)) { - printf ("pthread_mutex_lock failed\n"); + int err = pthread_mutex_lock (mtx); + if (err < 0) { + fprintf (stderr, "pthread_mutex_lock failed (error %d)\n", err); } + return err; } int mutex_unlock (uintptr_t _mtx) { pthread_mutex_t *mtx = (pthread_mutex_t *)_mtx; - if (pthread_mutex_unlock (mtx)) { - printf ("pthread_mutex_unlock failed\n"); - }; + int err = pthread_mutex_unlock (mtx); + if (err < 0) { + printf ("pthread_mutex_unlock failed (error %d)\n", err); + } + return err; } uintptr_t -- cgit v1.2.3