From: mquinson Date: Wed, 6 Jun 2007 13:45:03 +0000 (+0000) Subject: Be more verbose and display the string version of the error code X-Git-Tag: v3.3~1796 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c6e73e0bc2b1f092ab5a3ee79705ba6666c74da8 Be more verbose and display the string version of the error code git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3564 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/xbt/xbt_thread.c b/src/xbt/xbt_thread.c index 0b697bb632..0aef1c1549 100644 --- a/src/xbt/xbt_thread.c +++ b/src/xbt/xbt_thread.c @@ -67,7 +67,7 @@ xbt_thread_t xbt_thread_create(pvoid_f_pvoid_t start_routine, if ((errcode = pthread_create(&(res_thread->t), NULL, wrapper_start_routine, res_thread))) - THROW0(system_error,errcode, "pthread_create failed"); + THROW1(system_error,errcode, "pthread_create failed: %s",strerror(errcode)); return res_thread; } @@ -78,7 +78,8 @@ xbt_thread_join(xbt_thread_t thread,void ** thread_return) { int errcode; if ((errcode = pthread_join(thread->t,thread_return))) - THROW0(system_error,errcode, "pthread_join failed"); + THROW1(system_error,errcode, "pthread_join failed: %s", + strerror(errcode)); free(thread); } @@ -104,7 +105,8 @@ xbt_mutex_t xbt_mutex_init(void) { int errcode; if ((errcode = pthread_mutex_init(&(res->m),NULL))) - THROW0(system_error,errcode,"pthread_mutex_init() failed"); + THROW1(system_error,errcode,"pthread_mutex_init() failed: %s", + strerror(errcode)); return res; } @@ -113,14 +115,16 @@ void xbt_mutex_lock(xbt_mutex_t mutex) { int errcode; if ((errcode=pthread_mutex_lock(&(mutex->m)))) - THROW1(system_error,errcode,"pthread_mutex_lock(%p) failed",mutex); + THROW2(system_error,errcode,"pthread_mutex_lock(%p) failed: %s", + mutex, strerror(errcode)); } void xbt_mutex_unlock(xbt_mutex_t mutex) { int errcode; if ((errcode=pthread_mutex_unlock(&(mutex->m)))) - THROW1(system_error,errcode,"pthread_mutex_unlock(%p) failed",mutex); + THROW2(system_error,errcode,"pthread_mutex_unlock(%p) failed: %s", + mutex, strerror(errcode)); } void xbt_mutex_destroy(xbt_mutex_t mutex) { @@ -129,7 +133,8 @@ void xbt_mutex_destroy(xbt_mutex_t mutex) { if (!mutex) return; if ((errcode=pthread_mutex_destroy(&(mutex->m)))) - THROW1(system_error,errcode,"pthread_mutex_destroy(%p) failed",mutex); + THROW2(system_error,errcode,"pthread_mutex_destroy(%p) failed: %s", + mutex, strerror(errcode)); free(mutex); } @@ -142,7 +147,8 @@ xbt_thcond_t xbt_thcond_init(void) { xbt_thcond_t res = xbt_new(s_xbt_thcond_t,1); int errcode; if ((errcode=pthread_cond_init(&(res->c),NULL))) - THROW0(system_error,errcode,"pthread_cond_init() failed"); + THROW1(system_error,errcode,"pthread_cond_init() failed: %s", + strerror(errcode)); return res; } @@ -150,19 +156,22 @@ xbt_thcond_t xbt_thcond_init(void) { void xbt_thcond_wait(xbt_thcond_t cond, xbt_mutex_t mutex) { int errcode; if ((errcode=pthread_cond_wait(&(cond->c),&(mutex->m)))) - THROW2(system_error,errcode,"pthread_cond_wait(%p,%p) failed",cond,mutex); + THROW3(system_error,errcode,"pthread_cond_wait(%p,%p) failed: %s", + cond,mutex, strerror(errcode)); } void xbt_thcond_signal(xbt_thcond_t cond) { int errcode; if ((errcode=pthread_cond_signal(&(cond->c)))) - THROW1(system_error,errcode,"pthread_cond_signal(%p) failed",cond); + THROW2(system_error,errcode,"pthread_cond_signal(%p) failed: %s", + cond, strerror(errcode)); } void xbt_thcond_broadcast(xbt_thcond_t cond){ int errcode; if ((errcode=pthread_cond_broadcast(&(cond->c)))) - THROW1(system_error,errcode,"pthread_cond_broadcast(%p) failed",cond); + THROW2(system_error,errcode,"pthread_cond_broadcast(%p) failed: %s", + cond, strerror(errcode)); } void xbt_thcond_destroy(xbt_thcond_t cond){ int errcode; @@ -170,7 +179,8 @@ void xbt_thcond_destroy(xbt_thcond_t cond){ if (!cond) return; if ((errcode=pthread_cond_destroy(&(cond->c)))) - THROW1(system_error,errcode,"pthread_cond_destroy(%p) failed",cond); + THROW2(system_error,errcode,"pthread_cond_destroy(%p) failed: %s", + cond, strerror(errcode)); free(cond); }