2.9
[glibc/nacl-glibc.git] / nptl / forward.c
blobb62efd86f8a23059996641037b7e477b8a7824de
1 /* Copyright (C) 2002, 2003, 2004, 2007 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <dlfcn.h>
21 #include <pthreadP.h>
22 #include <signal.h>
23 #include <stdlib.h>
25 #include <shlib-compat.h>
26 #include <atomic.h>
27 #include <sysdep.h>
30 /* Pointers to the libc functions. */
31 struct pthread_functions __libc_pthread_functions attribute_hidden;
32 int __libc_pthread_functions_init attribute_hidden;
35 #define FORWARD2(name, rettype, decl, params, defaction) \
36 rettype \
37 name decl \
38 { \
39 if (!__libc_pthread_functions_init) \
40 defaction; \
42 return PTHFCT_CALL (ptr_##name, params); \
45 #define FORWARD(name, decl, params, defretval) \
46 FORWARD2 (name, int, decl, params, return defretval)
49 FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0)
51 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_1)
52 FORWARD (__pthread_attr_init_2_0, (pthread_attr_t *attr), (attr), 0)
53 compat_symbol (libc, __pthread_attr_init_2_0, pthread_attr_init, GLIBC_2_0);
54 #endif
56 FORWARD (__pthread_attr_init_2_1, (pthread_attr_t *attr), (attr), 0)
57 versioned_symbol (libc, __pthread_attr_init_2_1, pthread_attr_init, GLIBC_2_1);
59 FORWARD (pthread_attr_getdetachstate,
60 (const pthread_attr_t *attr, int *detachstate), (attr, detachstate),
62 FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate),
63 (attr, detachstate), 0)
65 FORWARD (pthread_attr_getinheritsched,
66 (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0)
67 FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit),
68 (attr, inherit), 0)
70 FORWARD (pthread_attr_getschedparam,
71 (const pthread_attr_t *attr, struct sched_param *param),
72 (attr, param), 0)
73 FORWARD (pthread_attr_setschedparam,
74 (pthread_attr_t *attr, const struct sched_param *param),
75 (attr, param), 0)
77 FORWARD (pthread_attr_getschedpolicy,
78 (const pthread_attr_t *attr, int *policy), (attr, policy), 0)
79 FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy),
80 (attr, policy), 0)
82 FORWARD (pthread_attr_getscope,
83 (const pthread_attr_t *attr, int *scope), (attr, scope), 0)
84 FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope),
85 (attr, scope), 0)
88 FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
89 FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
91 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
92 FORWARD2 (__pthread_cond_broadcast_2_0, int attribute_compat_text_section,
93 (pthread_cond_2_0_t *cond), (cond), return 0)
94 compat_symbol (libc, __pthread_cond_broadcast_2_0, pthread_cond_broadcast,
95 GLIBC_2_0);
96 #endif
97 FORWARD (__pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
98 versioned_symbol (libc, __pthread_cond_broadcast, pthread_cond_broadcast,
99 GLIBC_2_3_2);
101 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
102 FORWARD2 (__pthread_cond_destroy_2_0, int attribute_compat_text_section,
103 (pthread_cond_2_0_t *cond), (cond), return 0)
104 compat_symbol (libc, __pthread_cond_destroy_2_0, pthread_cond_destroy,
105 GLIBC_2_0);
106 #endif
107 FORWARD (__pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
108 versioned_symbol (libc, __pthread_cond_destroy, pthread_cond_destroy,
109 GLIBC_2_3_2);
111 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
112 FORWARD2 (__pthread_cond_init_2_0, int attribute_compat_text_section,
113 (pthread_cond_2_0_t *cond, const pthread_condattr_t *cond_attr),
114 (cond, cond_attr), return 0)
115 compat_symbol (libc, __pthread_cond_init_2_0, pthread_cond_init, GLIBC_2_0);
116 #endif
117 FORWARD (__pthread_cond_init,
118 (pthread_cond_t *cond, const pthread_condattr_t *cond_attr),
119 (cond, cond_attr), 0)
120 versioned_symbol (libc, __pthread_cond_init, pthread_cond_init, GLIBC_2_3_2);
122 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
123 FORWARD2 (__pthread_cond_signal_2_0, int attribute_compat_text_section,
124 (pthread_cond_2_0_t *cond), (cond), return 0)
125 compat_symbol (libc, __pthread_cond_signal_2_0, pthread_cond_signal,
126 GLIBC_2_0);
127 #endif
128 FORWARD (__pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
129 versioned_symbol (libc, __pthread_cond_signal, pthread_cond_signal,
130 GLIBC_2_3_2);
132 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
133 FORWARD2 (__pthread_cond_wait_2_0, int attribute_compat_text_section,
134 (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex), (cond, mutex),
135 return 0)
136 compat_symbol (libc, __pthread_cond_wait_2_0, pthread_cond_wait,
137 GLIBC_2_0);
138 #endif
139 FORWARD (__pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
140 (cond, mutex), 0)
141 versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait,
142 GLIBC_2_3_2);
144 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
145 FORWARD2 (__pthread_cond_timedwait_2_0, int attribute_compat_text_section,
146 (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex,
147 const struct timespec *abstime), (cond, mutex, abstime),
148 return 0)
149 compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait,
150 GLIBC_2_0);
151 #endif
152 FORWARD (__pthread_cond_timedwait,
153 (pthread_cond_t *cond, pthread_mutex_t *mutex,
154 const struct timespec *abstime), (cond, mutex, abstime), 0)
155 versioned_symbol (libc, __pthread_cond_timedwait, pthread_cond_timedwait,
156 GLIBC_2_3_2);
159 FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2),
160 (thread1, thread2), 1)
163 /* Use an alias to avoid warning, as pthread_exit is declared noreturn. */
164 FORWARD2 (__pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS))
165 strong_alias (__pthread_exit, pthread_exit);
168 FORWARD (pthread_getschedparam,
169 (pthread_t target_thread, int *policy, struct sched_param *param),
170 (target_thread, policy, param), 0)
171 FORWARD (pthread_setschedparam,
172 (pthread_t target_thread, int policy,
173 const struct sched_param *param), (target_thread, policy, param), 0)
176 FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
178 FORWARD (pthread_mutex_init,
179 (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr),
180 (mutex, mutexattr), 0)
182 FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
184 FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
187 FORWARD2 (pthread_self, pthread_t, (void), (), return 0)
190 FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate),
193 FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
195 #define return /* value is void */
196 FORWARD2(__pthread_unwind,
197 void attribute_hidden __attribute ((noreturn)) __cleanup_fct_attribute
198 attribute_compat_text_section,
199 (__pthread_unwind_buf_t *buf), (buf), {
200 /* We cannot call abort() here. */
201 INTERNAL_SYSCALL_DECL (err);
202 INTERNAL_SYSCALL (kill, err, 1, SIGKILL);
204 #undef return