1 /* Copyright (C) 2002 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 #define SYS_gettimeofday __NR_gettimeofday
29 #define EWOULDBLOCK 11
34 .globl __lll_mutex_lock_wait
35 .type __lll_mutex_lock_wait,@function
36 .hidden __lll_mutex_lock_wait
38 __lll_mutex_lock_wait:
44 xorl %esi, %esi /* No timeout. */
45 xorl %ecx, %ecx /* movl $FUTEX_WAIT, %ecx */
47 leal 1(%eax), %edx /* account for the preceeded xadd. */
53 cmpl $0, %gs:MULTIPLE_THREADS_OFFSET
68 .size __lll_mutex_lock_wait,.-__lll_mutex_lock_wait
71 .globl __lll_mutex_timedlock_wait
72 .type __lll_mutex_timedlock_wait,@function
73 .hidden __lll_mutex_timedlock_wait
75 __lll_mutex_timedlock_wait:
76 /* Check for a valid timeout value. */
77 cmpl $1000000000, 4(%edx)
85 /* Stack frame for the timespec and timeval structs. */
92 /* Get current time. */
96 movl $SYS_gettimeofday, %eax
99 /* Compute relative timeout. */
102 mul %edx /* Milli seconds to nano seconds. */
108 addl $1000000000, %edx
111 js 5f /* Time is already up. */
114 movl %ecx, (%esp) /* Store relative timeout. */
118 xorl %ecx, %ecx /* movl $FUTEX_WAIT, %ecx */
120 movl $SYS_futex, %eax
125 cmpl $0, %gs:MULTIPLE_THREADS_OFFSET
144 /* Check whether the time expired. */
145 7: cmpl $-ETIMEDOUT, %eax
149 3: movl $EINVAL, %eax
152 5: movl $ETIMEDOUT, %eax
154 .size __lll_mutex_timedlock_wait,.-__lll_mutex_timedlock_wait
157 .globl __lll_mutex_unlock_wake
158 .type __lll_mutex_unlock_wake,@function
159 .hidden __lll_mutex_unlock_wake
161 __lll_mutex_unlock_wake:
167 movl $FUTEX_WAKE, %ecx
171 movl $1, %edx /* Wake one thread. */
172 movl $SYS_futex, %eax
180 .size __lll_mutex_unlock_wake,.-__lll_mutex_unlock_wake