1 /* Copyright (C) 2003, 2004, 2005 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 "lowlevel-atomic.h"
25 #define SYS_gettimeofday __NR_gettimeofday
31 .globl __lll_mutex_lock_wait
32 .type __lll_mutex_lock_wait,@function
33 .hidden __lll_mutex_lock_wait
36 __lll_mutex_lock_wait:
38 cfi_adjust_cfa_offset(4)
39 cfi_rel_offset (r8, 0)
42 mov #0, r7 /* No timeout. */
66 .size __lll_mutex_lock_wait,.-__lll_mutex_lock_wait
70 .globl __lll_mutex_timedlock_wait
71 .type __lll_mutex_timedlock_wait,@function
72 .hidden __lll_mutex_timedlock_wait
75 __lll_mutex_timedlock_wait:
76 /* Check for a valid timeout value. */
83 cfi_adjust_cfa_offset(4)
84 cfi_rel_offset (r10, 0)
86 cfi_adjust_cfa_offset(4)
87 cfi_rel_offset (r9, 0)
89 cfi_adjust_cfa_offset(4)
90 cfi_rel_offset (r8, 0)
95 /* Stack frame for the timespec and timeval structs. */
97 cfi_adjust_cfa_offset(8)
100 /* Get current time. */
103 mov #SYS_gettimeofday, r3
107 /* Compute relative timeout. */
110 dmulu.l r0, r1 /* Micro seconds to nano seconds. */
124 bf 5f /* Time is already up. */
126 mov.l r2, @r15 /* Store relative timeout. */
131 CMPXCHG (r3, @r8, r4, r2)
148 CMPXCHG (r3, @r8, r4, r2)
159 /* Check whether the time expired. */
164 /* Make sure the current holder knows we are going to sleep. */
185 .size __lll_mutex_timedlock_wait,.-__lll_mutex_timedlock_wait
190 .globl lll_unlock_wake_cb
191 .type lll_unlock_wake_cb,@function
192 .hidden lll_unlock_wake_cb
201 mov #1, r6 /* Wake one thread. */
203 mov.l r7, @r4 /* Stores 0. */
213 .size lll_unlock_wake_cb,.-lll_unlock_wake_cb
217 .globl __lll_mutex_unlock_wake
218 .type __lll_mutex_unlock_wake,@function
219 .hidden __lll_mutex_unlock_wake
222 __lll_mutex_unlock_wake:
224 mov #1, r6 /* Wake one thread. */
226 mov.l r7, @r4 /* Stores 0. */
234 .size __lll_mutex_unlock_wake,.-__lll_mutex_unlock_wake
238 .globl __lll_timedwait_tid
239 .type __lll_timedwait_tid,@function
240 .hidden __lll_timedwait_tid
245 cfi_adjust_cfa_offset(4)
246 cfi_rel_offset (r9, 0)
248 cfi_adjust_cfa_offset(4)
249 cfi_rel_offset (r8, 0)
253 /* Stack frame for the timespec and timeval structs. */
255 cfi_adjust_cfa_offset(8)
258 /* Get current time. */
261 mov #SYS_gettimeofday, r3
265 /* Compute relative timeout. */
268 dmulu.l r0, r1 /* Micro seconds to nano seconds. */
282 bf 6f /* Time is already up. */
284 mov.l r2, @r15 /* Store relative timeout. */
311 /* Check whether the time expired. */
325 .size __lll_timedwait_tid,.-__lll_timedwait_tid