Update copyright notices with scripts/update-copyrights
[glibc.git] / nptl / sysdeps / unix / sysv / linux / x86_64 / sem_post.S
blob1c1160046872ba25a51c2888d9c46866c3c2e1f5
1 /* Copyright (C) 2002-2014 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, see
17    <http://www.gnu.org/licenses/>.  */
19 #include <sysdep.h>
20 #include <lowlevellock.h>
21 #include <shlib-compat.h>
22 #include <pthread-errnos.h>
23 #include <structsem.h>
26         .text
28         .globl  sem_post
29         .type   sem_post,@function
30         .align  16
31 sem_post:
32 #if VALUE == 0
33         movl    (%rdi), %eax
34 #else
35         movl    VALUE(%rdi), %eax
36 #endif
37 0:      cmpl    $SEM_VALUE_MAX, %eax
38         je      3f
39         leal    1(%rax), %esi
40         LOCK
41 #if VALUE == 0
42         cmpxchgl %esi, (%rdi)
43 #else
44         cmpxchgl %esi, VALUE(%rdi)
45 #endif
46         jnz     0b
48         LP_OP(cmp) $0, NWAITERS(%rdi)
49         je      2f
51         movl    $SYS_futex, %eax
52         movl    $FUTEX_WAKE, %esi
53         orl     PRIVATE(%rdi), %esi
54         movl    $1, %edx
55         syscall
57         testq   %rax, %rax
58         js      1f
60 2:      xorl    %eax, %eax
61         retq
64         movl    $EINVAL, %eax
65         jmp     4f
68         movl    $EOVERFLOW, %eax
71         movq    errno@gottpoff(%rip), %rdx
72         movl    %eax, %fs:(%rdx)
73         orl     $-1, %eax
74         retq
75         .size   sem_post,.-sem_post