1 /* Copyright (C) 2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 #include <shlib-compat.h>
21 #include <lowlevelcond.h>
22 #include "lowlevel-atomic.h"
24 #define SYS_gettimeofday __NR_gettimeofday
34 /* int pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
35 const struct timespec *abstime) */
36 .globl __pthread_cond_timedwait
37 .type __pthread_cond_timedwait, @function
39 __pthread_cond_timedwait:
50 /* Get internal lock. */
53 XADD (r3, @(cond_lock,r8), r2)
62 /* Unlock the mutex. */
72 mov.l @(total_seq,r8),r0
73 mov.l @(total_seq+4,r8),r1
76 mov.l r0,@(total_seq,r8)
77 mov.l r1,@(total_seq+4,r8)
79 /* Install cancellation handler. */
97 /* Get and store current wakeup_seq value. */
98 mov.l @(wakeup_seq,r8), r0
99 mov.l @(wakeup_seq+4,r8), r1
106 DEC (@(cond_lock,r8), r2)
121 /* Get current time. */
125 mov #SYS_gettimeofday, r3
129 /* Compute relative timeout. */
132 dmulu.l r0, r1 /* Milli seconds to nano seconds. */
146 bf 13f /* Time is already up. */
148 /* Store relative timeout. */
172 XADD (r3, @(cond_lock,r8), r2)
179 mov.l @(woken_seq,r8), r0
180 mov.l @(woken_seq+4,r8), r1
182 mov.l @(wakeup_seq,r8), r2
183 mov.l @(wakeup_seq+4,r8), r3
203 cmp/eq #-ETIMEDOUT, r0
210 mov.l @(wakeup_seq,r8),r0
211 mov.l @(wakeup_seq+4,r8),r1
214 mov.l r0,@(wakeup_seq,r8)
215 mov.l r1,@(wakeup_seq+4,r8)
228 mov.l @(woken_seq,r8),r0
229 mov.l @(woken_seq+4,r8),r1
232 mov.l r0,@(woken_seq,r8)
233 mov.l r1,@(woken_seq+4,r8)
236 DEC (@(cond_lock,r8), r2)
244 /* Remove cancellation handler. */
262 /* We return the result of the mutex_lock operation. */
275 .long __pthread_mutex_unlock_internal-.Lmunlock1b
278 .long _GLOBAL_OFFSET_TABLE_
280 .long __condvar_cleanup@GOTOFF
283 .long __condvar_cleanup
286 .long __pthread_cleanup_push-.Lccpush1b
288 .long __pthread_enable_asynccancel-.Lenable1b
290 .long __pthread_disable_asynccancel-.Ldisable1b
292 .long __pthread_cleanup_pop-.Lcpop1b
294 .long __pthread_mutex_lock_internal-.Lmlocki1b
299 /* Initial locking failed. */
312 /* Unlock in loop requires waekup. */
325 /* Locking in loop failed. */
338 /* Unlock after loop requires waekup. */
352 .long __lll_mutex_lock_wait-.Lmwait2b
354 .long __lll_mutex_unlock_wake-.Lmwake2b
356 .long __lll_mutex_lock_wait-.Lmwait3b
358 .long __lll_mutex_unlock_wake-.Lmwake3b
359 .size __pthread_cond_timedwait, .-__pthread_cond_timedwait
360 versioned_symbol (libpthread, __pthread_cond_timedwait, pthread_cond_timedwait,