From db93cd1c0fc7fed756efeb7ffad21d553f41be97 Mon Sep 17 00:00:00 2001 From: cherierm Date: Tue, 23 Oct 2007 11:26:19 +0000 Subject: [PATCH 1/1] Mac OS X doesn't provide the sem_timedwait() function. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4854 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/portable.h | 9 +++++++++ src/xbt/xbt_os_thread.c | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/portable.h b/src/portable.h index 537d24cff6..99de0b81ec 100644 --- a/src/portable.h +++ b/src/portable.h @@ -163,4 +163,13 @@ XBT_PUBLIC(int) gettimeofday(struct timeval *tv, struct timezone *tz); #endif +#define HAVE_SEM_TIMEDWAIT 1 + +/* mac osx doesn't have the sem_timedwait() function */ +#if defined(__GNUC__) && ( defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__MACOS_CLASSIC__) ) +# +# undef HAVE_SEM_TIMEDWAIT +# +#endif + #endif /* GRAS_PORTABLE_H */ diff --git a/src/xbt/xbt_os_thread.c b/src/xbt/xbt_os_thread.c index 023848edb7..8465beb8dd 100644 --- a/src/xbt/xbt_os_thread.c +++ b/src/xbt/xbt_os_thread.c @@ -317,6 +317,10 @@ xbt_os_sem_acquire(xbt_os_sem_t sem) void xbt_os_sem_timedacquire(xbt_os_sem_t sem,double timeout) { + /* mac os x have not the sem_timedwait() function */ + #ifndef HAVE_SEM_TIMEDWAIT + THROW_UNIMPLEMENTED; + #else int errcode; struct timespec ts_end; double end = timeout + xbt_os_time(); @@ -346,6 +350,7 @@ void xbt_os_sem_timedacquire(xbt_os_sem_t sem,double timeout) THROW3(system_error,errcode,"sem_timedwait(%p,%f) failed: %s",sem,timeout, strerror(errcode)); } } + #endif } void -- 2.20.1