Updated to fedora-glibc-20070731T1624
[glibc.git] / nptl / sysdeps / unix / sysv / linux / sh / sem_post.S
bloba63233feab3c8cc1d2ac74aa9f5e3962cd0860fb
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, 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 "lowlevel-atomic.h"
26 #define SYS_gettimeofday        __NR_gettimeofday
27 #define SYS_futex               240
28 #define FUTEX_WAIT              0
29 #define FUTEX_WAKE              1
31         .text
33         .globl  __new_sem_post
34         .type   __new_sem_post,@function
35         .align  5
36 __new_sem_post:
37         mov     #1, r3
38         XADD (r3, @(VALUE,r4), r2)
39         mov.l   @(NWAITERS,r4), r2
40         tst     r2, r2
41         bt      2f
42         mov     #FUTEX_WAKE, r5
43         mov.l   @(PRIVATE,r4), r1
44         or      r1, r5
45         mov     #1, r6
46         mov     #0, r7
47         mov     #SYS_futex, r3
48         extu.b  r3, r3
49         trapa   #0x14
50         SYSCALL_INST_PAD
52         cmp/pz  r0
53         bf      1f
55         rts
56          mov    #0, r0
59         mov     #EINVAL, r2
60         mova    .Lgot3, r0
61         mov.l   .Lgot3, r12
62         add     r0, r12
64 #if USE___THREAD
65         mov.l   .Lerrno3, r0
66         stc     gbr, r1
67         mov.l   @(r0, r12), r0
68         add     r1, r0
69 #else
70         mov.l   .Lerrloc3, r1
71         bsrf    r1
72          nop
73 .Lerrloc3b:
74 #endif
75         mov.l   r2, @r0
76         lds.l   @r15+, pr
77         mov.l   @r15+, r12
78         rts
79          mov    #-1, r0
81         .align  2
82 .Lgot3:
83         .long   _GLOBAL_OFFSET_TABLE_
84 #if USE___THREAD
85 .Lerrno3:
86         .long   errno@GOTTPOFF
87 #else
88 .Lerrloc3:
89         .long   __errno_location@PLT-(.Lerrloc3b-.)
90 #endif
91         .size   __new_sem_post,.-__new_sem_post
92         versioned_symbol(libpthread, __new_sem_post, sem_post, GLIBC_2_1)