]>
Commit | Line | Data |
---|---|---|
04277e02 | 1 | /* Copyright (C) 2002-2019 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 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://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 | |
e7da6545 | 59 | FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0) |
76a50749 | 60 | |
bd499a3b | 61 | #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_1) |
49e9f864 | 62 | FORWARD (__pthread_attr_init_2_0, (pthread_attr_t *attr), (attr), 0) |
83f2fcbe | 63 | compat_symbol (libc, __pthread_attr_init_2_0, pthread_attr_init, GLIBC_2_0); |
bd499a3b UD |
64 | #endif |
65 | ||
49e9f864 | 66 | FORWARD (__pthread_attr_init_2_1, (pthread_attr_t *attr), (attr), 0) |
e7da6545 | 67 | versioned_symbol (libc, __pthread_attr_init_2_1, pthread_attr_init, GLIBC_2_1); |
76a50749 UD |
68 | |
69 | FORWARD (pthread_attr_getdetachstate, | |
70 | (const pthread_attr_t *attr, int *detachstate), (attr, detachstate), | |
e7da6545 | 71 | 0) |
76a50749 | 72 | FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate), |
e7da6545 | 73 | (attr, detachstate), 0) |
76a50749 UD |
74 | |
75 | FORWARD (pthread_attr_getinheritsched, | |
e7da6545 | 76 | (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0) |
76a50749 | 77 | FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit), |
e7da6545 | 78 | (attr, inherit), 0) |
76a50749 UD |
79 | |
80 | FORWARD (pthread_attr_getschedparam, | |
81 | (const pthread_attr_t *attr, struct sched_param *param), | |
e7da6545 | 82 | (attr, param), 0) |
76a50749 UD |
83 | FORWARD (pthread_attr_setschedparam, |
84 | (pthread_attr_t *attr, const struct sched_param *param), | |
e7da6545 | 85 | (attr, param), 0) |
76a50749 UD |
86 | |
87 | FORWARD (pthread_attr_getschedpolicy, | |
e7da6545 | 88 | (const pthread_attr_t *attr, int *policy), (attr, policy), 0) |
76a50749 | 89 | FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy), |
e7da6545 | 90 | (attr, policy), 0) |
76a50749 UD |
91 | |
92 | FORWARD (pthread_attr_getscope, | |
e7da6545 | 93 | (const pthread_attr_t *attr, int *scope), (attr, scope), 0) |
76a50749 | 94 | FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope), |
e7da6545 | 95 | (attr, scope), 0) |
76a50749 UD |
96 | |
97 | ||
e7da6545 UD |
98 | FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0) |
99 | FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0) | |
76a50749 | 100 | |
bf293afe | 101 | #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) |
4a381a81 | 102 | FORWARD2 (__pthread_cond_broadcast_2_0, int attribute_compat_text_section, |
43513fb7 | 103 | (pthread_cond_2_0_t *cond), (cond), return 0) |
bf293afe UD |
104 | compat_symbol (libc, __pthread_cond_broadcast_2_0, pthread_cond_broadcast, |
105 | GLIBC_2_0); | |
106 | #endif | |
107 | FORWARD (__pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0) | |
108 | versioned_symbol (libc, __pthread_cond_broadcast, pthread_cond_broadcast, | |
109 | GLIBC_2_3_2); | |
110 | ||
111 | #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) | |
4a381a81 | 112 | FORWARD2 (__pthread_cond_destroy_2_0, int attribute_compat_text_section, |
43513fb7 | 113 | (pthread_cond_2_0_t *cond), (cond), return 0) |
bf293afe UD |
114 | compat_symbol (libc, __pthread_cond_destroy_2_0, pthread_cond_destroy, |
115 | GLIBC_2_0); | |
116 | #endif | |
117 | FORWARD (__pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0) | |
118 | versioned_symbol (libc, __pthread_cond_destroy, pthread_cond_destroy, | |
119 | GLIBC_2_3_2); | |
76a50749 | 120 | |
bf293afe | 121 | #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) |
4a381a81 UD |
122 | FORWARD2 (__pthread_cond_init_2_0, int attribute_compat_text_section, |
123 | (pthread_cond_2_0_t *cond, const pthread_condattr_t *cond_attr), | |
43513fb7 | 124 | (cond, cond_attr), return 0) |
bf293afe UD |
125 | compat_symbol (libc, __pthread_cond_init_2_0, pthread_cond_init, GLIBC_2_0); |
126 | #endif | |
127 | FORWARD (__pthread_cond_init, | |
128 | (pthread_cond_t *cond, const pthread_condattr_t *cond_attr), | |
129 | (cond, cond_attr), 0) | |
130 | versioned_symbol (libc, __pthread_cond_init, pthread_cond_init, GLIBC_2_3_2); | |
76a50749 | 131 | |
bf293afe | 132 | #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) |
4a381a81 | 133 | FORWARD2 (__pthread_cond_signal_2_0, int attribute_compat_text_section, |
43513fb7 | 134 | (pthread_cond_2_0_t *cond), (cond), return 0) |
bf293afe UD |
135 | compat_symbol (libc, __pthread_cond_signal_2_0, pthread_cond_signal, |
136 | GLIBC_2_0); | |
137 | #endif | |
138 | FORWARD (__pthread_cond_signal, (pthread_cond_t *cond), (cond), 0) | |
139 | versioned_symbol (libc, __pthread_cond_signal, pthread_cond_signal, | |
140 | GLIBC_2_3_2); | |
141 | ||
142 | #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) | |
4a381a81 | 143 | FORWARD2 (__pthread_cond_wait_2_0, int attribute_compat_text_section, |
43513fb7 UD |
144 | (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex), (cond, mutex), |
145 | return 0) | |
bf293afe UD |
146 | compat_symbol (libc, __pthread_cond_wait_2_0, pthread_cond_wait, |
147 | GLIBC_2_0); | |
148 | #endif | |
149 | FORWARD (__pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex), | |
e7da6545 | 150 | (cond, mutex), 0) |
bf293afe UD |
151 | versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait, |
152 | GLIBC_2_3_2); | |
76a50749 | 153 | |
c503d3dc | 154 | #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) |
4a381a81 UD |
155 | FORWARD2 (__pthread_cond_timedwait_2_0, int attribute_compat_text_section, |
156 | (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex, | |
43513fb7 UD |
157 | const struct timespec *abstime), (cond, mutex, abstime), |
158 | return 0) | |
c503d3dc UD |
159 | compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait, |
160 | GLIBC_2_0); | |
161 | #endif | |
162 | FORWARD (__pthread_cond_timedwait, | |
163 | (pthread_cond_t *cond, pthread_mutex_t *mutex, | |
164 | const struct timespec *abstime), (cond, mutex, abstime), 0) | |
165 | versioned_symbol (libc, __pthread_cond_timedwait, pthread_cond_timedwait, | |
166 | GLIBC_2_3_2); | |
167 | ||
76a50749 | 168 | |
5452bffe UD |
169 | FORWARD_NORETURN (__pthread_exit, void, (void *retval), (retval), |
170 | exit (EXIT_SUCCESS)) | |
49e9f864 | 171 | strong_alias (__pthread_exit, pthread_exit); |
76a50749 UD |
172 | |
173 | ||
174 | FORWARD (pthread_getschedparam, | |
175 | (pthread_t target_thread, int *policy, struct sched_param *param), | |
e7da6545 | 176 | (target_thread, policy, param), 0) |
76a50749 UD |
177 | FORWARD (pthread_setschedparam, |
178 | (pthread_t target_thread, int policy, | |
e7da6545 | 179 | const struct sched_param *param), (target_thread, policy, param), 0) |
76a50749 UD |
180 | |
181 | ||
e7da6545 | 182 | FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0) |
76a50749 UD |
183 | |
184 | FORWARD (pthread_mutex_init, | |
185 | (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr), | |
e7da6545 | 186 | (mutex, mutexattr), 0) |
76a50749 | 187 | |
e7da6545 | 188 | FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0) |
76a50749 | 189 | |
e7da6545 | 190 | FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0) |
76a50749 | 191 | |
e5d19c08 L |
192 | FORWARD (__pthread_setcancelstate, (int state, int *oldstate), |
193 | (state, oldstate), 0) | |
194 | strong_alias (__pthread_setcancelstate, pthread_setcancelstate) | |
76a50749 | 195 | |
e7da6545 | 196 | FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0) |
6efd4814 | 197 | |
f61a113f RM |
198 | FORWARD_NORETURN (__pthread_unwind, |
199 | void attribute_hidden __attribute ((noreturn)) | |
200 | __cleanup_fct_attribute attribute_compat_text_section, | |
201 | (__pthread_unwind_buf_t *buf), (buf), | |
202 | __safe_fatal ()) |