Module: xenomai-jki
Branch: for-upstream
Commit: 91d84f3e333e3bdc4f9a73498987509bcb340165
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=91d84f3e333e3bdc4f9a73498987509bcb340165

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Sat Mar  6 09:02:34 2010 +0100

POSIX: Consolidate __pthread_cond_wait and __pthread_cond_timedwait

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 src/skins/posix/cond.c |   45 ++++++++++-----------------------------------
 1 files changed, 10 insertions(+), 35 deletions(-)

diff --git a/src/skins/posix/cond.c b/src/skins/posix/cond.c
index 0582367..1fd01b3 100644
--- a/src/skins/posix/cond.c
+++ b/src/skins/posix/cond.c
@@ -100,7 +100,8 @@ static void __pthread_cond_cleanup(void *data)
        } while (err == EINTR);
 }
 
-int __wrap_pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+static int __pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex,
+                              int timed, const struct timespec *abstime)
 {
        struct pse51_cond_cleanup_t c = {
                .cond = (union __xeno_cond *)cond,
@@ -118,7 +119,8 @@ int __wrap_pthread_cond_wait(pthread_cond_t *cond, 
pthread_mutex_t *mutex)
        err = -XENOMAI_SKINCALL5(__pse51_muxid,
                                 __pse51_cond_wait_prologue,
                                 &c.cond->shadow_cond,
-                                &c.mutex->shadow_mutex, &c.count, 0, NULL);
+                                &c.mutex->shadow_mutex, &c.count,
+                                timed, abstime);
 
        pthread_setcanceltype(oldtype, NULL);
 
@@ -138,43 +140,16 @@ int __wrap_pthread_cond_wait(pthread_cond_t *cond, 
pthread_mutex_t *mutex)
        return err;
 }
 
+int __wrap_pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+       return __pthread_cond_wait(cond, mutex, 0, NULL);
+}
+
 int __wrap_pthread_cond_timedwait(pthread_cond_t * cond,
                                  pthread_mutex_t * mutex,
                                  const struct timespec *abstime)
 {
-       struct pse51_cond_cleanup_t c = {
-               .cond = (union __xeno_cond *)cond,
-               .mutex = (union __xeno_mutex *)mutex,
-       };
-       int err, oldtype;
-
-       if (cb_try_read_lock(&c.mutex->shadow_mutex.lock, s))
-               return EINVAL;
-
-       pthread_cleanup_push(&__pthread_cond_cleanup, &c);
-
-       pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
-
-       err = -XENOMAI_SKINCALL5(__pse51_muxid,
-                                __pse51_cond_wait_prologue,
-                                &c.cond->shadow_cond,
-                                &c.mutex->shadow_mutex, &c.count, 1, abstime);
-       pthread_setcanceltype(oldtype, NULL);
-
-       pthread_cleanup_pop(0);
-
-       while (err == EINTR)
-               err = -XENOMAI_SKINCALL3(__pse51_muxid,
-                                        __pse51_cond_wait_epilogue,
-                                        &c.cond->shadow_cond,
-                                        &c.mutex->shadow_mutex,
-                                        c.count);
-
-       cb_read_unlock(&c.mutex->shadow_mutex.lock, s);
-
-       pthread_testcancel();
-
-       return err;
+       return __pthread_cond_wait(cond, mutex, 1, abstime);
 }
 
 int __wrap_pthread_cond_signal(pthread_cond_t * cond)


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to