X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6760cb07d6b57be16928d95339d71e57c4e24f36..1af9727066a32ce8b66adf74e95d87b5879eae0f:/src/xbt/xbt_rl_synchro.c diff --git a/src/xbt/xbt_rl_synchro.c b/src/xbt/xbt_rl_synchro.c index 0bdbba6ea0..c33b03e554 100644 --- a/src/xbt/xbt_rl_synchro.c +++ b/src/xbt/xbt_rl_synchro.c @@ -14,7 +14,6 @@ #include "xbt/ex.h" #include "portable.h" -#include "xbt/synchro.h" /* This module */ #include "xbt/xbt_os_thread.h" /* The implementation we use */ /* the implementation would be cleaner (and faster) with ELF symbol aliasing */ @@ -30,8 +29,8 @@ typedef struct s_xbt_thread_ { static void *xbt_thread_create_wrapper(void *p) { xbt_thread_t t = (xbt_thread_t) p; - DEBUG1("I'm thread %p", p); - (*t->code) (t->userparam); + XBT_DEBUG("I'm thread %p", p); + t->code(t->userparam); return NULL; } @@ -43,8 +42,9 @@ xbt_thread_t xbt_thread_create(const char *name, void_f_pvoid_t code, xbt_thread_t res = xbt_new0(s_xbt_thread_t, 1); res->userparam = param; res->code = code; - DEBUG1("Create thread %p", res); - res->os_thread = xbt_os_thread_create(name, xbt_thread_create_wrapper, res); + XBT_DEBUG("Create thread %p", res); + res->os_thread = + xbt_os_thread_create(name, xbt_thread_create_wrapper, res, NULL); return res; } @@ -60,14 +60,14 @@ const char *xbt_thread_self_name(void) void xbt_thread_join(xbt_thread_t thread) { - DEBUG1("Join thread %p", thread); + XBT_DEBUG("Join thread %p", thread); xbt_os_thread_join(thread->os_thread, NULL); xbt_free(thread); } void xbt_thread_exit() { - DEBUG0("Thread exits"); + XBT_DEBUG("Thread exits"); xbt_os_thread_exit(NULL); } @@ -78,13 +78,13 @@ xbt_thread_t xbt_thread_self(void) void xbt_thread_yield(void) { - DEBUG0("Thread yields"); + XBT_DEBUG("Thread yields"); xbt_os_thread_yield(); } void xbt_thread_cancel(xbt_thread_t t) { - DEBUG1("Cancel thread %p", t); + XBT_DEBUG("Cancel thread %p", t); xbt_os_thread_cancel(t->os_thread); } @@ -93,7 +93,7 @@ struct xbt_mutex_ { /* KEEP IT IN SYNC WITH OS IMPLEMENTATION (both win and lin) */ #ifdef HAVE_PTHREAD_H pthread_mutex_t m; -#elif defined(WIN32) +#elif defined(_XBT_WIN32) CRITICAL_SECTION lock; #endif }; @@ -101,35 +101,35 @@ struct xbt_mutex_ { xbt_mutex_t xbt_mutex_init(void) { xbt_mutex_t res = (xbt_mutex_t) xbt_os_mutex_init(); - DEBUG1("Create mutex %p", res); + XBT_DEBUG("Create mutex %p", res); return res; } void xbt_mutex_acquire(xbt_mutex_t mutex) { - DEBUG1("Acquire mutex %p", mutex); + XBT_DEBUG("Acquire mutex %p", mutex); xbt_os_mutex_acquire((xbt_os_mutex_t) mutex); } void xbt_mutex_timedacquire(xbt_mutex_t mutex, double delay) { - DEBUG2("Acquire mutex %p with delay %lf", mutex, delay); + XBT_DEBUG("Acquire mutex %p with delay %lf", mutex, delay); xbt_os_mutex_timedacquire((xbt_os_mutex_t) mutex, delay); } void xbt_mutex_release(xbt_mutex_t mutex) { - DEBUG1("Unlock mutex %p", mutex); + XBT_DEBUG("Unlock mutex %p", mutex); xbt_os_mutex_release((xbt_os_mutex_t) mutex); } void xbt_mutex_destroy(xbt_mutex_t mutex) { - DEBUG1("Destroy mutex %p", mutex); + XBT_DEBUG("Destroy mutex %p", mutex); xbt_os_mutex_destroy((xbt_os_mutex_t) mutex); } -#ifdef WIN32 +#ifdef _XBT_WIN32 enum { /* KEEP IT IN SYNC WITH OS IMPLEM */ SIGNAL = 0, BROADCAST = 1, @@ -142,7 +142,7 @@ typedef struct xbt_cond_ { /* KEEP IT IN SYNC WITH OS IMPLEMENTATION (both win and lin) */ #ifdef HAVE_PTHREAD_H pthread_cond_t c; -#elif defined(WIN32) +#elif defined(_XBT_WIN32) HANDLE events[MAX_EVENTS]; unsigned int waiters_count; /* the number of waiters */ @@ -153,37 +153,38 @@ typedef struct xbt_cond_ { xbt_cond_t xbt_cond_init(void) { xbt_cond_t res = (xbt_cond_t) xbt_os_cond_init(); - DEBUG1("Create cond %p", res); + XBT_DEBUG("Create cond %p", res); return res; } void xbt_cond_wait(xbt_cond_t cond, xbt_mutex_t mutex) { - DEBUG2("Wait cond %p, mutex %p", cond, mutex); + XBT_DEBUG("Wait cond %p, mutex %p", cond, mutex); xbt_os_cond_wait((xbt_os_cond_t) cond, (xbt_os_mutex_t) mutex); } void xbt_cond_timedwait(xbt_cond_t cond, xbt_mutex_t mutex, double delay) { - DEBUG3("Wait cond %p, mutex %p for %f sec", cond, mutex, delay); - xbt_os_cond_timedwait((xbt_os_cond_t) cond, (xbt_os_mutex_t) mutex, delay); - DEBUG3("Done waiting cond %p, mutex %p for %f sec", cond, mutex, delay); + XBT_DEBUG("Wait cond %p, mutex %p for %f sec", cond, mutex, delay); + xbt_os_cond_timedwait((xbt_os_cond_t) cond, (xbt_os_mutex_t) mutex, + delay); + XBT_DEBUG("Done waiting cond %p, mutex %p for %f sec", cond, mutex, delay); } void xbt_cond_signal(xbt_cond_t cond) { - DEBUG1("Signal cond %p", cond); + XBT_DEBUG("Signal cond %p", cond); xbt_os_cond_signal((xbt_os_cond_t) cond); } void xbt_cond_broadcast(xbt_cond_t cond) { - DEBUG1("Broadcast cond %p", cond); + XBT_DEBUG("Broadcast cond %p", cond); xbt_os_cond_broadcast((xbt_os_cond_t) cond); } void xbt_cond_destroy(xbt_cond_t cond) { - DEBUG1("Destroy cond %p", cond); + XBT_DEBUG("Destroy cond %p", cond); xbt_os_cond_destroy((xbt_os_cond_t) cond); }