* sysdeps/unix/sysv/linux/i386/i486/sem_post.S (__old_sem_post): New
[glibc.git] / nptl / sysdeps / unix / sysv / linux / i386 / i486 / sem_post.S
blobac045b6e3441d1f9274699c34007f75e497bba4d
1 /* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
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.
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.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
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         pushl   %ebx
35         movl    8(%esp), %ebx
37         LOCK
38 #if VALUE == 0
39         addl    $1, (%ebx)
40 #else
41         addl    $1, VALUE(%ebx)
42 #endif
44         cmpl    $0, NWAITERS(%ebx)
45         je      2f
47         movl    $FUTEX_WAKE, %ecx
48         orl     PRIVATE(%ebx), %ecx
49         movl    $1, %edx
50         movl    $SYS_futex, %eax
51         ENTER_KERNEL
53         testl   %eax, %eax
54         js      1f
56 2:      xorl    %eax, %eax
57         popl    %ebx
58         ret
61 #ifdef PIC
62         call    __i686.get_pc_thunk.bx
63 #else
64         movl    $4f, %ebx
66 #endif
67         addl    $_GLOBAL_OFFSET_TABLE_, %ebx
68 #if USE___THREAD
69 # ifdef NO_TLS_DIRECT_SEG_REFS
70         movl    errno@gotntpoff(%ebx), %edx
71         addl    %gs:0, %edx
72         movl    $EINVAL, (%edx)
73 # else
74         movl    errno@gotntpoff(%ebx), %edx
75         movl    $EINVAL, %gs:(%edx)
76 # endif
77 #else
78         call    __errno_location@plt
79         movl    $EINVAL, (%eax)
80 #endif
82         orl     $-1, %eax
83         popl    %ebx
84         ret
85         .size   __new_sem_post,.-__new_sem_post
86         versioned_symbol(libpthread, __new_sem_post, sem_post, GLIBC_2_1)
87 #if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)
88         .global __old_sem_post
89         .type   __old_sem_post,@function
90 __old_sem_post:
91         pushl   %ebx
93         movl    8(%esp), %ebx
94         LOCK
95         addl    $1, (%ebx)
97         movl    $SYS_futex, %eax
98         movl    $FUTEX_WAKE, %ecx
99         movl    $1, %edx
100         ENTER_KERNEL
102         testl   %eax, %eax
103         js      1b
105         xorl    %eax, %eax
106         popl    %ebx
107         ret
108         .size   __old_sem_post,.-__old_sem_post
109         compat_symbol(libpthread, __old_sem_post, sem_post, GLIBC_2_0)
110 #endif
113 #ifdef PIC
114         .section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits
115         .globl  __i686.get_pc_thunk.bx
116         .hidden __i686.get_pc_thunk.bx
117         .type   __i686.get_pc_thunk.bx,@function
118 __i686.get_pc_thunk.bx:
119         movl (%esp), %ebx;
120         ret
121         .size   __i686.get_pc_thunk.bx,.-__i686.get_pc_thunk.bx
122 #endif