Update.
authorUlrich Drepper <drepper@redhat.com>
Fri, 13 Feb 2004 08:32:43 +0000 (08:32 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 13 Feb 2004 08:32:43 +0000 (08:32 +0000)
* sysdeps/pthread/pthread_cond_timedwait.c
(__pthread_cond_timedwait): Optimize.  Drop internal lock earlier.
Reuse code.  Add __builtin_expects.

* init.c (pthread_functions): Make array const.

nptl/ChangeLog
nptl/sysdeps/pthread/pthread_cond_timedwait.c

index 351ff05..c37d8a3 100644 (file)
@@ -1,5 +1,9 @@
 2004-02-13  Ulrich Drepper  <drepper@redhat.com>
 
+       * sysdeps/pthread/pthread_cond_timedwait.c
+       (__pthread_cond_timedwait): Optimize.  Drop internal lock earlier.
+       Reuse code.  Add __builtin_expects.
+
        * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
        (__pthread_cond_timedwait): Get internal lock in case timeout has
        passed before the futex syscall.
@@ -35,7 +39,7 @@
 
 2004-01-14  Ulrich Drepper  <drepper@redhat.com>
 
-       * init.c (pthread_funtions): Make array const.
+       * init.c (pthread_functions): Make array const.
 
 2004-01-13  Ulrich Drepper  <drepper@redhat.com>
 
index 9fa2920..71e9cf7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
 
@@ -98,6 +98,9 @@ __pthread_cond_timedwait (cond, mutex, abstime)
 
   while (1)
     {
+      /* Prepare to wait.  Release the condvar futex.  */
+      lll_mutex_unlock (cond->__data.__lock);
+
       struct timespec rt;
       {
 #ifdef __NR_clock_gettime
@@ -138,19 +141,14 @@ __pthread_cond_timedwait (cond, mutex, abstime)
          --rt.tv_sec;
        }
       /* Did we already time out?  */
-      if (rt.tv_sec < 0)
+      if (__builtin_expect (rt.tv_sec < 0, 0))
        {
-         /* Yep.  Adjust the sequence counter.  */
-         ++cond->__data.__wakeup_seq;
+         /* We are going to look at shared data again, so get the lock.  */
+         lll_mutex_lock(cond->__data.__lock);
 
-         /* The error value.  */
-         result = ETIMEDOUT;
-         break;
+         goto timeout;
        }
 
-      /* Prepare to wait.  Release the condvar futex.  */
-      lll_mutex_unlock (cond->__data.__lock);
-
       /* Enable asynchronous cancellation.  Required by the standard.  */
       cbuffer.oldtype = __pthread_enable_asynccancel ();
 
@@ -170,8 +168,9 @@ __pthread_cond_timedwait (cond, mutex, abstime)
        break;
 
       /* Not woken yet.  Maybe the time expired?  */
-      if (err == -ETIMEDOUT)
+      if (__builtin_expect (err == -ETIMEDOUT, 0))
        {
+       timeout:
          /* Yep.  Adjust the counters.  */
          ++cond->__data.__wakeup_seq;