2 * Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
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 $
32 #include <pthread_np.h>
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
*);
62 /* define a null pthread structure just to satisfy _pthread_self */
66 static struct pthread main_thread
;
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).
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
);
104 _pthread_cond_init_stub(pthread_cond_t
*cond __unused
,
105 const pthread_condattr_t
*cond_attr __unused
)
111 _pthread_cond_signal_stub(pthread_cond_t
*cond __unused
)
117 _pthread_cond_wait_stub(pthread_cond_t
*cond __unused
,
118 pthread_mutex_t
*mutex __unused
)
124 _pthread_getspecific_stub(pthread_key_t key __unused
)
130 _pthread_key_create_stub(pthread_key_t
*key __unused
,
131 void (*destructor
) (void *) __unused
)
137 _pthread_key_delete_stub(pthread_key_t key __unused
)
143 _pthread_main_np_stub(void)
149 _pthread_mutex_destroy_stub(pthread_mutex_t
*mattr __unused
)
155 _pthread_mutex_init_stub(pthread_mutex_t
*mutex __unused
,
156 const pthread_mutexattr_t
*mattr __unused
)
162 _pthread_mutex_lock_stub(pthread_mutex_t
*mutex __unused
)
168 _pthread_mutex_trylock_stub(pthread_mutex_t
*mutex __unused
)
174 _pthread_mutex_unlock_stub(pthread_mutex_t
*mutex __unused
)
180 _pthread_mutexattr_init_stub(pthread_mutexattr_t
*mattr __unused
)
186 _pthread_mutexattr_destroy_stub(pthread_mutexattr_t
*mattr __unused
)
192 _pthread_mutexattr_settype_stub(pthread_mutexattr_t
*mattr __unused
,
199 _pthread_once_stub(pthread_once_t
*once_control __unused
,
200 void (*init_routine
) (void) __unused
)
206 _pthread_rwlock_init_stub(pthread_rwlock_t
*rwlock __unused
,
207 const pthread_rwlockattr_t
*attr __unused
)
213 _pthread_rwlock_destroy_stub(pthread_rwlock_t
*rwlock __unused
)
219 _pthread_rwlock_rdlock_stub(pthread_rwlock_t
*rwlock __unused
)
225 _pthread_rwlock_tryrdlock_stub(pthread_rwlock_t
*rwlock __unused
)
231 _pthread_rwlock_trywrlock_stub(pthread_rwlock_t
*rwlock __unused
)
237 _pthread_rwlock_unlock_stub(pthread_rwlock_t
*rwlock __unused
)
243 _pthread_rwlock_wrlock_stub(pthread_rwlock_t
*rwlock __unused
)
249 _pthread_self_stub(void)
251 return (&main_thread
);
254 _pthread_setspecific_stub(pthread_key_t key __unused
,
255 const void *value __unused
)
261 _pthread_sigmask_stub(int how __unused
, const sigset_t
*set __unused
,
262 sigset_t
*oset __unused
)