]>
Commit | Line | Data |
---|---|---|
76a50749 UD |
1 | /* Copyright (C) 2002 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 <dlfcn.h> | |
21 | #include <pthread.h> | |
22 | #include <stdlib.h> | |
23 | ||
24 | #include <shlib-compat.h> | |
25 | ||
26 | ||
27 | #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) | |
28 | static void *libpthread_handle; | |
29 | ||
30 | ||
31 | static void | |
32 | test_loaded (void) | |
33 | { | |
400d6c51 UD |
34 | /* While we are getting the result set the handle to (void *) -1 to |
35 | avoid recursive calls. */ | |
36 | libpthread_handle = (void *) -1l; | |
37 | ||
76a50749 UD |
38 | void *h = __libc_dlopen_mode ("libpthread.so.0", RTLD_LAZY | RTLD_NOLOAD); |
39 | ||
40 | libpthread_handle = h ?: (void *) -1l; | |
41 | } | |
42 | ||
43 | ||
44 | #define FORWARD3(name, rettype, decl, params, defaction, version) \ | |
45 | rettype \ | |
46 | __noexport_##name decl \ | |
47 | { \ | |
48 | if (libpthread_handle == NULL) \ | |
49 | test_loaded (); \ | |
50 | \ | |
51 | if (libpthread_handle == (void *) -1l) \ | |
52 | defaction; \ | |
53 | \ | |
54 | static __typeof (name) *p; \ | |
55 | p = __libc_dlsym (libpthread_handle, #name); \ | |
56 | \ | |
57 | return p params; \ | |
58 | } \ | |
59 | compat_symbol (libc, __noexport_##name, name, version) | |
60 | ||
61 | #define FORWARD2(name, decl, params, defretval, version) \ | |
62 | FORWARD3 (name, int, decl, params, return defretval, version) | |
63 | ||
64 | #define FORWARD(name, decl, params, defretval) \ | |
65 | FORWARD2 (name, decl, params, defretval, GLIBC_2_0) | |
66 | ||
67 | ||
68 | FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0); | |
69 | ||
70 | FORWARD2 (pthread_attr_init, (pthread_attr_t *attr), (attr), 0, GLIBC_2_1); | |
71 | ||
72 | FORWARD (pthread_attr_getdetachstate, | |
73 | (const pthread_attr_t *attr, int *detachstate), (attr, detachstate), | |
74 | 0); | |
75 | FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate), | |
76 | (attr, detachstate), 0); | |
77 | ||
78 | FORWARD (pthread_attr_getinheritsched, | |
79 | (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0); | |
80 | FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit), | |
81 | (attr, inherit), 0); | |
82 | ||
83 | FORWARD (pthread_attr_getschedparam, | |
84 | (const pthread_attr_t *attr, struct sched_param *param), | |
85 | (attr, param), 0); | |
86 | FORWARD (pthread_attr_setschedparam, | |
87 | (pthread_attr_t *attr, const struct sched_param *param), | |
88 | (attr, param), 0); | |
89 | ||
90 | FORWARD (pthread_attr_getschedpolicy, | |
91 | (const pthread_attr_t *attr, int *policy), (attr, policy), 0); | |
92 | FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy), | |
93 | (attr, policy), 0); | |
94 | ||
95 | FORWARD (pthread_attr_getscope, | |
96 | (const pthread_attr_t *attr, int *scope), (attr, scope), 0); | |
97 | FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope), | |
98 | (attr, scope), 0); | |
99 | ||
100 | ||
101 | FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0); | |
102 | FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0); | |
103 | ||
104 | ||
105 | FORWARD (pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0); | |
106 | ||
107 | FORWARD (pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0); | |
108 | ||
109 | FORWARD (pthread_cond_init, | |
110 | (pthread_cond_t *cond, const pthread_condattr_t *cond_attr), | |
111 | (cond, cond_attr), 0); | |
112 | ||
113 | FORWARD (pthread_cond_signal, (pthread_cond_t *cond), (cond), 0); | |
114 | ||
115 | FORWARD (pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex), | |
116 | (cond, mutex), 0); | |
117 | ||
118 | ||
119 | FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2), | |
120 | (thread1, thread2), 1); | |
121 | ||
122 | ||
123 | FORWARD3 (pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS), | |
124 | GLIBC_2_0); | |
125 | ||
126 | ||
127 | FORWARD (pthread_getschedparam, | |
128 | (pthread_t target_thread, int *policy, struct sched_param *param), | |
129 | (target_thread, policy, param), 0); | |
130 | FORWARD (pthread_setschedparam, | |
131 | (pthread_t target_thread, int policy, | |
132 | const struct sched_param *param), (target_thread, policy, param), 0); | |
133 | ||
134 | ||
135 | FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0); | |
136 | ||
137 | FORWARD (pthread_mutex_init, | |
138 | (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr), | |
139 | (mutex, mutexattr), 0); | |
140 | ||
141 | FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0); | |
142 | ||
143 | FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0); | |
144 | ||
145 | ||
d5ed0118 | 146 | FORWARD3 (pthread_self, pthread_t, (void), (), return 0, GLIBC_2_0); |
76a50749 UD |
147 | |
148 | ||
149 | FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate), | |
150 | 0); | |
151 | ||
152 | FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0); | |
153 | ||
154 | ||
155 | #endif |