Merge commit 'origin/vendor/PAM_PASSWDQC'
[dragonfly.git] / lib / libc / gen / _pthread_stubs.c
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  *
26  * $FreeBSD: src/lib/libc/gen/_pthread_stubs.c,v 1.5 2001/06/11 23:18:22 iedowse Exp $
27  * $DragonFly: src/lib/libc/gen/_pthread_stubs.c,v 1.4 2005/05/09 12:43:40 davidxu Exp $
28  */
29
30 #include <signal.h>
31 #include <pthread.h>
32 #include <pthread_np.h>
33
34 int     _pthread_cond_init_stub(pthread_cond_t *, const pthread_condattr_t *);
35 int     _pthread_cond_signal_stub(pthread_cond_t *);
36 int     _pthread_cond_wait_stub(pthread_cond_t *, pthread_mutex_t *);
37 void    *_pthread_getspecific_stub(pthread_key_t);
38 int     _pthread_key_create_stub(pthread_key_t *, void (*)(void *));
39 int     _pthread_key_delete_stub(pthread_key_t);
40 int     _pthread_main_np_stub(void);
41 int     _pthread_mutex_destroy_stub(pthread_mutex_t *);
42 int     _pthread_mutex_init_stub(pthread_mutex_t *,
43                                  const pthread_mutexattr_t *);
44 int     _pthread_mutex_lock_stub(pthread_mutex_t *);
45 int     _pthread_mutex_trylock_stub(pthread_mutex_t *);
46 int     _pthread_mutex_unlock_stub(pthread_mutex_t *);
47 int     _pthread_mutexattr_init_stub(pthread_mutexattr_t *);
48 int     _pthread_mutexattr_destroy_stub(pthread_mutexattr_t *);
49 int     _pthread_mutexattr_settype_stub(pthread_mutexattr_t *, int);
50 int     _pthread_once_stub(pthread_once_t *, void (*)(void));
51 int     _pthread_rwlock_init_stub(pthread_rwlock_t *,
52                                   const pthread_rwlockattr_t *);
53 int     _pthread_rwlock_destroy_stub(pthread_rwlock_t *);
54 int     _pthread_rwlock_rdlock_stub(pthread_rwlock_t *);
55 int     _pthread_rwlock_tryrdlock_stub(pthread_rwlock_t *);
56 int     _pthread_rwlock_trywrlock_stub(pthread_rwlock_t *);
57 int     _pthread_rwlock_unlock_stub(pthread_rwlock_t *);
58 int     _pthread_rwlock_wrlock_stub(pthread_rwlock_t *);
59 int     _pthread_setspecific_stub(pthread_key_t, const void *);
60 int     _pthread_sigmask_stub(int, const sigset_t *, sigset_t *);
61
62 /* define a null pthread structure just to satisfy _pthread_self */
63 struct pthread {
64 };
65
66 static struct pthread main_thread;
67
68 /*
69  * Weak symbols: All libc internal usage of these functions should
70  * use the weak symbol versions (_pthread_XXX).  If libpthread is
71  * linked, it will override these functions with (non-weak) routines.
72  * The _pthread_XXX functions are provided solely for internal libc
73  * usage to avoid unwanted cancellation points and to differentiate
74  * between application locks and libc locks (threads holding the
75  * latter can't be allowed to exit/terminate).
76  */
77 __weak_reference(_pthread_cond_init_stub,       _pthread_cond_init);
78 __weak_reference(_pthread_cond_signal_stub,     _pthread_cond_signal);
79 __weak_reference(_pthread_cond_wait_stub,       _pthread_cond_wait);
80 __weak_reference(_pthread_getspecific_stub,     _pthread_getspecific);
81 __weak_reference(_pthread_key_create_stub,      _pthread_key_create);
82 __weak_reference(_pthread_key_delete_stub,      _pthread_key_delete);
83 __weak_reference(_pthread_main_np_stub,         _pthread_main_np);
84 __weak_reference(_pthread_mutex_destroy_stub,   _pthread_mutex_destroy);
85 __weak_reference(_pthread_mutex_init_stub,      _pthread_mutex_init);
86 __weak_reference(_pthread_mutex_lock_stub,      _pthread_mutex_lock);
87 __weak_reference(_pthread_mutex_trylock_stub,   _pthread_mutex_trylock);
88 __weak_reference(_pthread_mutex_unlock_stub,    _pthread_mutex_unlock);
89 __weak_reference(_pthread_mutexattr_init_stub,  _pthread_mutexattr_init);
90 __weak_reference(_pthread_mutexattr_destroy_stub, _pthread_mutexattr_destroy);
91 __weak_reference(_pthread_mutexattr_settype_stub, _pthread_mutexattr_settype);
92 __weak_reference(_pthread_once_stub,            _pthread_once);
93 __weak_reference(_pthread_self_stub,            _pthread_self);
94 __weak_reference(_pthread_rwlock_init_stub,     _pthread_rwlock_init);
95 __weak_reference(_pthread_rwlock_rdlock_stub,   _pthread_rwlock_rdlock);
96 __weak_reference(_pthread_rwlock_tryrdlock_stub, _pthread_rwlock_tryrdlock);
97 __weak_reference(_pthread_rwlock_trywrlock_stub, _pthread_rwlock_trywrlock);
98 __weak_reference(_pthread_rwlock_unlock_stub,   _pthread_rwlock_unlock);
99 __weak_reference(_pthread_rwlock_wrlock_stub,   _pthread_rwlock_wrlock);
100 __weak_reference(_pthread_setspecific_stub,     _pthread_setspecific);
101 __weak_reference(_pthread_sigmask_stub,         _pthread_sigmask);
102
103 int
104 _pthread_cond_init_stub(pthread_cond_t *cond __unused,
105                         const pthread_condattr_t *cond_attr __unused)
106 {
107         return (0);
108 }
109
110 int
111 _pthread_cond_signal_stub(pthread_cond_t *cond __unused)
112 {
113         return (0);
114 }
115
116 int
117 _pthread_cond_wait_stub(pthread_cond_t *cond __unused,
118                         pthread_mutex_t *mutex __unused)
119 {
120         return (0);
121 }
122
123 void *
124 _pthread_getspecific_stub(pthread_key_t key __unused)
125 {
126         return (NULL);
127 }
128
129 int
130 _pthread_key_create_stub(pthread_key_t *key __unused,
131                          void (*destructor) (void *) __unused)
132 {
133         return (0);
134 }
135
136 int
137 _pthread_key_delete_stub(pthread_key_t key __unused)
138 {
139         return (0);
140 }
141
142 int
143 _pthread_main_np_stub(void)
144 {
145         return (-1);
146 }
147
148 int
149 _pthread_mutex_destroy_stub(pthread_mutex_t *mattr __unused)
150 {
151         return (0);
152 }
153
154 int
155 _pthread_mutex_init_stub(pthread_mutex_t *mutex __unused,
156                          const pthread_mutexattr_t *mattr __unused)
157 {
158         return (0);
159 }
160
161 int
162 _pthread_mutex_lock_stub(pthread_mutex_t *mutex __unused)
163 {
164         return (0);
165 }
166
167 int
168 _pthread_mutex_trylock_stub(pthread_mutex_t *mutex __unused)
169 {
170         return (0);
171 }
172
173 int
174 _pthread_mutex_unlock_stub(pthread_mutex_t *mutex __unused)
175 {
176         return (0);
177 }
178
179 int
180 _pthread_mutexattr_init_stub(pthread_mutexattr_t *mattr __unused)
181 {
182         return (0);
183 }
184
185 int
186 _pthread_mutexattr_destroy_stub(pthread_mutexattr_t *mattr __unused)
187 {
188         return (0);
189 }
190
191 int
192 _pthread_mutexattr_settype_stub(pthread_mutexattr_t *mattr __unused,
193                                 int type __unused)
194 {
195         return (0);
196 }
197
198 int
199 _pthread_once_stub(pthread_once_t *once_control __unused,
200                    void (*init_routine) (void) __unused)
201 {
202         return (0);
203 }
204
205 int
206 _pthread_rwlock_init_stub(pthread_rwlock_t *rwlock __unused,
207                           const pthread_rwlockattr_t *attr __unused)
208 {
209         return (0);
210 }
211
212 int
213 _pthread_rwlock_destroy_stub(pthread_rwlock_t *rwlock __unused)
214 {
215         return (0);
216 }
217
218 int
219 _pthread_rwlock_rdlock_stub(pthread_rwlock_t *rwlock __unused)
220 {
221         return (0);
222 }
223
224 int
225 _pthread_rwlock_tryrdlock_stub(pthread_rwlock_t *rwlock __unused)
226 {
227         return (0);
228 }
229
230 int
231 _pthread_rwlock_trywrlock_stub(pthread_rwlock_t *rwlock __unused)
232 {
233         return (0);
234 }
235
236 int
237 _pthread_rwlock_unlock_stub(pthread_rwlock_t *rwlock __unused)
238 {
239         return (0);
240 }
241
242 int
243 _pthread_rwlock_wrlock_stub(pthread_rwlock_t *rwlock __unused)
244 {
245         return (0);
246 }
247
248 pthread_t
249 _pthread_self_stub(void)
250 {
251         return (&main_thread);
252 }
253 int
254 _pthread_setspecific_stub(pthread_key_t key __unused,
255                           const void *value __unused)
256 {
257         return (0);
258 }
259
260 int
261 _pthread_sigmask_stub(int how __unused, const sigset_t *set __unused,
262                       sigset_t *oset __unused)
263 {
264         return (0);
265 }