or1k: syscall: Pass arguments on the stack
[uclibc-ng.git] / libpthread / nptl / sysdeps / unix / sysv / linux / sh / sem_wait.S
blobb8c25092aa1c94a09f5e05fcb6d7d471664128d7
1 /* Copyright (C) 2003, 2004, 2007 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, see
16    <http://www.gnu.org/licenses/>.  */
18 #include <sysdep.h>
19 #include <pthread-errnos.h>
20 #include <tcb-offsets.h>
21 #include <structsem.h>
22 #include <lowlevellock.h>
23 #include "lowlevel-atomic.h"
26 #if VALUE != 0
27 # error "code needs to be rewritten for VALUE != 0"
28 #endif
30         .text
32         .globl  sem_wait
33         .type   sem_wait,@function
34         .align  5
35 sem_wait:
36 .LSTARTCODE:
37         mov.l   r8, @-r15
38 .Lpush_r8:
39         mov.l   r10, @-r15
40 .Lpush_r10:
41         mov.l   r12, @-r15
42 .Lpush_r12:
43         sts.l   pr, @-r15
44 .Lpush_pr:
45         mov     r4, r8
47         mov.l   @r8, r0
49         tst     r0, r0
50         bt      1f
51         mov     r0, r3
52         mov     r0, r4
53         add     #-1, r3
54         CMPXCHG (r4, @r8, r3, r2)
55         bf/s    2b
56          mov    r2, r0
58         mov     #0, r0
60         lds.l   @r15+, pr
61         mov.l   @r15+, r12
62         mov.l   @r15+, r10
63         rts
64          mov.l  @r15+, r8
66 .Lafter_ret:
68         INC (@(NWAITERS,r8),r2)
70 .LcleanupSTART:
72         mov.l   .Lenable0, r1
73         bsrf    r1
74          nop
75 .Lenable0b:
76         mov     r0, r10
78         mov     r8, r4
79 #if FUTEX_WAIT == 0
80         mov.l   @(PRIVATE,r8), r5
81 #else
82         mov.l   @(PRIVATE,r8), r5
83         mov     #FUTEX_WAIT, r0
84         or      r0, r5
85 #endif
86         mov     #0, r6
87         mov     #0, r7
88         mov     #SYS_futex, r3
89         extu.b  r3, r3
90         trapa   #0x14
91         SYSCALL_INST_PAD
93         mov.l   .Ldisable0, r1
94         mov     r10, r4
95         bsrf    r1
96          mov    r0, r10
97 .Ldisable0b:
98         mov     r10, r0
99 .LcleanupEND:
101         tst     r0, r0
102         bt      3f
103         cmp/eq  #-EWOULDBLOCK, r0
104         bf      4f
107         mov.l   @r8, r0
109         tst     r0, r0
110         bt      6b
112         mov     r0, r3
113         mov     r0, r4
114         add     #-1, r3
115         CMPXCHG (r4, @r8, r3, r2)
116         bf/s    5b
117          mov    r2, r0
119         DEC (@(NWAITERS,r8), r2)
120         bra     7b
121          nop
124         neg     r0, r0
125         mov     r0, r4
126         DEC (@(NWAITERS,r8), r2)
127         mov     r4, r8
128         mova    .Lgot0, r0
129         mov.l   .Lgot0, r12
130         add     r0, r12
132 #if USE___THREAD
133         mov.l   .Lerrno0, r0
134         stc     gbr, r1
135         mov.l   @(r0, r12), r0
136         bra     .Lexit
137          add    r1, r0
138         .align  2
139 .Lerrno0:
140         .long   errno@GOTTPOFF
141 .Lexit:
142 #else
143         mov.l   .Lerrloc0, r1
144         bsrf    r1
145          nop
146 .Lerrloc0b:
147 #endif
148         mov.l   r8, @r0
149         bra     9b
150          mov    #-1, r0
152         .align  2
153 .Lgot0:
154         .long   _GLOBAL_OFFSET_TABLE_
155 #if !USE___THREAD
156 .Lerrloc0:
157         .long   __errno_location@PLT-(.Lerrloc0b-.)
158 #endif
159 .Lenable0:
160         .long   __pthread_enable_asynccancel-.Lenable0b
161 .Ldisable0:
162         .long   __pthread_disable_asynccancel-.Ldisable0b
163         .size   sem_wait,.-sem_wait
166         .type   sem_wait_cleanup,@function
167 sem_wait_cleanup:
168         DEC (@(NWAITERS,r8), r2)
169 .LcallUR:
170         mov.l   .Lresume, r1
171 #ifdef __PIC__
172         add     r12, r1
173 #endif
174         jsr     @r1
175          nop
176         sleep
178         .align  2
179 .Lresume:
180 #ifdef __PIC__
181         .long   _Unwind_Resume@GOTOFF
182 #else
183         .long   _Unwind_Resume
184 #endif
185 .LENDCODE:
186         .size   sem_wait_cleanup,.-sem_wait_cleanup
189         .section .gcc_except_table,"a",@progbits
190 .LexceptSTART:
191         .byte   0xff                            ! @LPStart format (omit)
192         .byte   0xff                            ! @TType format (omit)
193         .byte   0x01                            ! call-site format
194                                                 ! DW_EH_PE_uleb128
195         .uleb128 .Lcstend-.Lcstbegin
196 .Lcstbegin:
197         .uleb128 .LcleanupSTART-.LSTARTCODE
198         .uleb128 .LcleanupEND-.LcleanupSTART
199         .uleb128 sem_wait_cleanup-.LSTARTCODE
200         .uleb128  0
201         .uleb128 .LcallUR-.LSTARTCODE
202         .uleb128 .LENDCODE-.LcallUR
203         .uleb128 0
204         .uleb128  0
205 .Lcstend:
208         .section .eh_frame,"a",@progbits
209 .LSTARTFRAME:
210         .ualong .LENDCIE-.LSTARTCIE             ! Length of the CIE.
211 .LSTARTCIE:
212         .ualong 0                               ! CIE ID.
213         .byte   1                               ! Version number.
214 #ifdef SHARED
215         .string "zPLR"                          ! NUL-terminated augmentation
216                                                 ! string.
217 #else
218         .string "zPL"                           ! NUL-terminated augmentation
219                                                 ! string.
220 #endif
221         .uleb128 1                              ! Code alignment factor.
222         .sleb128 -4                             ! Data alignment factor.
223         .byte   0x11                            ! Return address register
224                                                 ! column.
225 #ifdef SHARED
226         .uleb128 7                              ! Augmentation value length.
227         .byte   0x9b                            ! Personality: DW_EH_PE_pcrel
228                                                 ! + DW_EH_PE_sdata4
229                                                 ! + DW_EH_PE_indirect
230         .ualong DW.ref.__gcc_personality_v0-.
231         .byte   0x1b                            ! LSDA Encoding: DW_EH_PE_pcrel
232                                                 ! + DW_EH_PE_sdata4.
233         .byte   0x1b                            ! FDE Encoding: DW_EH_PE_pcrel
234                                                 ! + DW_EH_PE_sdata4.
235 #else
236         .uleb128 6                              ! Augmentation value length.
237         .byte   0x0                             ! Personality: absolute
238         .ualong __gcc_personality_v0
239         .byte   0x0                             ! LSDA Encoding: absolute
240 #endif
241         .byte 0x0c                              ! DW_CFA_def_cfa
242         .uleb128 0xf
243         .uleb128 0
244         .align 4
245 .LENDCIE:
247         .ualong .LENDFDE-.LSTARTFDE             ! Length of the FDE.
248 .LSTARTFDE:
249         .ualong .LSTARTFDE-.LSTARTFRAME         ! CIE pointer.
250 #ifdef SHARED
251         .ualong .LSTARTCODE-.                   ! PC-relative start address
252                                                 ! of the code.
253 #else
254         .ualong .LSTARTCODE                     ! Start address of the code.
255 #endif
256         .ualong .LENDCODE-.LSTARTCODE           ! Length of the code.
257         .uleb128 4                              ! Augmentation size
258 #ifdef SHARED
259         .ualong .LexceptSTART-.
260 #else
261         .ualong .LexceptSTART
262 #endif
264         .byte   4                               ! DW_CFA_advance_loc4
265         .ualong .Lpush_r8-.LSTARTCODE
266         .byte   14                              ! DW_CFA_def_cfa_offset
267         .uleb128 4
268         .byte   0x88                            ! DW_CFA_offset r8
269         .uleb128 1
270         .byte   4                               ! DW_CFA_advance_loc4
271         .ualong .Lpush_r10-.Lpush_r8
272         .byte   14                              ! DW_CFA_def_cfa_offset
273         .uleb128 8
274         .byte   0x8a                            ! DW_CFA_offset r10
275         .uleb128 2
276         .byte   4                               ! DW_CFA_advance_loc4
277         .ualong .Lpush_r12-.Lpush_r10
278         .byte   14                              ! DW_CFA_def_cfa_offset
279         .uleb128 12
280         .byte   0x8c                            ! DW_CFA_offset r12
281         .uleb128 3
282         .byte   4                               ! DW_CFA_advance_loc4
283         .ualong .Lpush_pr-.Lpush_r12
284         .byte   14                              ! DW_CFA_def_cfa_offset
285         .uleb128 16
286         .byte   0x91                            ! DW_CFA_offset pr
287         .uleb128 4
288         .align  4
289 .LENDFDE:
292 #ifdef SHARED
293         .hidden DW.ref.__gcc_personality_v0
294         .weak   DW.ref.__gcc_personality_v0
295         .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
296         .align  4
297         .type   DW.ref.__gcc_personality_v0, @object
298         .size   DW.ref.__gcc_personality_v0, 4
299 DW.ref.__gcc_personality_v0:
300         .long   __gcc_personality_v0
301 #endif