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