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
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); \
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
FORWARD (__pthread_attr_init_2_1, (pthread_attr_t *attr), (attr), 0)
52
weak_alias(__pthread_attr_init_2_1, pthread_attr_init)
54
FORWARD (pthread_attr_getdetachstate,
55
(const pthread_attr_t *attr, int *detachstate), (attr, detachstate),
57
FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate),
58
(attr, detachstate), 0)
60
FORWARD (pthread_attr_getinheritsched,
61
(const pthread_attr_t *attr, int *inherit), (attr, inherit), 0)
62
FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit),
65
FORWARD (pthread_attr_getschedparam,
66
(const pthread_attr_t *attr, struct sched_param *param),
68
FORWARD (pthread_attr_setschedparam,
69
(pthread_attr_t *attr, const struct sched_param *param),
72
FORWARD (pthread_attr_getschedpolicy,
73
(const pthread_attr_t *attr, int *policy), (attr, policy), 0)
74
FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy),
77
FORWARD (pthread_attr_getscope,
78
(const pthread_attr_t *attr, int *scope), (attr, scope), 0)
79
FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope),
83
FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
84
FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
86
FORWARD (__pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
87
weak_alias(__pthread_cond_broadcast, pthread_cond_broadcast)
89
FORWARD (__pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
90
weak_alias(__pthread_cond_destroy, pthread_cond_destroy)
92
FORWARD (__pthread_cond_init,
93
(pthread_cond_t *cond, const pthread_condattr_t *cond_attr),
95
weak_alias(__pthread_cond_init, pthread_cond_init)
97
FORWARD (__pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
98
weak_alias(__pthread_cond_signal, pthread_cond_signal)
100
FORWARD (__pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
102
weak_alias(__pthread_cond_wait, pthread_cond_wait)
104
FORWARD (__pthread_cond_timedwait,
105
(pthread_cond_t *cond, pthread_mutex_t *mutex,
106
const struct timespec *abstime), (cond, mutex, abstime), 0)
107
weak_alias(__pthread_cond_timedwait, pthread_cond_timedwait)
110
FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2),
111
(thread1, thread2), 1)
114
/* Use an alias to avoid warning, as pthread_exit is declared noreturn. */
115
FORWARD2 (__pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS))
116
strong_alias (__pthread_exit, pthread_exit);
119
FORWARD (pthread_getschedparam,
120
(pthread_t target_thread, int *policy, struct sched_param *param),
121
(target_thread, policy, param), 0)
122
FORWARD (pthread_setschedparam,
123
(pthread_t target_thread, int policy,
124
const struct sched_param *param), (target_thread, policy, param), 0)
127
FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
129
FORWARD (pthread_mutex_init,
130
(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr),
131
(mutex, mutexattr), 0)
133
FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
134
weak_alias (pthread_mutex_lock, __pthread_mutex_lock)
136
FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
137
weak_alias (pthread_mutex_unlock, __pthread_mutex_unlock)
139
FORWARD2 (pthread_self, pthread_t, (void), (), return 0)
142
FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate),
145
FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
147
#define return /* value is void */
148
FORWARD2(_pthread_cleanup_push_defer,
149
void, (struct _pthread_cleanup_buffer *buffer, void (*routine)(void *), void *arg),
150
(buffer, routine, arg),
151
{ buffer->__routine = routine; buffer->__arg = arg; });
153
FORWARD2(_pthread_cleanup_pop_restore,
154
void, (struct _pthread_cleanup_buffer *buffer, int execute),
156
if (execute) { buffer->__routine(buffer->__arg); });
158
FORWARD2(__pthread_unwind,
159
void attribute_hidden __attribute ((noreturn)) __cleanup_fct_attribute,
160
(__pthread_unwind_buf_t *buf), (buf), {
161
/* We cannot call abort() here. */
162
INTERNAL_SYSCALL_DECL (err);
163
INTERNAL_SYSCALL (kill, err, 1, SIGKILL);