OSDN Git Service

Replace FSF snail mail address with URLs
[uclinux-h8/uClibc.git] / libpthread / linuxthreads / forward.c
1 /* Copyright (C) 2002, 2003 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    <http://www.gnu.org/licenses/>.  */
18
19 #include <features.h>
20 #include <stdlib.h>
21 #include <dlfcn.h>
22
23 /* psm: keep this before internals.h */
24
25 #include "internals.h"
26
27 /* Pointers to the libc functions.  */
28 struct pthread_functions __libc_pthread_functions;
29
30
31 # define FORWARD2(name, rettype, decl, params, defaction) \
32 rettype                                                                       \
33 name decl                                                                     \
34 {                                                                             \
35   if (__libc_pthread_functions.ptr_##name == NULL)                            \
36     defaction;                                                                \
37                                                                               \
38   return __libc_pthread_functions.ptr_##name params;                          \
39 }
40
41 # define FORWARD(name, decl, params, defretval) \
42   FORWARD2 (name, int, decl, params, return defretval)
43
44 FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0)
45
46 FORWARD (pthread_attr_init, (pthread_attr_t *attr), (attr), 0)
47
48 FORWARD (pthread_attr_getdetachstate,
49          (const pthread_attr_t *attr, int *detachstate), (attr, detachstate),
50          0)
51 FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate),
52          (attr, detachstate), 0)
53
54 FORWARD (pthread_attr_getinheritsched,
55          (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0)
56 FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit),
57          (attr, inherit), 0)
58
59 FORWARD (pthread_attr_getschedparam,
60          (const pthread_attr_t *attr, struct sched_param *param),
61          (attr, param), 0)
62 FORWARD (pthread_attr_setschedparam,
63          (pthread_attr_t *attr, const struct sched_param *param),
64          (attr, param), 0)
65
66 FORWARD (pthread_attr_getschedpolicy,
67          (const pthread_attr_t *attr, int *policy), (attr, policy), 0)
68 FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy),
69          (attr, policy), 0)
70
71 FORWARD (pthread_attr_getscope,
72          (const pthread_attr_t *attr, int *scope), (attr, scope), 0)
73 FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope),
74          (attr, scope), 0)
75
76
77 FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
78 FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
79
80
81 FORWARD (pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
82
83 FORWARD (pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
84
85 FORWARD (pthread_cond_init,
86          (pthread_cond_t *cond, const pthread_condattr_t *cond_attr),
87          (cond, cond_attr), 0)
88
89 FORWARD (pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
90
91 FORWARD (pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
92          (cond, mutex), 0)
93
94 FORWARD (pthread_cond_timedwait,
95          (pthread_cond_t *cond, pthread_mutex_t *mutex,
96           const struct timespec *abstime), (cond, mutex, abstime), 0)
97
98
99 FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2),
100          (thread1, thread2), 1)
101
102
103 /* Use an alias to avoid warning, as pthread_exit is declared noreturn.  */
104 FORWARD2 (__pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS))
105 strong_alias (__pthread_exit, pthread_exit)
106
107
108 FORWARD (pthread_getschedparam,
109          (pthread_t target_thread, int *policy, struct sched_param *param),
110          (target_thread, policy, param), 0)
111 FORWARD (pthread_setschedparam,
112          (pthread_t target_thread, int policy,
113           const struct sched_param *param), (target_thread, policy, param), 0)
114
115
116 FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
117
118 FORWARD (pthread_mutex_init,
119          (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr),
120          (mutex, mutexattr), 0)
121 strong_alias(pthread_mutex_init, __pthread_mutex_init)
122
123 FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
124 strong_alias(pthread_mutex_lock, __pthread_mutex_lock)
125
126 FORWARD (pthread_mutex_trylock, (pthread_mutex_t *mutex), (mutex), 0)
127 strong_alias(pthread_mutex_trylock, __pthread_mutex_trylock)
128
129 FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
130 strong_alias(pthread_mutex_unlock, __pthread_mutex_unlock)
131
132 FORWARD2 (pthread_self, pthread_t, (void), (), return 0)
133
134
135 FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate),
136          0)
137
138 FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
139
140 FORWARD2 (_pthread_cleanup_push, void, (struct _pthread_cleanup_buffer * buffer, void (*routine)(void *), void * arg), (buffer, routine, arg), return)
141 FORWARD2 (_pthread_cleanup_push_defer, void, (struct _pthread_cleanup_buffer * buffer, void (*routine)(void *), void * arg), (buffer, routine, arg), return)
142
143 FORWARD2 (_pthread_cleanup_pop, void, (struct _pthread_cleanup_buffer * buffer, int execute), (buffer, execute), return)
144 FORWARD2 (_pthread_cleanup_pop_restore, void, (struct _pthread_cleanup_buffer * buffer, int execute), (buffer, execute), return)