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