Please try the patch below and report back to me. :)

    # cd /usr/src/lib/libpthread
    # patch -p0 < /path/to/patch
    # make
    # make includes
    # make install


Index: include/semaphore.h
===================================================================
RCS file: /cvs/src/lib/libpthread/include/semaphore.h,v
retrieving revision 1.3
diff -u -p include/semaphore.h
--- include/semaphore.h 16 Feb 2002 21:27:25 -0000      1.3
+++ include/semaphore.h 24 Jun 2010 01:03:15 -0000
@@ -59,6 +59,7 @@ int   sem_close(sem_t *);
 int    sem_unlink(const char *);
 int    sem_wait(sem_t *);
 int    sem_trywait(sem_t *);
+int    sem_timedwait(sem_t *, const struct timespec *);
 int    sem_post(sem_t *);
 int    sem_getvalue(sem_t *, int *);
 __END_DECLS
Index: uthread/uthread_sem.c
===================================================================
RCS file: /cvs/src/lib/libpthread/uthread/uthread_sem.c,v
retrieving revision 1.3
diff -u -p uthread/uthread_sem.c
--- uthread/uthread_sem.c       20 Jun 2008 02:58:00 -0000      1.3
+++ uthread/uthread_sem.c       24 Jun 2010 01:03:15 -0000
@@ -207,6 +207,40 @@ sem_trywait(sem_t *sem)
 }
 
 int
+sem_timedwait(sem_t *sem, const struct timespec *abstime)
+{
+       int     retval;
+
+       _thread_enter_cancellation_point();
+       
+       _SEM_CHECK_VALIDITY(sem);
+
+       pthread_mutex_lock(&(*sem)->lock);
+
+       for (;;) {
+               if ((*sem)->count > 0) {
+                       (*sem)->count--;
+                       retval = 0;
+                       break;
+               }
+               (*sem)->nwaiters++;
+               retval = pthread_cond_timedwait(&(*sem)->gtzero,
+                   &(*sem)->lock, abstime);
+               (*sem)->nwaiters--;
+               if (retval != 0) {
+                       errno = retval;
+                       retval = -1;
+                       break;
+               }
+       }
+
+       pthread_mutex_unlock(&(*sem)->lock);
+  RETURN:
+       _thread_leave_cancellation_point();
+       return retval;
+}
+
+int
 sem_post(sem_t *sem)
 {
        int     retval;

Reply via email to