Replace FSF snail mail address with URLs.
[glibc.git] / nptl / sysdeps / unix / sysv / linux / i386 / i486 / sem_post.S
blob0b8181584a4ed795ad09f02f0556d2ac3e9a6f51
1 /* Copyright (C) 2002,2003,2005,2007,2008,2011-2012
2    Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, see
18    <http://www.gnu.org/licenses/>.  */
20 #include <sysdep.h>
21 #include <shlib-compat.h>
22 #include <pthread-errnos.h>
23 #include <structsem.h>
24 #include <lowlevellock.h>
27         .text
29         .globl  __new_sem_post
30         .type   __new_sem_post,@function
31         .align  16
32 __new_sem_post:
33         cfi_startproc
34         pushl   %ebx
35         cfi_adjust_cfa_offset(4)
36         cfi_offset(%ebx, -8)
38         movl    8(%esp), %ebx
40 #if VALUE == 0
41         movl    (%ebx), %eax
42 #else
43         movl    VALUE(%ebx), %eax
44 #endif
45 0:      cmpl    $SEM_VALUE_MAX, %eax
46         je      3f
47         leal    1(%eax), %edx
48         LOCK
49 #if VALUE == 0
50         cmpxchgl %edx, (%ebx)
51 #else
52         cmpxchgl %edx, VALUE(%ebx)
53 #endif
54         jnz     0b
56         cmpl    $0, NWAITERS(%ebx)
57         je      2f
59         movl    $FUTEX_WAKE, %ecx
60         orl     PRIVATE(%ebx), %ecx
61         movl    $1, %edx
62         movl    $SYS_futex, %eax
63         ENTER_KERNEL
65         testl   %eax, %eax
66         js      1f
68 2:      xorl    %eax, %eax
69         popl    %ebx
70         cfi_adjust_cfa_offset(-4)
71         cfi_restore(%ebx)
72         ret
74         cfi_adjust_cfa_offset(4)
75         cfi_offset(%ebx, -8)
77 #ifdef PIC
78         SETUP_PIC_REG(bx)
79 #else
80         movl    $4f, %ebx
82 #endif
83         addl    $_GLOBAL_OFFSET_TABLE_, %ebx
84 #ifdef NO_TLS_DIRECT_SEG_REFS
85         movl    errno@gotntpoff(%ebx), %edx
86         addl    %gs:0, %edx
87         movl    $EINVAL, (%edx)
88 #else
89         movl    errno@gotntpoff(%ebx), %edx
90         movl    $EINVAL, %gs:(%edx)
91 #endif
93         orl     $-1, %eax
94         popl    %ebx
95         ret
98 #ifdef PIC
99         SETUP_PIC_REG(bx)
100 #else
101         movl    $5f, %ebx
103 #endif
104         addl    $_GLOBAL_OFFSET_TABLE_, %ebx
105 #ifdef NO_TLS_DIRECT_SEG_REFS
106         movl    errno@gotntpoff(%ebx), %edx
107         addl    %gs:0, %edx
108         movl    $EOVERFLOW, (%edx)
109 #else
110         movl    errno@gotntpoff(%ebx), %edx
111         movl    $EOVERFLOW, %gs:(%edx)
112 #endif
114         orl     $-1, %eax
115         popl    %ebx
116         cfi_adjust_cfa_offset(-4)
117         cfi_restore(%ebx)
118         ret
119         cfi_endproc
120         .size   __new_sem_post,.-__new_sem_post
121         versioned_symbol(libpthread, __new_sem_post, sem_post, GLIBC_2_1)
122 #if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)
123         .global __old_sem_post
124         .type   __old_sem_post,@function
125 __old_sem_post:
126         cfi_startproc
127         pushl   %ebx
128         cfi_adjust_cfa_offset(4)
129         cfi_offset(%ebx, -8)
131         movl    8(%esp), %ebx
132         LOCK
133         addl    $1, (%ebx)
135         movl    $SYS_futex, %eax
136         movl    $FUTEX_WAKE, %ecx
137         movl    $1, %edx
138         ENTER_KERNEL
140         testl   %eax, %eax
141         js      1b
143         xorl    %eax, %eax
144         popl    %ebx
145         cfi_adjust_cfa_offset(-4)
146         cfi_restore(%ebx)
147         ret
148         cfi_endproc
149         .size   __old_sem_post,.-__old_sem_post
150         compat_symbol(libpthread, __old_sem_post, sem_post, GLIBC_2_0)
151 #endif