]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_post.S
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / nptl / sysdeps / unix / sysv / linux / i386 / i486 / sem_post.S
1 /* Copyright (C) 2002, 2003, 2005, 2007, 2008 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18
19 #include <sysdep.h>
20 #include <pthread-errnos.h>
21 #include <structsem.h>
22 #include <lowlevellock.h>
23
24
25         .text
26
27         .globl  sem_post
28         .type   sem_post,@function
29         .align  16
30 sem_post:
31         cfi_startproc
32         pushl   %ebx
33         cfi_adjust_cfa_offset(4)
34         cfi_offset(%ebx, -8)
35
36         movl    8(%esp), %ebx
37
38 #if VALUE == 0
39         movl    (%ebx), %eax
40 #else
41         movl    VALUE(%ebx), %eax
42 #endif
43 0:      cmpl    $SEM_VALUE_MAX, %eax
44         je      3f
45         leal    1(%eax), %edx
46         LOCK
47 #if VALUE == 0
48         cmpxchgl %edx, (%ebx)
49 #else
50         cmpxchgl %edx, VALUE(%ebx)
51 #endif
52         jnz     0b
53
54         cmpl    $0, NWAITERS(%ebx)
55         je      2f
56
57         movl    $FUTEX_WAKE, %ecx
58         orl     PRIVATE(%ebx), %ecx
59         movl    $1, %edx
60         movl    $SYS_futex, %eax
61         ENTER_KERNEL
62
63         testl   %eax, %eax
64         js      1f
65
66 2:      xorl    %eax, %eax
67         popl    %ebx
68         cfi_adjust_cfa_offset(-4)
69         cfi_restore(%ebx)
70         ret
71
72         cfi_adjust_cfa_offset(4)
73         cfi_offset(%ebx, -8)
74 1:
75 #ifdef __PIC__
76         call    __x86.get_pc_thunk.bx
77 #else
78         movl    $4f, %ebx
79 4:
80 #endif
81         addl    $_GLOBAL_OFFSET_TABLE_, %ebx
82 #if USE___THREAD
83 # ifdef NO_TLS_DIRECT_SEG_REFS
84         movl    errno@gotntpoff(%ebx), %edx
85         addl    %gs:0, %edx
86         movl    $EINVAL, (%edx)
87 # else
88         movl    errno@gotntpoff(%ebx), %edx
89         movl    $EINVAL, %gs:(%edx)
90 # endif
91 #else
92         call    __errno_location@plt
93         movl    $EINVAL, (%eax)
94 #endif
95
96         orl     $-1, %eax
97         popl    %ebx
98         ret
99
100 3:
101 #ifdef __PIC__
102         call    __x86.get_pc_thunk.bx
103 #else
104         movl    $5f, %ebx
105 5:
106 #endif
107         addl    $_GLOBAL_OFFSET_TABLE_, %ebx
108 #if USE___THREAD
109 # ifdef NO_TLS_DIRECT_SEG_REFS
110         movl    errno@gotntpoff(%ebx), %edx
111         addl    %gs:0, %edx
112         movl    $EOVERFLOW, (%edx)
113 # else
114         movl    errno@gotntpoff(%ebx), %edx
115         movl    $EOVERFLOW, %gs:(%edx)
116 # endif
117 #else
118         call    __errno_location@plt
119         movl    $EOVERFLOW, (%eax)
120 #endif
121
122         orl     $-1, %eax
123         popl    %ebx
124         cfi_adjust_cfa_offset(-4)
125         cfi_restore(%ebx)
126         ret
127         cfi_endproc
128         .size   sem_post,.-sem_post
129
130 #ifdef __PIC__
131         .section .gnu.linkonce.t.__x86.get_pc_thunk.bx,"ax",@progbits
132         .globl  __x86.get_pc_thunk.bx
133         .hidden __x86.get_pc_thunk.bx
134         .type   __x86.get_pc_thunk.bx,@function
135 __x86.get_pc_thunk.bx:
136         movl (%esp), %ebx;
137         ret
138         .size   __x86.get_pc_thunk.bx,.-__x86.get_pc_thunk.bx
139 #endif