]>
Commit | Line | Data |
---|---|---|
db5f2fc9 UD |
1 | /* Copyright (C) 2002, 2003 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, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
19 | ||
20 | #include <sysdep.h> | |
21 | #include <shlib-compat.h> | |
22 | ||
23 | #ifndef UP | |
24 | # define LOCK lock | |
25 | #else | |
26 | # define | |
27 | #endif | |
28 | ||
29 | #define SYS_futex 202 | |
30 | ||
31 | #define EWOULDBLOCK 11 | |
32 | ||
33 | ||
34 | .text | |
35 | ||
36 | .globl __new_sem_wait | |
37 | .type __new_sem_wait,@function | |
38 | .align 16 | |
39 | __new_sem_wait: | |
40 | 3: movl (%rdi), %eax | |
41 | 2: testl %eax, %eax | |
42 | je 1f | |
43 | ||
5a03acfe | 44 | leaq -1(%rax), %rdx |
db5f2fc9 UD |
45 | LOCK |
46 | cmpxchgl %edx, (%rdi) | |
47 | jne 2b | |
48 | xorl %eax, %eax | |
49 | ||
50 | retq | |
51 | ||
52 | 1: xorq %r10, %r10 | |
53 | movq $SYS_futex, %rax | |
54 | movq %r10, %rsi | |
55 | movq %r10, %rdx | |
56 | syscall | |
57 | ||
58 | testq %rax, %rax | |
59 | je 3b | |
60 | cmpq $-EWOULDBLOCK, %rax | |
61 | je 3b | |
62 | negq %rax | |
63 | #if USE___THREAD | |
64 | movq errno@gottpoff(%rip), %rdx | |
65 | movl %eax, %fs:(%rdx) | |
66 | #else | |
67 | movl %eax, %edx | |
6c477888 | 68 | callq __errno_location@plt |
db5f2fc9 UD |
69 | movl %edx, (%rax) |
70 | #endif | |
71 | orl $-1, %eax | |
72 | retq | |
73 | .size __new_sem_wait,.-__new_sem_wait | |
74 | .symver __new_sem_wait, sem_wait@@GLIBC_2.1 | |
75 | #if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1) | |
76 | .global __old_sem_wait | |
77 | __old_sem_wait = __new_sem_wait | |
78 | .symver __old_sem_wait, sem_wait@GLIBC_2.0 | |
79 | #endif |