1 /* Copyright (C) 2002-2019 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 <https://www.gnu.org/licenses/>. */
24 #include <shlib-compat.h>
26 #include <safe-fatal.h>
29 /* Pointers to the libc functions. */
30 struct pthread_functions __libc_pthread_functions attribute_hidden
;
31 int __libc_pthread_functions_init attribute_hidden
;
34 #define FORWARD2(name, rettype, decl, params, defaction) \
38 if (!__libc_pthread_functions_init) \
41 return PTHFCT_CALL (ptr_##name, params); \
44 /* Same as FORWARD2, only without return. */
45 #define FORWARD_NORETURN(name, rettype, decl, params, defaction) \
49 if (!__libc_pthread_functions_init) \
52 PTHFCT_CALL (ptr_##name, params); \
55 #define FORWARD(name, decl, params, defretval) \
56 FORWARD2 (name, int, decl, params, return defretval)
59 FORWARD (pthread_attr_setschedparam
,
60 (pthread_attr_t
*attr
, const struct sched_param
*param
),
63 FORWARD (pthread_attr_getschedpolicy
,
64 (const pthread_attr_t
*attr
, int *policy
), (attr
, policy
), 0)
65 FORWARD (pthread_attr_setschedpolicy
, (pthread_attr_t
*attr
, int policy
),
68 FORWARD (pthread_attr_getscope
,
69 (const pthread_attr_t
*attr
, int *scope
), (attr
, scope
), 0)
70 FORWARD (pthread_attr_setscope
, (pthread_attr_t
*attr
, int scope
),
74 FORWARD (pthread_condattr_destroy
, (pthread_condattr_t
*attr
), (attr
), 0)
75 FORWARD (pthread_condattr_init
, (pthread_condattr_t
*attr
), (attr
), 0)
77 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
78 FORWARD2 (__pthread_cond_broadcast_2_0
, int attribute_compat_text_section
,
79 (pthread_cond_2_0_t
*cond
), (cond
), return 0)
80 compat_symbol (libc
, __pthread_cond_broadcast_2_0
, pthread_cond_broadcast
,
83 FORWARD (__pthread_cond_broadcast
, (pthread_cond_t
*cond
), (cond
), 0)
84 versioned_symbol (libc
, __pthread_cond_broadcast
, pthread_cond_broadcast
,
87 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
88 FORWARD2 (__pthread_cond_destroy_2_0
, int attribute_compat_text_section
,
89 (pthread_cond_2_0_t
*cond
), (cond
), return 0)
90 compat_symbol (libc
, __pthread_cond_destroy_2_0
, pthread_cond_destroy
,
93 FORWARD (__pthread_cond_destroy
, (pthread_cond_t
*cond
), (cond
), 0)
94 versioned_symbol (libc
, __pthread_cond_destroy
, pthread_cond_destroy
,
97 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
98 FORWARD2 (__pthread_cond_init_2_0
, int attribute_compat_text_section
,
99 (pthread_cond_2_0_t
*cond
, const pthread_condattr_t
*cond_attr
),
100 (cond
, cond_attr
), return 0)
101 compat_symbol (libc
, __pthread_cond_init_2_0
, pthread_cond_init
, GLIBC_2_0
);
103 FORWARD (__pthread_cond_init
,
104 (pthread_cond_t
*cond
, const pthread_condattr_t
*cond_attr
),
105 (cond
, cond_attr
), 0)
106 versioned_symbol (libc
, __pthread_cond_init
, pthread_cond_init
, GLIBC_2_3_2
);
108 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
109 FORWARD2 (__pthread_cond_signal_2_0
, int attribute_compat_text_section
,
110 (pthread_cond_2_0_t
*cond
), (cond
), return 0)
111 compat_symbol (libc
, __pthread_cond_signal_2_0
, pthread_cond_signal
,
114 FORWARD (__pthread_cond_signal
, (pthread_cond_t
*cond
), (cond
), 0)
115 versioned_symbol (libc
, __pthread_cond_signal
, pthread_cond_signal
,
118 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
119 FORWARD2 (__pthread_cond_wait_2_0
, int attribute_compat_text_section
,
120 (pthread_cond_2_0_t
*cond
, pthread_mutex_t
*mutex
), (cond
, mutex
),
122 compat_symbol (libc
, __pthread_cond_wait_2_0
, pthread_cond_wait
,
125 FORWARD (__pthread_cond_wait
, (pthread_cond_t
*cond
, pthread_mutex_t
*mutex
),
127 versioned_symbol (libc
, __pthread_cond_wait
, pthread_cond_wait
,
130 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
131 FORWARD2 (__pthread_cond_timedwait_2_0
, int attribute_compat_text_section
,
132 (pthread_cond_2_0_t
*cond
, pthread_mutex_t
*mutex
,
133 const struct timespec
*abstime
), (cond
, mutex
, abstime
),
135 compat_symbol (libc
, __pthread_cond_timedwait_2_0
, pthread_cond_timedwait
,
138 FORWARD (__pthread_cond_timedwait
,
139 (pthread_cond_t
*cond
, pthread_mutex_t
*mutex
,
140 const struct timespec
*abstime
), (cond
, mutex
, abstime
), 0)
141 versioned_symbol (libc
, __pthread_cond_timedwait
, pthread_cond_timedwait
,
145 FORWARD_NORETURN (__pthread_exit
, void, (void *retval
), (retval
),
147 strong_alias (__pthread_exit
, pthread_exit
);
150 FORWARD (pthread_getschedparam
,
151 (pthread_t target_thread
, int *policy
, struct sched_param
*param
),
152 (target_thread
, policy
, param
), 0)
153 FORWARD (pthread_setschedparam
,
154 (pthread_t target_thread
, int policy
,
155 const struct sched_param
*param
), (target_thread
, policy
, param
), 0)
158 FORWARD (pthread_mutex_destroy
, (pthread_mutex_t
*mutex
), (mutex
), 0)
160 FORWARD (pthread_mutex_init
,
161 (pthread_mutex_t
*mutex
, const pthread_mutexattr_t
*mutexattr
),
162 (mutex
, mutexattr
), 0)
164 FORWARD (pthread_mutex_lock
, (pthread_mutex_t
*mutex
), (mutex
), 0)
166 FORWARD (pthread_mutex_unlock
, (pthread_mutex_t
*mutex
), (mutex
), 0)
168 FORWARD (__pthread_setcancelstate
, (int state
, int *oldstate
),
169 (state
, oldstate
), 0)
170 strong_alias (__pthread_setcancelstate
, pthread_setcancelstate
)
172 FORWARD (pthread_setcanceltype
, (int type
, int *oldtype
), (type
, oldtype
), 0)
174 FORWARD_NORETURN (__pthread_unwind
,
175 void attribute_hidden
__attribute ((noreturn
))
176 __cleanup_fct_attribute attribute_compat_text_section
,
177 (__pthread_unwind_buf_t
*buf
), (buf
),