Fix some uses of ret in libpthread
[glibc/nacl-glibc.git] / nptl / sysdeps / unix / sysv / linux / sh / sem_post.S
blob4a154fc6492016063182ef874d95f844e82403bf
1 /* Copyright (C) 2003, 2004, 2007, 2008 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
17    02111-1307 USA.  */
19 #include <sysdep.h>
20 #include <shlib-compat.h>
21 #include <pthread-errnos.h>
22 #include <structsem.h>
23 #include <lowlevellock.h>
24 #include "lowlevel-atomic.h"
27         .text
29         .globl  __new_sem_post
30         .type   __new_sem_post,@function
31         .align  5
32 __new_sem_post:
33         mov.l   @(VALUE,r4), r2
35         mov.l   .Lmax, r1
36         cmp/eq  r1, r2
37         bt/s    3f
38          mov    r2, r3
39         mov     r3, r5
40         add     #1, r5
41         CMPXCHG (r3, @(VALUE,r4), r5, r2)
42         bf      0b
43         mov.l   @(NWAITERS,r4), r2
44         tst     r2, r2
45         bt      2f
46         mov     #FUTEX_WAKE, r5
47         mov.l   @(PRIVATE,r4), r1
48         or      r1, r5
49         mov     #1, r6
50         mov     #0, r7
51         mov     #SYS_futex, r3
52         extu.b  r3, r3
53         trapa   #0x14
54         SYSCALL_INST_PAD
56         cmp/pz  r0
57         bf      1f
59         rts
60          mov    #0, r0
63         bra     4f
64          mov    #EINVAL, r2
67         mov     #EOVERFLOW, r2
68 4:      
69         mov.l   r12, @-r15
70         mov.l   r8, @-r15
71         sts.l   pr, @-r15
72         mova    .Lgot3, r0
73         mov.l   .Lgot3, r12
74         add     r0, r12
76 #if USE___THREAD
77         mov.l   .Lerrno3, r0
78         stc     gbr, r1
79         mov.l   @(r0, r12), r0
80         bra     .Lexit
81          add    r1, r0
82         .align  2
83 .Lerrno3:
84         .long   errno@GOTTPOFF
85 .Lexit:
86         mov.l   r2, @r0
87 #else
88         mov     r2, r8
89         mov.l   .Lerrloc3, r1
90         bsrf    r1
91          nop
92 .Lerrloc3b:
93         mov     r8, @r0
94 #endif
95         lds.l   @r15+, pr
96         mov.l   @r15+, r8
97         mov.l   @r15+, r12
98         rts
99          mov    #-1, r0
101         .align  2
102 .Lmax:
103         .long   SEM_VALUE_MAX
104 .Lgot3:
105         .long   _GLOBAL_OFFSET_TABLE_
106 #if !USE___THREAD
107 .Lerrloc3:
108         .long   __errno_location@PLT-(.Lerrloc3b-.)
109 #endif
110         .size   __new_sem_post,.-__new_sem_post
111         versioned_symbol(libpthread, __new_sem_post, sem_post, GLIBC_2_1)