1 /* Copyright (C) 2003, 2004, 2005, 2006 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 <pthread-errnos.h>
21 #include <lowlevelrobustlock.h>
22 #include "lowlevel-atomic.h"
26 #define SYS_gettimeofday __NR_gettimeofday
30 #define FUTEX_WAITERS 0x80000000
31 #define FUTEX_OWNER_DIED 0x40000000
34 .globl __lll_robust_mutex_lock_wait
35 .type __lll_robust_mutex_lock_wait,@function
36 .hidden __lll_robust_mutex_lock_wait
39 __lll_robust_mutex_lock_wait:
41 cfi_adjust_cfa_offset(4)
42 cfi_rel_offset (r8, 0)
44 mov #0, r7 /* No timeout. */
49 mov.l .L_FUTEX_WAITERS, r0
51 shlr r0 /* r0 = FUTEX_OWNER_DIED */
57 CMPXCHG (r4, @r8, r6, r2)
79 CMPXCHG (r3, @r8, r6, r4)
92 .word TID - TLS_PRE_TCB_SIZE
93 .size __lll_robust_mutex_lock_wait,.-__lll_robust_mutex_lock_wait
96 .globl __lll_robust_mutex_timedlock_wait
97 .type __lll_robust_mutex_timedlock_wait,@function
98 .hidden __lll_robust_mutex_timedlock_wait
101 __lll_robust_mutex_timedlock_wait:
102 /* Check for a valid timeout value. */
109 cfi_adjust_cfa_offset(4)
110 cfi_rel_offset (r10, 0)
112 cfi_adjust_cfa_offset(4)
113 cfi_rel_offset (r9, 0)
115 cfi_adjust_cfa_offset(4)
116 cfi_rel_offset (r8, 0)
121 /* Stack frame for the timespec and timeval structs. */
123 cfi_adjust_cfa_offset(8)
126 /* Get current time. */
129 mov #SYS_gettimeofday, r3
133 /* Compute relative timeout. */
136 dmulu.l r0, r1 /* Micro seconds to nano seconds. */
150 bf 8f /* Time is already up. */
152 mov.l r2, @r15 /* Store relative timeout. */
156 mov.l .L_FUTEX_WAITERS2, r0
158 shlr r0 /* r0 = FUTEX_OWNER_DIED */
164 CMPXCHG (r4, @r8, r6, r2)
191 CMPXCHG (r3, @r8, r4, r10)
203 /* Check whether the time expired. */
221 .word TID - TLS_PRE_TCB_SIZE
224 .size __lll_robust_mutex_timedlock_wait,.-__lll_robust_mutex_timedlock_wait