]>
Commit | Line | Data |
---|---|---|
d0aacb47 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 | #include <lowlevelcond.h> | |
23 | ||
24 | #ifdef UP | |
25 | # define LOCK | |
26 | #else | |
27 | # define LOCK lock | |
28 | #endif | |
29 | ||
30 | #define SYS_futex 202 | |
31 | #define FUTEX_WAIT 0 | |
32 | #define FUTEX_WAKE 1 | |
33 | ||
34 | ||
35 | .text | |
36 | ||
37 | /* int pthread_cond_signal (pthread_cond_t *cond) */ | |
38 | .globl __pthread_cond_signal | |
39 | .type __pthread_cond_signal, @function | |
40 | .align 16 | |
41 | __pthread_cond_signal: | |
42 | ||
43 | /* Get internal lock. */ | |
44 | movl $1, %esi | |
45 | LOCK | |
46 | #if cond_lock == 0 | |
47 | xaddl %esi, (%rdi) | |
48 | #else | |
49 | xaddl %esi, cond_lock(%rdi) | |
50 | #endif | |
51 | testl %esi, %esi | |
52 | jne 1f | |
53 | ||
54 | 2: addq $wakeup_seq, %rdi | |
55 | movq total_seq-wakeup_seq(%rdi), %rcx | |
56 | cmpq (%rdi), %rcx | |
57 | jbe 4f | |
58 | ||
59 | /* Bump the wakeup number. */ | |
60 | addq $1, (%rdi) | |
61 | ||
62 | /* Wake up one thread. */ | |
63 | movq $FUTEX_WAKE, %rsi | |
64 | movq $SYS_futex, %rax | |
5a03acfe | 65 | movq %rsi, %rdx /* movl $1, %edx */ |
d0aacb47 UD |
66 | syscall |
67 | ||
68 | /* Unlock. */ | |
69 | 4: LOCK | |
70 | decl cond_lock-wakeup_seq(%rdi) | |
71 | jne 5f | |
72 | ||
73 | 6: xorl %eax, %eax | |
74 | retq | |
75 | ||
76 | /* Initial locking failed. */ | |
77 | 1: | |
78 | #if cond_lock != 0 | |
79 | addq $cond_lock, %rdi | |
80 | #endif | |
6c477888 | 81 | callq __lll_mutex_lock_wait |
d0aacb47 UD |
82 | #if cond_lock != 0 |
83 | subq $cond_lock, %rdi | |
84 | #endif | |
85 | jmp 2b | |
86 | ||
87 | /* Unlock in loop requires waekup. */ | |
6c477888 UD |
88 | 5: addq $cond_lock-wakeup_seq, %rdi |
89 | callq __lll_mutex_unlock_wake | |
d0aacb47 UD |
90 | jmp 6b |
91 | .size __pthread_cond_signal, .-__pthread_cond_signal | |
92 | versioned_symbol (libpthread, __pthread_cond_signal, pthread_cond_signal, | |
93 | GLIBC_2_3_2) |