]> git.ipfire.org Git - thirdparty/glibc.git/blob - nptl/forward.c
nptl: Move pthread_attr_getschedparam implementation into libc
[thirdparty/glibc.git] / nptl / forward.c
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.
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, see
17 <https://www.gnu.org/licenses/>. */
18
19 #include <dlfcn.h>
20 #include <pthreadP.h>
21 #include <signal.h>
22 #include <stdlib.h>
23
24 #include <shlib-compat.h>
25 #include <atomic.h>
26 #include <safe-fatal.h>
27
28
29 /* Pointers to the libc functions. */
30 struct pthread_functions __libc_pthread_functions attribute_hidden;
31 int __libc_pthread_functions_init attribute_hidden;
32
33
34 #define FORWARD2(name, rettype, decl, params, defaction) \
35 rettype \
36 name decl \
37 { \
38 if (!__libc_pthread_functions_init) \
39 defaction; \
40 \
41 return PTHFCT_CALL (ptr_##name, params); \
42 }
43
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
55 #define FORWARD(name, decl, params, defretval) \
56 FORWARD2 (name, int, decl, params, return defretval)
57
58
59 FORWARD (pthread_attr_setschedparam,
60 (pthread_attr_t *attr, const struct sched_param *param),
61 (attr, param), 0)
62
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),
66 (attr, policy), 0)
67
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),
71 (attr, scope), 0)
72
73
74 FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
75 FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
76
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,
81 GLIBC_2_0);
82 #endif
83 FORWARD (__pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
84 versioned_symbol (libc, __pthread_cond_broadcast, pthread_cond_broadcast,
85 GLIBC_2_3_2);
86
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,
91 GLIBC_2_0);
92 #endif
93 FORWARD (__pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
94 versioned_symbol (libc, __pthread_cond_destroy, pthread_cond_destroy,
95 GLIBC_2_3_2);
96
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);
102 #endif
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);
107
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,
112 GLIBC_2_0);
113 #endif
114 FORWARD (__pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
115 versioned_symbol (libc, __pthread_cond_signal, pthread_cond_signal,
116 GLIBC_2_3_2);
117
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),
121 return 0)
122 compat_symbol (libc, __pthread_cond_wait_2_0, pthread_cond_wait,
123 GLIBC_2_0);
124 #endif
125 FORWARD (__pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
126 (cond, mutex), 0)
127 versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait,
128 GLIBC_2_3_2);
129
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),
134 return 0)
135 compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait,
136 GLIBC_2_0);
137 #endif
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,
142 GLIBC_2_3_2);
143
144
145 FORWARD_NORETURN (__pthread_exit, void, (void *retval), (retval),
146 exit (EXIT_SUCCESS))
147 strong_alias (__pthread_exit, pthread_exit);
148
149
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)
156
157
158 FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
159
160 FORWARD (pthread_mutex_init,
161 (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr),
162 (mutex, mutexattr), 0)
163
164 FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
165
166 FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
167
168 FORWARD (__pthread_setcancelstate, (int state, int *oldstate),
169 (state, oldstate), 0)
170 strong_alias (__pthread_setcancelstate, pthread_setcancelstate)
171
172 FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
173
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),
178 __safe_fatal ())