libc: consolidate pthread stub functions
[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 $
19c7a913 27 * $DragonFly: src/lib/libc/gen/_pthread_stubs.c,v 1.4 2005/05/09 12:43:40 davidxu Exp $
17ea2221
MD
28 */
29
82205bfb
SS
30#include <sys/cdefs.h>
31#include <stdlib.h>
19c7a913 32
17ea2221
MD
33/*
34 * Weak symbols: All libc internal usage of these functions should
35 * use the weak symbol versions (_pthread_XXX). If libpthread is
36 * linked, it will override these functions with (non-weak) routines.
37 * The _pthread_XXX functions are provided solely for internal libc
38 * usage to avoid unwanted cancellation points and to differentiate
39 * between application locks and libc locks (threads holding the
40 * latter can't be allowed to exit/terminate).
41 */
ce0e08e2 42
82205bfb
SS
43#define WR(f, n) \
44 __weak_reference(f, _ ## n); \
45 __weak_reference(f, n)
46
47
48WR(stub_zero, pthread_atfork);
49WR(stub_zero, pthread_attr_destroy);
50WR(stub_zero, pthread_attr_get_np);
51WR(stub_zero, pthread_attr_getdetachstate);
52WR(stub_zero, pthread_attr_getguardsize);
53WR(stub_zero, pthread_attr_getinheritsched);
54WR(stub_zero, pthread_attr_getschedparam);
55WR(stub_zero, pthread_attr_getschedpolicy);
56WR(stub_zero, pthread_attr_getscope);
57WR(stub_zero, pthread_attr_getstack);
58WR(stub_zero, pthread_attr_getstackaddr);
59WR(stub_zero, pthread_attr_getstacksize);
60WR(stub_zero, pthread_attr_init);
61WR(stub_zero, pthread_attr_setcreatesuspend_np);
62WR(stub_zero, pthread_attr_setdetachstate);
63WR(stub_zero, pthread_attr_setguardsize);
64WR(stub_zero, pthread_attr_setinheritsched);
65WR(stub_zero, pthread_attr_setschedparam);
66WR(stub_zero, pthread_attr_setschedpolicy);
67WR(stub_zero, pthread_attr_setscope);
68WR(stub_zero, pthread_attr_setstack);
69WR(stub_zero, pthread_attr_setstackaddr);
70WR(stub_zero, pthread_attr_setstacksize);
71WR(stub_zero, pthread_barrier_destroy);
72WR(stub_zero, pthread_barrier_init);
73WR(stub_zero, pthread_barrier_wait);
74WR(stub_zero, pthread_barrierattr_destroy);
75WR(stub_zero, pthread_barrierattr_getpshared);
76WR(stub_zero, pthread_barrierattr_init);
77WR(stub_zero, pthread_barrierattr_setpshared);
78WR(stub_zero, pthread_cancel);
79WR(stub_zero, pthread_cleanup_pop);
80WR(stub_zero, pthread_cleanup_push);
81WR(stub_zero, pthread_cond_broadcast);
82WR(stub_zero, pthread_cond_destroy);
83WR(stub_zero, pthread_cond_init);
84WR(stub_zero, pthread_cond_signal);
85WR(stub_zero, pthread_cond_timedwait);
86WR(stub_zero, pthread_cond_wait);
87WR(stub_zero, pthread_condattr_destroy);
88WR(stub_zero, pthread_condattr_getclock);
89WR(stub_zero, pthread_condattr_getpshared);
90WR(stub_zero, pthread_condattr_init);
91WR(stub_zero, pthread_condattr_setclock);
92WR(stub_zero, pthread_condattr_setpshared);
93WR(stub_zero, pthread_detach);
94WR(stub_true, pthread_equal);
95WR(stub_exit, pthread_exit);
96WR(stub_zero, pthread_getconcurrency);
97WR(stub_zero, pthread_getprio);
98WR(stub_zero, pthread_getschedparam);
99WR(stub_null, pthread_getspecific);
100WR(stub_zero, pthread_join);
101WR(stub_zero, pthread_key_create);
102WR(stub_zero, pthread_key_delete);
103WR(stub_zero, pthread_kill);
104WR(stub_main, pthread_main_np);
105WR(stub_zero, pthread_multi_np);
106WR(stub_zero, pthread_mutex_destroy);
107WR(stub_zero, pthread_mutex_getprioceiling);
108WR(stub_zero, pthread_mutex_init);
109WR(stub_zero, pthread_mutex_lock);
110WR(stub_zero, pthread_mutex_setprioceiling);
111WR(stub_zero, pthread_mutex_timedlock);
112WR(stub_zero, pthread_mutex_trylock);
113WR(stub_zero, pthread_mutex_unlock);
114WR(stub_zero, pthread_mutexattr_destroy);
115WR(stub_zero, pthread_mutexattr_getkind_np);
116WR(stub_zero, pthread_mutexattr_getprioceiling);
117WR(stub_zero, pthread_mutexattr_getprotocol);
118WR(stub_zero, pthread_mutexattr_getpshared);
119WR(stub_zero, pthread_mutexattr_gettype);
120WR(stub_zero, pthread_mutexattr_init);
121WR(stub_zero, pthread_mutexattr_setkind_np);
122WR(stub_zero, pthread_mutexattr_setprioceiling);
123WR(stub_zero, pthread_mutexattr_setprotocol);
124WR(stub_zero, pthread_mutexattr_setpshared);
125WR(stub_zero, pthread_mutexattr_settype);
126WR(stub_zero, pthread_once);
127WR(stub_zero, pthread_resume_all_np);
128WR(stub_zero, pthread_resume_np);
129WR(stub_zero, pthread_rwlock_destroy);
130WR(stub_zero, pthread_rwlock_init);
131WR(stub_zero, pthread_rwlock_rdlock);
132WR(stub_zero, pthread_rwlock_timedrdlock);
133WR(stub_zero, pthread_rwlock_timedwrlock);
134WR(stub_zero, pthread_rwlock_tryrdlock);
135WR(stub_zero, pthread_rwlock_trywrlock);
136WR(stub_zero, pthread_rwlock_unlock);
137WR(stub_zero, pthread_rwlock_wrlock);
138WR(stub_zero, pthread_rwlockattr_destroy);
139WR(stub_zero, pthread_rwlockattr_getpshared);
140WR(stub_zero, pthread_rwlockattr_init);
141WR(stub_zero, pthread_rwlockattr_setpshared);
142WR(stub_self, pthread_self);
143WR(stub_zero, pthread_set_name_np);
144WR(stub_zero, pthread_setcancelstate);
145WR(stub_zero, pthread_setcanceltype);
146WR(stub_zero, pthread_setconcurrency);
147WR(stub_zero, pthread_setprio);
148WR(stub_zero, pthread_setschedparam);
149WR(stub_zero, pthread_setspecific);
150WR(stub_zero, pthread_sigmask);
151WR(stub_zero, pthread_single_np);
152WR(stub_zero, pthread_suspend_all_np);
153WR(stub_zero, pthread_suspend_np);
154WR(stub_zero, pthread_switch_add_np);
155WR(stub_zero, pthread_switch_delete_np);
156WR(stub_zero, pthread_testcancel);
157WR(stub_zero, pthread_timedjoin_np);
158WR(stub_zero, pthread_yield);
159WR(stub_zero, sched_yield);
160WR(stub_zero, sem_close);
161WR(stub_zero, sem_destroy);
162WR(stub_zero, sem_getvalue);
163WR(stub_zero, sem_init);
164WR(stub_zero, sem_open);
165WR(stub_zero, sem_post);
166WR(stub_zero, sem_trywait);
167WR(stub_zero, sem_unlink);
168WR(stub_zero, sem_wait);
169
170
171static int __used
172stub_zero(void)
173{
174 return (0);
175}
176
177static void * __used
178stub_null(void)
17ea2221
MD
179{
180 return (NULL);
181}
182
82205bfb
SS
183static void * __used
184stub_self(void)
17ea2221 185{
82205bfb 186 static struct {} main_thread;
17ea2221 187
82205bfb 188 return (&main_thread);
17ea2221
MD
189}
190
82205bfb
SS
191static int __used
192stub_main(void)
ce0e08e2
PA
193{
194 return (-1);
195}
196
82205bfb
SS
197static int __used
198stub_true(void)
17ea2221 199{
82205bfb 200 return (1);
17ea2221
MD
201}
202
82205bfb
SS
203static void __used
204stub_exit(void)
17ea2221 205{
82205bfb 206 exit(0);
ce0e08e2 207}