Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Mac OS X doesn't provide the sem_timedwait() function.
authorcherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 23 Oct 2007 11:26:19 +0000 (11:26 +0000)
committercherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 23 Oct 2007 11:26:19 +0000 (11:26 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4854 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/portable.h
src/xbt/xbt_os_thread.c

index 537d24c..99de0b8 100644 (file)
@@ -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 */
index 023848e..8465beb 100644 (file)
@@ -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