From: Ulrich Drepper Date: Fri, 13 Feb 2004 08:32:43 +0000 (+0000) Subject: Update. X-Git-Tag: upstream/2.30~18294 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=219304ecbbb8dab55a788dd3bbb31b3ce01d88a9;p=external%2Fglibc.git Update. * 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. --- diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 351ff05..c37d8a3ad 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,5 +1,9 @@ 2004-02-13 Ulrich Drepper + * 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 - * init.c (pthread_funtions): Make array const. + * init.c (pthread_functions): Make array const. 2004-01-13 Ulrich Drepper diff --git a/nptl/sysdeps/pthread/pthread_cond_timedwait.c b/nptl/sysdeps/pthread/pthread_cond_timedwait.c index 9fa2920..71e9cf7 100644 --- a/nptl/sysdeps/pthread/pthread_cond_timedwait.c +++ b/nptl/sysdeps/pthread/pthread_cond_timedwait.c @@ -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 , 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;