]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / libpthread / nptl / sysdeps / unix / sysv / linux / sh / sem_post.S
1 /* Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
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.
8
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.
13
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/>.  */
17
18 #include <sysdep.h>
19 #include <pthread-errnos.h>
20 #include <structsem.h>
21 #include <lowlevellock.h>
22 #include "lowlevel-atomic.h"
23
24
25         .text
26
27         .globl  sem_post
28         .type   sem_post,@function
29         .align  5
30 sem_post:
31         mov.l   @(VALUE,r4), r2
32 0:
33         mov.l   .Lmax, r1
34         cmp/eq  r1, r2
35         bt/s    3f
36          mov    r2, r3
37         mov     r3, r5
38         add     #1, r5
39         CMPXCHG (r3, @(VALUE,r4), r5, r2)
40         bf      0b
41         mov.l   @(NWAITERS,r4), r2
42         tst     r2, r2
43         bt      2f
44         mov     #FUTEX_WAKE, r5
45         mov.l   @(PRIVATE,r4), r1
46         or      r1, r5
47         mov     #1, r6
48         mov     #0, r7
49         mov     #SYS_futex, r3
50         extu.b  r3, r3
51         trapa   #0x14
52         SYSCALL_INST_PAD
53
54         cmp/pz  r0
55         bf      1f
56 2:
57         rts
58          mov    #0, r0
59
60 1:
61         bra     4f
62          mov    #EINVAL, r2
63
64 3:
65         mov     #EOVERFLOW, r2
66 4:
67         mov.l   r12, @-r15
68         mov.l   r8, @-r15
69         sts.l   pr, @-r15
70         mova    .Lgot3, r0
71         mov.l   .Lgot3, r12
72         add     r0, r12
73
74 #if USE___THREAD
75         mov.l   .Lerrno3, r0
76         stc     gbr, r1
77         mov.l   @(r0, r12), r0
78         bra     .Lexit
79          add    r1, r0
80         .align  2
81 .Lerrno3:
82         .long   errno@GOTTPOFF
83 .Lexit:
84         mov.l   r2, @r0
85 #else
86         mov     r2, r8
87         mov.l   .Lerrloc3, r1
88         bsrf    r1
89          nop
90 .Lerrloc3b:
91         mov     r8, @r0
92 #endif
93         lds.l   @r15+, pr
94         mov.l   @r15+, r8
95         mov.l   @r15+, r12
96         rts
97          mov    #-1, r0
98
99         .align  2
100 .Lmax:
101         .long   SEM_VALUE_MAX
102 .Lgot3:
103         .long   _GLOBAL_OFFSET_TABLE_
104 #if !USE___THREAD
105 .Lerrloc3:
106         .long   __errno_location@PLT-(.Lerrloc3b-.)
107 #endif
108         .size   sem_post,.-sem_post