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.
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 /* psm: keep this before internals.h */
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
)
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
)
47 #include <sys/types.h>
51 #include "internals.h"
53 /* Pointers to the libc functions. */
54 struct pthread_functions __libc_pthread_functions attribute_hidden
;
57 # define FORWARD2(name, rettype, decl, params, defaction) \
61 if (__libc_pthread_functions.ptr_##name == NULL) \
64 return __libc_pthread_functions.ptr_##name params; \
67 # define FORWARD(name, decl, params, defretval) \
68 FORWARD2 (name, int, decl, params, return defretval)
70 FORWARD (pthread_attr_destroy
, (pthread_attr_t
*attr
), (attr
), 0)
72 FORWARD (pthread_attr_init
, (pthread_attr_t
*attr
), (attr
), 0)
74 FORWARD (pthread_attr_getdetachstate
,
75 (const pthread_attr_t
*attr
, int *detachstate
), (attr
, detachstate
),
77 FORWARD (pthread_attr_setdetachstate
, (pthread_attr_t
*attr
, int detachstate
),
78 (attr
, detachstate
), 0)
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
),
85 FORWARD (pthread_attr_getschedparam
,
86 (const pthread_attr_t
*attr
, struct sched_param
*param
),
88 FORWARD (pthread_attr_setschedparam
,
89 (pthread_attr_t
*attr
, const struct sched_param
*param
),
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
),
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
),
103 FORWARD (pthread_condattr_destroy
, (pthread_condattr_t
*attr
), (attr
), 0)
104 FORWARD (pthread_condattr_init
, (pthread_condattr_t
*attr
), (attr
), 0)
107 FORWARD (pthread_cond_broadcast
, (pthread_cond_t
*cond
), (cond
), 0)
109 FORWARD (pthread_cond_destroy
, (pthread_cond_t
*cond
), (cond
), 0)
111 FORWARD (pthread_cond_init
,
112 (pthread_cond_t
*cond
, const pthread_condattr_t
*cond_attr
),
113 (cond
, cond_attr
), 0)
115 FORWARD (pthread_cond_signal
, (pthread_cond_t
*cond
), (cond
), 0)
117 FORWARD (pthread_cond_wait
, (pthread_cond_t
*cond
, pthread_mutex_t
*mutex
),
120 FORWARD (pthread_cond_timedwait
,
121 (pthread_cond_t
*cond
, pthread_mutex_t
*mutex
,
122 const struct timespec
*abstime
), (cond
, mutex
, abstime
), 0)
125 FORWARD (pthread_equal
, (pthread_t thread1
, pthread_t thread2
),
126 (thread1
, thread2
), 1)
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
)
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)
142 FORWARD (pthread_mutex_destroy
, (pthread_mutex_t
*mutex
), (mutex
), 0)
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
)
149 FORWARD (pthread_mutex_lock
, (pthread_mutex_t
*mutex
), (mutex
), 0)
150 strong_alias(pthread_mutex_lock
, __pthread_mutex_lock
)
152 FORWARD (pthread_mutex_trylock
, (pthread_mutex_t
*mutex
), (mutex
), 0)
153 strong_alias(pthread_mutex_trylock
, __pthread_mutex_trylock
)
155 FORWARD (pthread_mutex_unlock
, (pthread_mutex_t
*mutex
), (mutex
), 0)
156 strong_alias(pthread_mutex_unlock
, __pthread_mutex_unlock
)
158 FORWARD2 (pthread_self
, pthread_t
, (void), (), return 0)
161 FORWARD (pthread_setcancelstate
, (int state
, int *oldstate
), (state
, oldstate
),
164 FORWARD (pthread_setcanceltype
, (int type
, int *oldtype
), (type
, oldtype
), 0)
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)
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)