Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread remove compatibility code for handling CLOCK_...



details:   https://anonhg.NetBSD.org/src/rev/fee64e34df0e
branches:  trunk
changeset: 793249:fee64e34df0e
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jan 31 20:44:01 2014 +0000

description:
remove compatibility code for handling CLOCK_MONOTONIC and handle it in the
syscall directly.

diffstat:

 lib/libpthread/pthread.c        |   7 ++++---
 lib/libpthread/pthread_compat.c |   9 +++++----
 lib/libpthread/pthread_cond.c   |  29 +++++------------------------
 lib/libpthread/pthread_mutex.c  |   8 ++++----
 4 files changed, 18 insertions(+), 35 deletions(-)

diffs (153 lines):

diff -r 1862e22c071d -r fee64e34df0e lib/libpthread/pthread.c
--- a/lib/libpthread/pthread.c  Fri Jan 31 19:38:48 2014 +0000
+++ b/lib/libpthread/pthread.c  Fri Jan 31 20:44:01 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread.c,v 1.143 2013/03/21 16:49:11 christos Exp $   */
+/*     $NetBSD: pthread.c,v 1.144 2014/01/31 20:44:01 christos Exp $   */
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread.c,v 1.143 2013/03/21 16:49:11 christos Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.144 2014/01/31 20:44:01 christos Exp $");
 
 #define        __EXPOSE_STACK  1
 
@@ -1177,7 +1177,8 @@
                 * If we deferred unparking a thread, arrange to
                 * have _lwp_park() restart it before blocking.
                 */
-               error = _lwp_park(abstime, self->pt_unpark, hint, hint);
+               error = _lwp_park(CLOCK_REALTIME, TIMER_ABSTIME, abstime,
+                   self->pt_unpark, hint, hint);
                self->pt_unpark = 0;
                if (error != 0) {
                        switch (rv = errno) {
diff -r 1862e22c071d -r fee64e34df0e lib/libpthread/pthread_compat.c
--- a/lib/libpthread/pthread_compat.c   Fri Jan 31 19:38:48 2014 +0000
+++ b/lib/libpthread/pthread_compat.c   Fri Jan 31 20:44:01 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_compat.c,v 1.2 2008/10/08 08:27:07 ad Exp $    */
+/*     $NetBSD: pthread_compat.c,v 1.3 2014/01/31 20:44:01 christos Exp $      */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_compat.c,v 1.2 2008/10/08 08:27:07 ad Exp $");
+__RCSID("$NetBSD: pthread_compat.c,v 1.3 2014/01/31 20:44:01 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/syscall.h>
@@ -85,10 +85,11 @@
 }
 
 int
-_lwp_park(const struct timespec *a, lwpid_t b, const void *c, const void *d)
+_lwp_park(clockid_t a, int b, const struct timespec *c, lwpid_t d,
+    const void *e, const void *f)
 {
 
-       return syscall(SYS__lwp_park, a, b, c, d);
+       return syscall(SYS____lwp_park60, a, b, c, d, e, f);
 }
 
 int
diff -r 1862e22c071d -r fee64e34df0e lib/libpthread/pthread_cond.c
--- a/lib/libpthread/pthread_cond.c     Fri Jan 31 19:38:48 2014 +0000
+++ b/lib/libpthread/pthread_cond.c     Fri Jan 31 20:44:01 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_cond.c,v 1.62 2014/01/31 19:22:00 christos Exp $       */
+/*     $NetBSD: pthread_cond.c,v 1.63 2014/01/31 20:44:01 christos Exp $       */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_cond.c,v 1.62 2014/01/31 19:22:00 christos Exp $");
+__RCSID("$NetBSD: pthread_cond.c,v 1.63 2014/01/31 20:44:01 christos Exp $");
 
 #include <stdlib.h>
 #include <errno.h>
@@ -131,7 +131,7 @@
 {
        pthread_t self;
        int retval;
-       struct timespec mono;
+       clockid_t clkid = pthread_cond_getclock(cond);
 
        if (__predict_false(__uselibcstub))
                return __libc_cond_timedwait_stub(cond, mutex, abstime);
@@ -142,25 +142,6 @@
            mutex->ptm_magic == _PT_MUTEX_MAGIC);
        pthread__error(EPERM, "Mutex not locked in condition wait",
            mutex->ptm_owner != NULL);
-       if (abstime != NULL) {
-               /*
-                * XXX: This should be done in the kernel to avoid
-                * extra system calls! 
-                */
-               if (pthread_cond_getclock(cond) == CLOCK_MONOTONIC) {
-                       struct timespec real;
-                       if (clock_gettime(CLOCK_REALTIME, &real) == -1 ||
-                           clock_gettime(CLOCK_MONOTONIC, &mono) == -1)
-                               return errno;
-                       timespecsub(abstime, &mono, &mono);
-                       timespecadd(&mono, &real, &mono);
-                       abstime = &mono;
-               }
-               pthread__error(EINVAL, "Invalid wait time", 
-                   (abstime->tv_sec >= 0) &&
-                   (abstime->tv_nsec >= 0) &&
-                   (abstime->tv_nsec < 1000000000));
-       }
 
        self = pthread__self();
 
@@ -185,8 +166,8 @@
                self->pt_willpark = 0;
                self->pt_blocking++;
                do {
-                       retval = _lwp_park(abstime, self->pt_unpark,
-                           __UNVOLATILE(&mutex->ptm_waiters),
+                       retval = _lwp_park(clkid, TIMER_ABSTIME, abstime,
+                           self->pt_unpark, __UNVOLATILE(&mutex->ptm_waiters),
                            __UNVOLATILE(&mutex->ptm_waiters));
                        self->pt_unpark = 0;
                } while (retval == -1 && errno == ESRCH);
diff -r 1862e22c071d -r fee64e34df0e lib/libpthread/pthread_mutex.c
--- a/lib/libpthread/pthread_mutex.c    Fri Jan 31 19:38:48 2014 +0000
+++ b/lib/libpthread/pthread_mutex.c    Fri Jan 31 20:44:01 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_mutex.c,v 1.57 2014/01/31 19:22:00 christos Exp $      */
+/*     $NetBSD: pthread_mutex.c,v 1.58 2014/01/31 20:44:01 christos Exp $      */
 
 /*-
  * Copyright (c) 2001, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_mutex.c,v 1.57 2014/01/31 19:22:00 christos Exp $");
+__RCSID("$NetBSD: pthread_mutex.c,v 1.58 2014/01/31 20:44:01 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/lwpctl.h>
@@ -330,8 +330,8 @@
                 */
                while (self->pt_mutexwait) {
                        self->pt_blocking++;
-                       (void)_lwp_park(NULL, self->pt_unpark,
-                           __UNVOLATILE(&ptm->ptm_waiters),
+                       (void)_lwp_park(CLOCK_REALTIME, TIMER_ABSTIME, NULL,
+                           self->pt_unpark, __UNVOLATILE(&ptm->ptm_waiters),
                            __UNVOLATILE(&ptm->ptm_waiters));
                        self->pt_unpark = 0;
                        self->pt_blocking--;



Home | Main Index | Thread Index | Old Index