]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/linuxthreads.old/forward.c
Inital import
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / linuxthreads.old / 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, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 #include <features.h>
21 #include <stdlib.h>
22 #include <dlfcn.h>
23
24 /* psm: keep this before internals.h */
25 #if 0
26 vda: here is why:
27 headers contain libc_hidden_proto(foo).
28 In libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h
29 adding libc_hidden_proto(foo) just before weak_extern (__pthread_initialize)
30 will not warn:
31     /* libc_hidden_proto(foo) */
32     weak_extern (__pthread_initialize)
33     /* libc_hidden_proto(foo) */
34 but adding after will! Which is extremely strange -
35 weak_extern expands into just "#pragma weak __pthread_initialize".
36 TODO: determine whether it is a gcc bug or what
37 (see gcc.gnu.org/PR36282).
38 For now, just include all headers before internals.h
39 (they are again included in internals.h - maybe remove them there later)
40 #endif
41
42 #include <string.h>
43 #include <limits.h>
44 #include <setjmp.h>
45 #include <signal.h>
46 #include <unistd.h>
47 #include <sys/types.h>
48 #include <sys/wait.h>
49 #include <sys/time.h>
50
51 #include "internals.h"
52
53 /* Pointers to the libc functions.  */
54 struct pthread_functions __libc_pthread_functions attribute_hidden;
55
56
57 # define FORWARD2(name, rettype, decl, params, defaction) \
58 rettype                                                                       \
59 name decl                                                                     \
60 {                                                                             \
61   if (__libc_pthread_functions.ptr_##name == NULL)                            \
62     defaction;                                                                \
63                                                                               \
64   return __libc_pthread_functions.ptr_##name params;                          \
65 }
66
67 # define FORWARD(name, decl, params, defretval) \
68   FORWARD2 (name, int, decl, params, return defretval)
69
70 FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0)
71
72 FORWARD (pthread_attr_init, (pthread_attr_t *attr), (attr), 0)
73
74 FORWARD (pthread_attr_getdetachstate,
75          (const pthread_attr_t *attr, int *detachstate), (attr, detachstate),
76          0)
77 FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate),
78          (attr, detachstate), 0)
79
80 FORWARD (pthread_attr_getinheritsched,
81          (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0)
82 FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit),
83          (attr, inherit), 0)
84
85 FORWARD (pthread_attr_getschedparam,
86          (const pthread_attr_t *attr, struct sched_param *param),
87          (attr, param), 0)
88 FORWARD (pthread_attr_setschedparam,
89          (pthread_attr_t *attr, const struct sched_param *param),
90          (attr, param), 0)
91
92 FORWARD (pthread_attr_getschedpolicy,
93          (const pthread_attr_t *attr, int *policy), (attr, policy), 0)
94 FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy),
95          (attr, policy), 0)
96
97 FORWARD (pthread_attr_getscope,
98          (const pthread_attr_t *attr, int *scope), (attr, scope), 0)
99 FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope),
100          (attr, scope), 0)
101
102
103 FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
104 FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
105
106
107 FORWARD (pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
108
109 FORWARD (pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
110
111 FORWARD (pthread_cond_init,
112          (pthread_cond_t *cond, const pthread_condattr_t *cond_attr),
113          (cond, cond_attr), 0)
114
115 FORWARD (pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
116
117 FORWARD (pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
118          (cond, mutex), 0)
119
120 FORWARD (pthread_cond_timedwait,
121          (pthread_cond_t *cond, pthread_mutex_t *mutex,
122           const struct timespec *abstime), (cond, mutex, abstime), 0)
123
124
125 FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2),
126          (thread1, thread2), 1)
127
128
129 /* Use an alias to avoid warning, as pthread_exit is declared noreturn.  */
130 FORWARD2 (__pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS))
131 strong_alias (__pthread_exit, pthread_exit)
132
133
134 FORWARD (pthread_getschedparam,
135          (pthread_t target_thread, int *policy, struct sched_param *param),
136          (target_thread, policy, param), 0)
137 FORWARD (pthread_setschedparam,
138          (pthread_t target_thread, int policy,
139           const struct sched_param *param), (target_thread, policy, param), 0)
140
141
142 FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
143
144 FORWARD (pthread_mutex_init,
145          (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr),
146          (mutex, mutexattr), 0)
147 strong_alias(pthread_mutex_init, __pthread_mutex_init)
148
149 FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
150 strong_alias(pthread_mutex_lock, __pthread_mutex_lock)
151
152 FORWARD (pthread_mutex_trylock, (pthread_mutex_t *mutex), (mutex), 0)
153 strong_alias(pthread_mutex_trylock, __pthread_mutex_trylock)
154
155 FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
156 strong_alias(pthread_mutex_unlock, __pthread_mutex_unlock)
157
158 FORWARD2 (pthread_self, pthread_t, (void), (), return 0)
159
160
161 FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate),
162          0)
163
164 FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
165
166 FORWARD2 (_pthread_cleanup_push, void, (struct _pthread_cleanup_buffer * buffer, void (*routine)(void *), void * arg), (buffer, routine, arg), return)
167 FORWARD2 (_pthread_cleanup_push_defer, void, (struct _pthread_cleanup_buffer * buffer, void (*routine)(void *), void * arg), (buffer, routine, arg), return)
168
169 FORWARD2 (_pthread_cleanup_pop, void, (struct _pthread_cleanup_buffer * buffer, int execute), (buffer, execute), return)
170 FORWARD2 (_pthread_cleanup_pop_restore, void, (struct _pthread_cleanup_buffer * buffer, int execute), (buffer, execute), return)