1
/* Copyright (C) 2003, 2004, 2005, 2006, 2007
2
Free Software Foundation, Inc.
3
This file is part of the GNU C Library.
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
21
#include <pthread-errnos.h>
22
#include <lowlevellock.h>
23
#include <lowlevelrobustlock.h>
24
#include <bits/kernel-features.h>
25
#include <tcb-offsets.h>
26
#include "lowlevel-atomic.h"
30
#define FUTEX_WAITERS 0x80000000
31
#define FUTEX_OWNER_DIED 0x40000000
33
#ifdef __ASSUME_PRIVATE_FUTEX
34
# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
35
mov #(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), tmp; \
40
# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
46
mov #FUTEX_PRIVATE_FLAG, tmp ; \
47
99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
48
98: extu.b tmp, tmp ; \
52
# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
58
mov #FUTEX_PRIVATE_FLAG, tmp ; \
59
99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
60
98: extu.b tmp, tmp ; \
63
mov #FUTEX_WAIT, tmp ; \
68
.globl __lll_robust_lock_wait
69
.type __lll_robust_lock_wait,@function
70
.hidden __lll_robust_lock_wait
73
__lll_robust_lock_wait:
75
cfi_adjust_cfa_offset(4)
76
cfi_rel_offset (r8, 0)
78
mov #0, r7 /* No timeout. */
80
LOAD_FUTEX_WAIT (r5, r0, r1)
84
mov.l .L_FUTEX_WAITERS, r0
86
shlr r0 /* r0 = FUTEX_OWNER_DIED */
92
CMPXCHG (r4, @r8, r6, r2)
114
CMPXCHG (r3, @r8, r6, r4)
127
.word TID - TLS_PRE_TCB_SIZE
128
.size __lll_robust_lock_wait,.-__lll_robust_lock_wait
131
.globl __lll_robust_timedlock_wait
132
.type __lll_robust_timedlock_wait,@function
133
.hidden __lll_robust_timedlock_wait
136
__lll_robust_timedlock_wait:
137
/* Check for a valid timeout value. */
144
cfi_adjust_cfa_offset(4)
145
cfi_rel_offset (r11, 0)
147
cfi_adjust_cfa_offset(4)
148
cfi_rel_offset (r10, 0)
150
cfi_adjust_cfa_offset(4)
151
cfi_rel_offset (r9, 0)
153
cfi_adjust_cfa_offset(4)
154
cfi_rel_offset (r8, 0)
160
/* Stack frame for the timespec and timeval structs. */
162
cfi_adjust_cfa_offset(8)
165
/* Get current time. */
168
mov #__NR_gettimeofday, r3
172
/* Compute relative timeout. */
175
dmulu.l r0, r1 /* Micro seconds to nano seconds. */
189
bf 8f /* Time is already up. */
191
mov.l r2, @r15 /* Store relative timeout. */
195
mov.l .L_FUTEX_WAITERS2, r0
197
shlr r0 /* r0 = FUTEX_OWNER_DIED */
203
CMPXCHG (r4, @r8, r6, r2)
210
LOAD_FUTEX_WAIT (r5, r0, r1)
231
CMPXCHG (r3, @r8, r4, r10)
244
/* Check whether the time expired. */
262
.word TID - TLS_PRE_TCB_SIZE
265
.size __lll_robust_timedlock_wait,.-__lll_robust_timedlock_wait