Remove some unnecessary inclusions of <sys/cdefs.h> across the tree.
[dragonfly.git] / lib / libc / gen / _pthread_stubs.c
CommitLineData
17ea2221
MD
1/*
2 * Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS''
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
ce0e08e2 26 * $FreeBSD: src/lib/libc/gen/_pthread_stubs.c,v 1.5 2001/06/11 23:18:22 iedowse Exp $
17ea2221
MD
27 */
28
82205bfb 29#include <stdlib.h>
6692f0a1 30#include <pthread.h>
19c7a913 31
17ea2221
MD
32/*
33 * Weak symbols: All libc internal usage of these functions should
34 * use the weak symbol versions (_pthread_XXX). If libpthread is
35 * linked, it will override these functions with (non-weak) routines.
36 * The _pthread_XXX functions are provided solely for internal libc
37 * usage to avoid unwanted cancellation points and to differentiate
38 * between application locks and libc locks (threads holding the
39 * latter can't be allowed to exit/terminate).
40 */
ce0e08e2 41
82205bfb
SS
42#define WR(f, n) \
43 __weak_reference(f, _ ## n); \
44 __weak_reference(f, n)
45
46
47WR(stub_zero, pthread_atfork);
48WR(stub_zero, pthread_attr_destroy);
49WR(stub_zero, pthread_attr_get_np);
50WR(stub_zero, pthread_attr_getdetachstate);
0490f058 51WR(stub_zero, pthread_attr_getguardsize);
82205bfb
SS
52WR(stub_zero, pthread_attr_getinheritsched);
53WR(stub_zero, pthread_attr_getschedparam);
54WR(stub_zero, pthread_attr_getschedpolicy);
55WR(stub_zero, pthread_attr_getscope);
56WR(stub_zero, pthread_attr_getstack);
57WR(stub_zero, pthread_attr_getstackaddr);
58WR(stub_zero, pthread_attr_getstacksize);
59WR(stub_zero, pthread_attr_init);
60WR(stub_zero, pthread_attr_setcreatesuspend_np);
61WR(stub_zero, pthread_attr_setdetachstate);
0490f058 62WR(stub_zero, pthread_attr_setguardsize);
82205bfb
SS
63WR(stub_zero, pthread_attr_setinheritsched);
64WR(stub_zero, pthread_attr_setschedparam);
65WR(stub_zero, pthread_attr_setschedpolicy);
66WR(stub_zero, pthread_attr_setscope);
67WR(stub_zero, pthread_attr_setstack);
68WR(stub_zero, pthread_attr_setstackaddr);
69WR(stub_zero, pthread_attr_setstacksize);
0490f058
HT
70WR(stub_zero, pthread_barrier_destroy);
71WR(stub_zero, pthread_barrier_init);
72WR(stub_zero, pthread_barrier_wait);
73WR(stub_zero, pthread_barrierattr_destroy);
74WR(stub_zero, pthread_barrierattr_getpshared);
75WR(stub_zero, pthread_barrierattr_init);
76WR(stub_zero, pthread_barrierattr_setpshared);
82205bfb
SS
77WR(stub_zero, pthread_cancel);
78WR(stub_zero, pthread_cleanup_pop);
79WR(stub_zero, pthread_cleanup_push);
80WR(stub_zero, pthread_cond_broadcast);
81WR(stub_zero, pthread_cond_destroy);
82WR(stub_zero, pthread_cond_init);
83WR(stub_zero, pthread_cond_signal);
84WR(stub_zero, pthread_cond_timedwait);
85WR(stub_zero, pthread_cond_wait);
86WR(stub_zero, pthread_condattr_destroy);
0490f058
HT
87WR(stub_zero, pthread_condattr_getclock);
88WR(stub_zero, pthread_condattr_getpshared);
82205bfb 89WR(stub_zero, pthread_condattr_init);
0490f058
HT
90WR(stub_zero, pthread_condattr_setclock);
91WR(stub_zero, pthread_condattr_setpshared);
82205bfb
SS
92WR(stub_zero, pthread_detach);
93WR(stub_true, pthread_equal);
94WR(stub_exit, pthread_exit);
95WR(stub_zero, pthread_getconcurrency);
96WR(stub_zero, pthread_getprio);
97WR(stub_zero, pthread_getschedparam);
98WR(stub_null, pthread_getspecific);
99WR(stub_zero, pthread_join);
100WR(stub_zero, pthread_key_create);
101WR(stub_zero, pthread_key_delete);
102WR(stub_zero, pthread_kill);
103WR(stub_main, pthread_main_np);
104WR(stub_zero, pthread_multi_np);
105WR(stub_zero, pthread_mutex_destroy);
106WR(stub_zero, pthread_mutex_getprioceiling);
107WR(stub_zero, pthread_mutex_init);
108WR(stub_zero, pthread_mutex_lock);
109WR(stub_zero, pthread_mutex_setprioceiling);
0490f058 110WR(stub_zero, pthread_mutex_timedlock);
82205bfb
SS
111WR(stub_zero, pthread_mutex_trylock);
112WR(stub_zero, pthread_mutex_unlock);
113WR(stub_zero, pthread_mutexattr_destroy);
114WR(stub_zero, pthread_mutexattr_getkind_np);
115WR(stub_zero, pthread_mutexattr_getprioceiling);
116WR(stub_zero, pthread_mutexattr_getprotocol);
117WR(stub_zero, pthread_mutexattr_getpshared);
118WR(stub_zero, pthread_mutexattr_gettype);
119WR(stub_zero, pthread_mutexattr_init);
120WR(stub_zero, pthread_mutexattr_setkind_np);
121WR(stub_zero, pthread_mutexattr_setprioceiling);
122WR(stub_zero, pthread_mutexattr_setprotocol);
123WR(stub_zero, pthread_mutexattr_setpshared);
124WR(stub_zero, pthread_mutexattr_settype);
6692f0a1 125WR(stub_once, pthread_once);
82205bfb
SS
126WR(stub_zero, pthread_resume_all_np);
127WR(stub_zero, pthread_resume_np);
128WR(stub_zero, pthread_rwlock_destroy);
129WR(stub_zero, pthread_rwlock_init);
130WR(stub_zero, pthread_rwlock_rdlock);
0490f058
HT
131WR(stub_zero, pthread_rwlock_timedrdlock);
132WR(stub_zero, pthread_rwlock_timedwrlock);
82205bfb
SS
133WR(stub_zero, pthread_rwlock_tryrdlock);
134WR(stub_zero, pthread_rwlock_trywrlock);
135WR(stub_zero, pthread_rwlock_unlock);
136WR(stub_zero, pthread_rwlock_wrlock);
137WR(stub_zero, pthread_rwlockattr_destroy);
138WR(stub_zero, pthread_rwlockattr_getpshared);
139WR(stub_zero, pthread_rwlockattr_init);
140WR(stub_zero, pthread_rwlockattr_setpshared);
141WR(stub_self, pthread_self);
142WR(stub_zero, pthread_set_name_np);
143WR(stub_zero, pthread_setcancelstate);
144WR(stub_zero, pthread_setcanceltype);
145WR(stub_zero, pthread_setconcurrency);
146WR(stub_zero, pthread_setprio);
147WR(stub_zero, pthread_setschedparam);
148WR(stub_zero, pthread_setspecific);
149WR(stub_zero, pthread_sigmask);
150WR(stub_zero, pthread_single_np);
0490f058
HT
151WR(stub_zero, pthread_spin_destroy);
152WR(stub_zero, pthread_spin_init);
153WR(stub_zero, pthread_spin_lock);
154WR(stub_zero, pthread_spin_trylock);
155WR(stub_zero, pthread_spin_unlock);
82205bfb
SS
156WR(stub_zero, pthread_suspend_all_np);
157WR(stub_zero, pthread_suspend_np);
158WR(stub_zero, pthread_switch_add_np);
159WR(stub_zero, pthread_switch_delete_np);
160WR(stub_zero, pthread_testcancel);
0490f058 161WR(stub_zero, pthread_timedjoin_np);
82205bfb
SS
162WR(stub_zero, pthread_yield);
163WR(stub_zero, sched_yield);
164WR(stub_zero, sem_close);
165WR(stub_zero, sem_destroy);
166WR(stub_zero, sem_getvalue);
167WR(stub_zero, sem_init);
168WR(stub_zero, sem_open);
169WR(stub_zero, sem_post);
170WR(stub_zero, sem_trywait);
171WR(stub_zero, sem_unlink);
172WR(stub_zero, sem_wait);
173
174
175static int __used
176stub_zero(void)
177{
178 return (0);
179}
180
6692f0a1
AH
181static int __used
182stub_once(pthread_once_t *o, void (*r)(void))
183{
184 if (o->state != PTHREAD_DONE_INIT) {
185 (*r)();
186 o->state = PTHREAD_DONE_INIT;
187 }
188
189 return (0);
190}
191
82205bfb
SS
192static void * __used
193stub_null(void)
17ea2221
MD
194{
195 return (NULL);
196}
197
82205bfb
SS
198static void * __used
199stub_self(void)
17ea2221 200{
82205bfb 201 static struct {} main_thread;
17ea2221 202
82205bfb 203 return (&main_thread);
17ea2221
MD
204}
205
82205bfb
SS
206static int __used
207stub_main(void)
ce0e08e2
PA
208{
209 return (-1);
210}
211
82205bfb
SS
212static int __used
213stub_true(void)
17ea2221 214{
82205bfb 215 return (1);
17ea2221
MD
216}
217
82205bfb
SS
218static void __used
219stub_exit(void)
17ea2221 220{
82205bfb 221 exit(0);
ce0e08e2 222}