~ubuntu-branches/ubuntu/quantal/uclibc/quantal

« back to all changes in this revision

Viewing changes to libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S

  • Committer: Bazaar Package Importer
  • Author(s): Hector Oron
  • Date: 2011-06-11 03:06:20 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110611030620-ywjfvyuqvrpsm282
Tags: 0.9.32-1
* New upstream release
* Add myself as maintainer
* Bump standards version 
* Add Vcs-Git, Vcs-Browser and Homepage fields
* Add watch file 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003, 2004, 2005, 2006, 2007
 
2
   Free Software Foundation, Inc.
 
3
   This file is part of the GNU C Library.
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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
 
18
   02111-1307 USA.  */
 
19
 
 
20
#include <sysdep.h>
 
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"
 
27
 
 
28
        .text
 
29
 
 
30
#define FUTEX_WAITERS           0x80000000
 
31
#define FUTEX_OWNER_DIED        0x40000000
 
32
 
 
33
#ifdef __ASSUME_PRIVATE_FUTEX
 
34
# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
 
35
        mov     #(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), tmp; \
 
36
        extu.b  tmp, tmp; \
 
37
        xor     tmp, reg
 
38
#else
 
39
# if FUTEX_WAIT == 0
 
40
#  define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
 
41
        stc     gbr, tmp        ; \
 
42
        mov.w   99f, tmp2       ; \
 
43
        add     tmp2, tmp       ; \
 
44
        mov.l   @tmp, tmp2      ; \
 
45
        bra     98f             ; \
 
46
         mov    #FUTEX_PRIVATE_FLAG, tmp ; \
 
47
99:     .word   PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
 
48
98:     extu.b  tmp, tmp        ; \
 
49
        xor     tmp, reg        ; \
 
50
        and     tmp2, reg
 
51
# else
 
52
#  define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
 
53
        stc     gbr, tmp        ; \
 
54
        mov.w   99f, tmp2       ; \
 
55
        add     tmp2, tmp       ; \
 
56
        mov.l   @tmp, tmp2      ; \
 
57
        bra     98f             ; \
 
58
         mov    #FUTEX_PRIVATE_FLAG, tmp ; \
 
59
99:     .word   PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
 
60
98:     extu.b  tmp, tmp        ; \
 
61
        xor     tmp, reg        ; \
 
62
        and     tmp2, reg       ; \
 
63
        mov     #FUTEX_WAIT, tmp ; \
 
64
        or      tmp, reg
 
65
# endif
 
66
#endif
 
67
 
 
68
        .globl  __lll_robust_lock_wait
 
69
        .type   __lll_robust_lock_wait,@function
 
70
        .hidden __lll_robust_lock_wait
 
71
        .align  5
 
72
        cfi_startproc
 
73
__lll_robust_lock_wait:
 
74
        mov.l   r8, @-r15
 
75
        cfi_adjust_cfa_offset(4)
 
76
        cfi_rel_offset (r8, 0)
 
77
        mov     r5, r8
 
78
        mov     #0, r7          /* No timeout.  */
 
79
        mov     r6, r5
 
80
        LOAD_FUTEX_WAIT (r5, r0, r1)
 
81
 
 
82
4:
 
83
        mov     r4, r6
 
84
        mov.l   .L_FUTEX_WAITERS, r0
 
85
        or      r0, r6
 
86
        shlr    r0              /* r0 = FUTEX_OWNER_DIED */
 
87
        tst     r0, r4
 
88
        bf/s    3f
 
89
         cmp/eq r4, r6
 
90
        bt      1f
 
91
 
 
92
        CMPXCHG (r4, @r8, r6, r2)
 
93
        bf      2f
 
94
 
 
95
1:
 
96
        mov     r8, r4
 
97
        mov     #SYS_futex, r3
 
98
        extu.b  r3, r3
 
99
        trapa   #0x14
 
100
        SYSCALL_INST_PAD
 
101
 
 
102
        mov.l   @r8, r2
 
103
 
 
104
2:
 
105
        tst     r2, r2
 
106
        bf/s    4b
 
107
         mov    r2, r4
 
108
 
 
109
        stc     gbr, r1
 
110
        mov.w   .Ltidoff, r2
 
111
        add     r2, r1
 
112
        mov.l   @r1, r6
 
113
        mov     #0, r3
 
114
        CMPXCHG (r3, @r8, r6, r4)
 
115
        bf      4b
 
116
        mov     #0, r4
 
117
 
 
118
3:
 
119
        mov.l   @r15+, r8
 
120
        ret
 
121
         mov    r4, r0
 
122
        cfi_endproc
 
123
        .align  2
 
124
.L_FUTEX_WAITERS:
 
125
        .long   FUTEX_WAITERS
 
126
.Ltidoff:
 
127
        .word   TID - TLS_PRE_TCB_SIZE
 
128
        .size   __lll_robust_lock_wait,.-__lll_robust_lock_wait
 
129
 
 
130
 
 
131
        .globl  __lll_robust_timedlock_wait
 
132
        .type   __lll_robust_timedlock_wait,@function
 
133
        .hidden __lll_robust_timedlock_wait
 
134
        .align  5
 
135
        cfi_startproc
 
136
__lll_robust_timedlock_wait:
 
137
        /* Check for a valid timeout value.  */
 
138
        mov.l   @(4,r6), r1
 
139
        mov.l   .L1g, r0
 
140
        cmp/hs  r0, r1
 
141
        bt      3f
 
142
 
 
143
        mov.l   r11, @-r15
 
144
        cfi_adjust_cfa_offset(4)
 
145
        cfi_rel_offset (r11, 0)
 
146
        mov.l   r10, @-r15
 
147
        cfi_adjust_cfa_offset(4)
 
148
        cfi_rel_offset (r10, 0)
 
149
        mov.l   r9, @-r15
 
150
        cfi_adjust_cfa_offset(4)
 
151
        cfi_rel_offset (r9, 0)
 
152
        mov.l   r8, @-r15
 
153
        cfi_adjust_cfa_offset(4)
 
154
        cfi_rel_offset (r8, 0)
 
155
        mov     r7, r11
 
156
        mov     r4, r10
 
157
        mov     r6, r9
 
158
        mov     r5, r8
 
159
 
 
160
        /* Stack frame for the timespec and timeval structs.  */
 
161
        add     #-8, r15
 
162
        cfi_adjust_cfa_offset(8)
 
163
 
 
164
1:
 
165
        /* Get current time.  */
 
166
        mov     r15, r4
 
167
        mov     #0, r5
 
168
        mov     #__NR_gettimeofday, r3
 
169
        trapa   #0x12
 
170
        SYSCALL_INST_PAD
 
171
 
 
172
        /* Compute relative timeout.  */
 
173
        mov.l   @(4,r15), r0
 
174
        mov.w   .L1k, r1
 
175
        dmulu.l r0, r1          /* Micro seconds to nano seconds.  */
 
176
        mov.l   @r9, r2
 
177
        mov.l   @(4,r9), r3
 
178
        mov.l   @r15, r0
 
179
        sts     macl, r1
 
180
        sub     r0, r2
 
181
        clrt
 
182
        subc    r1, r3
 
183
        bf      4f
 
184
        mov.l   .L1g, r1
 
185
        add     r1, r3
 
186
        add     #-1, r2
 
187
4:
 
188
        cmp/pz  r2
 
189
        bf      8f              /* Time is already up.  */
 
190
 
 
191
        mov.l   r2, @r15        /* Store relative timeout.  */
 
192
        mov.l   r3, @(4,r15)
 
193
 
 
194
        mov     r10, r6
 
195
        mov.l   .L_FUTEX_WAITERS2, r0
 
196
        or      r0, r6
 
197
        shlr    r0              /* r0 = FUTEX_OWNER_DIED */
 
198
        tst     r0, r4
 
199
        bf/s    6f
 
200
         cmp/eq r4, r6
 
201
        bt      2f
 
202
 
 
203
        CMPXCHG (r4, @r8, r6, r2)
 
204
        bf/s    5f
 
205
         mov    #0, r5
 
206
 
 
207
2:
 
208
        mov     r8, r4
 
209
        mov     r11, r5
 
210
        LOAD_FUTEX_WAIT (r5, r0, r1)
 
211
        mov     r10, r6
 
212
        mov     r15, r7
 
213
        mov     #SYS_futex, r3
 
214
        extu.b  r3, r3
 
215
        trapa   #0x14
 
216
        SYSCALL_INST_PAD
 
217
        mov     r0, r5
 
218
 
 
219
        mov.l   @r8, r2
 
220
 
 
221
5:
 
222
        tst     r2, r2
 
223
        bf/s    7f
 
224
         mov    r2, r10
 
225
 
 
226
        stc     gbr, r1
 
227
        mov.w   .Ltidoff2, r2
 
228
        add     r2, r1
 
229
        mov.l   @r1, r4
 
230
        mov     #0, r3
 
231
        CMPXCHG (r3, @r8, r4, r10)
 
232
        bf      7f
 
233
        mov     #0, r0
 
234
 
 
235
6:
 
236
        add     #8, r15
 
237
        mov.l   @r15+, r8
 
238
        mov.l   @r15+, r9
 
239
        mov.l   @r15+, r10
 
240
        rts
 
241
         mov.l  @r15+, r11
 
242
 
 
243
7:
 
244
        /* Check whether the time expired.  */
 
245
        mov     #-ETIMEDOUT, r1
 
246
        cmp/eq  r5, r1
 
247
        bf      1b
 
248
 
 
249
8:
 
250
        bra     6b
 
251
         mov    #ETIMEDOUT, r0
 
252
3:
 
253
        rts
 
254
         mov    #EINVAL, r0
 
255
        cfi_endproc
 
256
        .align  2
 
257
.L_FUTEX_WAITERS2:
 
258
        .long   FUTEX_WAITERS
 
259
.L1g:
 
260
        .long   1000000000
 
261
.Ltidoff2:
 
262
        .word   TID - TLS_PRE_TCB_SIZE
 
263
.L1k:
 
264
        .word   1000
 
265
        .size   __lll_robust_timedlock_wait,.-__lll_robust_timedlock_wait