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.
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
24 #include <shlib-compat.h>
27 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
28 static void *libpthread_handle
;
34 void *h
= __libc_dlopen_mode ("libpthread.so.0", RTLD_LAZY
| RTLD_NOLOAD
);
36 libpthread_handle
= h
?: (void *) -1l;
40 #define FORWARD3(name, rettype, decl, params, defaction, version) \
42 __noexport_##name decl \
44 if (libpthread_handle == NULL) \
47 if (libpthread_handle == (void *) -1l) \
50 static __typeof (name) *p; \
51 p = __libc_dlsym (libpthread_handle, #name); \
55 compat_symbol (libc, __noexport_##name, name, version)
57 #define FORWARD2(name, decl, params, defretval, version) \
58 FORWARD3 (name, int, decl, params, return defretval, version)
60 #define FORWARD(name, decl, params, defretval) \
61 FORWARD2 (name, decl, params, defretval, GLIBC_2_0)
64 FORWARD (pthread_attr_destroy
, (pthread_attr_t
*attr
), (attr
), 0);
66 FORWARD2 (pthread_attr_init
, (pthread_attr_t
*attr
), (attr
), 0, GLIBC_2_1
);
68 FORWARD (pthread_attr_getdetachstate
,
69 (const pthread_attr_t
*attr
, int *detachstate
), (attr
, detachstate
),
71 FORWARD (pthread_attr_setdetachstate
, (pthread_attr_t
*attr
, int detachstate
),
72 (attr
, detachstate
), 0);
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
),
79 FORWARD (pthread_attr_getschedparam
,
80 (const pthread_attr_t
*attr
, struct sched_param
*param
),
82 FORWARD (pthread_attr_setschedparam
,
83 (pthread_attr_t
*attr
, const struct sched_param
*param
),
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
),
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
),
97 FORWARD (pthread_condattr_destroy
, (pthread_condattr_t
*attr
), (attr
), 0);
98 FORWARD (pthread_condattr_init
, (pthread_condattr_t
*attr
), (attr
), 0);
101 FORWARD (pthread_cond_broadcast
, (pthread_cond_t
*cond
), (cond
), 0);
103 FORWARD (pthread_cond_destroy
, (pthread_cond_t
*cond
), (cond
), 0);
105 FORWARD (pthread_cond_init
,
106 (pthread_cond_t
*cond
, const pthread_condattr_t
*cond_attr
),
107 (cond
, cond_attr
), 0);
109 FORWARD (pthread_cond_signal
, (pthread_cond_t
*cond
), (cond
), 0);
111 FORWARD (pthread_cond_wait
, (pthread_cond_t
*cond
, pthread_mutex_t
*mutex
),
115 FORWARD (pthread_equal
, (pthread_t thread1
, pthread_t thread2
),
116 (thread1
, thread2
), 1);
119 FORWARD3 (pthread_exit
, void, (void *retval
), (retval
), exit (EXIT_SUCCESS
),
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);
131 FORWARD (pthread_mutex_destroy
, (pthread_mutex_t
*mutex
), (mutex
), 0);
133 FORWARD (pthread_mutex_init
,
134 (pthread_mutex_t
*mutex
, const pthread_mutexattr_t
*mutexattr
),
135 (mutex
, mutexattr
), 0);
137 FORWARD (pthread_mutex_lock
, (pthread_mutex_t
*mutex
), (mutex
), 0);
139 FORWARD (pthread_mutex_unlock
, (pthread_mutex_t
*mutex
), (mutex
), 0);
142 FORWARD (pthread_self
, (void), (), 0);
145 FORWARD (pthread_setcancelstate
, (int state
, int *oldstate
), (state
, oldstate
),
148 FORWARD (pthread_setcanceltype
, (int type
, int *oldtype
), (type
, oldtype
), 0);