]>
Commit | Line | Data |
---|---|---|
d614a753 | 1 | /* Copyright (C) 2002-2020 Free Software Foundation, Inc. |
76a50749 UD |
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 | |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
76a50749 UD |
18 | |
19 | #include <dlfcn.h> | |
8454830b | 20 | #include <pthreadP.h> |
6efd4814 | 21 | #include <signal.h> |
76a50749 UD |
22 | #include <stdlib.h> |
23 | ||
24 | #include <shlib-compat.h> | |
3b7c07d8 | 25 | #include <atomic.h> |
f61a113f | 26 | #include <safe-fatal.h> |
76a50749 UD |
27 | |
28 | ||
8454830b UD |
29 | /* Pointers to the libc functions. */ |
30 | struct pthread_functions __libc_pthread_functions attribute_hidden; | |
ea1533e0 | 31 | int __libc_pthread_functions_init attribute_hidden; |
76a50749 | 32 | |
76a50749 | 33 | |
49e9f864 | 34 | #define FORWARD2(name, rettype, decl, params, defaction) \ |
76a50749 | 35 | rettype \ |
e7da6545 | 36 | name decl \ |
76a50749 | 37 | { \ |
ea1533e0 | 38 | if (!__libc_pthread_functions_init) \ |
76a50749 UD |
39 | defaction; \ |
40 | \ | |
ea1533e0 | 41 | return PTHFCT_CALL (ptr_##name, params); \ |
e7da6545 | 42 | } |
bd499a3b | 43 | |
5452bffe UD |
44 | /* Same as FORWARD2, only without return. */ |
45 | #define FORWARD_NORETURN(name, rettype, decl, params, defaction) \ | |
46 | rettype \ | |
47 | name decl \ | |
48 | { \ | |
49 | if (!__libc_pthread_functions_init) \ | |
50 | defaction; \ | |
51 | \ | |
52 | PTHFCT_CALL (ptr_##name, params); \ | |
53 | } | |
54 | ||
e7da6545 | 55 | #define FORWARD(name, decl, params, defretval) \ |
49e9f864 | 56 | FORWARD2 (name, int, decl, params, return defretval) |
76a50749 | 57 | |
76a50749 | 58 | |
bf293afe | 59 | #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) |
4a381a81 | 60 | FORWARD2 (__pthread_cond_broadcast_2_0, int attribute_compat_text_section, |
43513fb7 | 61 | (pthread_cond_2_0_t *cond), (cond), return 0) |
bf293afe UD |
62 | compat_symbol (libc, __pthread_cond_broadcast_2_0, pthread_cond_broadcast, |
63 | GLIBC_2_0); | |
64 | #endif | |
65 | FORWARD (__pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0) | |
66 | versioned_symbol (libc, __pthread_cond_broadcast, pthread_cond_broadcast, | |
67 | GLIBC_2_3_2); | |
68 | ||
bf293afe | 69 | #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) |
4a381a81 | 70 | FORWARD2 (__pthread_cond_signal_2_0, int attribute_compat_text_section, |
43513fb7 | 71 | (pthread_cond_2_0_t *cond), (cond), return 0) |
bf293afe UD |
72 | compat_symbol (libc, __pthread_cond_signal_2_0, pthread_cond_signal, |
73 | GLIBC_2_0); | |
74 | #endif | |
75 | FORWARD (__pthread_cond_signal, (pthread_cond_t *cond), (cond), 0) | |
76 | versioned_symbol (libc, __pthread_cond_signal, pthread_cond_signal, | |
77 | GLIBC_2_3_2); | |
78 | ||
79 | #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) | |
4a381a81 | 80 | FORWARD2 (__pthread_cond_wait_2_0, int attribute_compat_text_section, |
43513fb7 UD |
81 | (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex), (cond, mutex), |
82 | return 0) | |
bf293afe UD |
83 | compat_symbol (libc, __pthread_cond_wait_2_0, pthread_cond_wait, |
84 | GLIBC_2_0); | |
85 | #endif | |
86 | FORWARD (__pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex), | |
e7da6545 | 87 | (cond, mutex), 0) |
bf293afe UD |
88 | versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait, |
89 | GLIBC_2_3_2); | |
76a50749 | 90 | |
c503d3dc | 91 | #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) |
4a381a81 UD |
92 | FORWARD2 (__pthread_cond_timedwait_2_0, int attribute_compat_text_section, |
93 | (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex, | |
43513fb7 UD |
94 | const struct timespec *abstime), (cond, mutex, abstime), |
95 | return 0) | |
c503d3dc UD |
96 | compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait, |
97 | GLIBC_2_0); | |
98 | #endif | |
99 | FORWARD (__pthread_cond_timedwait, | |
100 | (pthread_cond_t *cond, pthread_mutex_t *mutex, | |
101 | const struct timespec *abstime), (cond, mutex, abstime), 0) | |
102 | versioned_symbol (libc, __pthread_cond_timedwait, pthread_cond_timedwait, | |
103 | GLIBC_2_3_2); | |
104 | ||
76a50749 | 105 | |
5452bffe UD |
106 | FORWARD_NORETURN (__pthread_exit, void, (void *retval), (retval), |
107 | exit (EXIT_SUCCESS)) | |
49e9f864 | 108 | strong_alias (__pthread_exit, pthread_exit); |
76a50749 UD |
109 | |
110 | ||
e7da6545 | 111 | FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0) |
76a50749 UD |
112 | |
113 | FORWARD (pthread_mutex_init, | |
114 | (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr), | |
e7da6545 | 115 | (mutex, mutexattr), 0) |
76a50749 | 116 | |
e7da6545 | 117 | FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0) |
76a50749 | 118 | |
e7da6545 | 119 | FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0) |
76a50749 | 120 | |
e5d19c08 L |
121 | FORWARD (__pthread_setcancelstate, (int state, int *oldstate), |
122 | (state, oldstate), 0) | |
123 | strong_alias (__pthread_setcancelstate, pthread_setcancelstate) | |
76a50749 | 124 | |
e7da6545 | 125 | FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0) |
6efd4814 | 126 | |
f61a113f RM |
127 | FORWARD_NORETURN (__pthread_unwind, |
128 | void attribute_hidden __attribute ((noreturn)) | |
129 | __cleanup_fct_attribute attribute_compat_text_section, | |
130 | (__pthread_unwind_buf_t *buf), (buf), | |
131 | __safe_fatal ()) |