_pthread_stubs.c (103576) | _pthread_stubs.c (106288) |
---|---|
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 --- 11 unchanged lines hidden (view full) --- 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 27#include <sys/cdefs.h> | 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 --- 11 unchanged lines hidden (view full) --- 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 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/lib/libc/gen/_pthread_stubs.c 103576 2002-09-19 01:09:49Z alfred $"); | 28__FBSDID("$FreeBSD: head/lib/libc/gen/_pthread_stubs.c 106288 2002-11-01 09:37:17Z dfr $"); |
29 30#include <signal.h> 31#include <pthread.h> 32#include <pthread_np.h> 33 | 29 30#include <signal.h> 31#include <pthread.h> 32#include <pthread_np.h> 33 |
34void *_pthread_getspecific(pthread_key_t key); 35pthread_t _pthread_self(void); 36 |
|
34/* 35 * Weak symbols: All libc internal usage of these functions should 36 * use the weak symbol versions (_pthread_XXX). If libpthread is 37 * linked, it will override these functions with (non-weak) routines. 38 * The _pthread_XXX functions are provided solely for internal libc 39 * usage to avoid unwanted cancellation points and to differentiate 40 * between application locks and libc locks (threads holding the 41 * latter can't be allowed to exit/terminate). | 37/* 38 * Weak symbols: All libc internal usage of these functions should 39 * use the weak symbol versions (_pthread_XXX). If libpthread is 40 * linked, it will override these functions with (non-weak) routines. 41 * The _pthread_XXX functions are provided solely for internal libc 42 * usage to avoid unwanted cancellation points and to differentiate 43 * between application locks and libc locks (threads holding the 44 * latter can't be allowed to exit/terminate). |
45 * 46 * We also provide weak pthread_XXX stubs which call their 47 * _pthread_XXX counterparts. These stubs may be used be other 48 * libraries for ensuring thread-safety without requiring the presence 49 * of a thread library. |
|
42 */ 43__weak_reference(_pthread_cond_init_stub, _pthread_cond_init); 44__weak_reference(_pthread_cond_signal_stub, _pthread_cond_signal); | 50 */ 51__weak_reference(_pthread_cond_init_stub, _pthread_cond_init); 52__weak_reference(_pthread_cond_signal_stub, _pthread_cond_signal); |
53__weak_reference(_pthread_cond_broadcast_stub, _pthread_cond_broadcast); |
|
45__weak_reference(_pthread_cond_wait_stub, _pthread_cond_wait); 46__weak_reference(_pthread_cond_destroy_stub, _pthread_cond_destroy); 47__weak_reference(_pthread_getspecific_stub, _pthread_getspecific); 48__weak_reference(_pthread_key_create_stub, _pthread_key_create); 49__weak_reference(_pthread_key_delete_stub, _pthread_key_delete); 50__weak_reference(_pthread_main_np_stub, _pthread_main_np); 51__weak_reference(_pthread_mutex_destroy_stub, _pthread_mutex_destroy); 52__weak_reference(_pthread_mutex_init_stub, _pthread_mutex_init); 53__weak_reference(_pthread_mutex_lock_stub, _pthread_mutex_lock); 54__weak_reference(_pthread_mutex_trylock_stub, _pthread_mutex_trylock); 55__weak_reference(_pthread_mutex_unlock_stub, _pthread_mutex_unlock); 56__weak_reference(_pthread_mutexattr_init_stub, _pthread_mutexattr_init); 57__weak_reference(_pthread_mutexattr_destroy_stub, _pthread_mutexattr_destroy); 58__weak_reference(_pthread_mutexattr_settype_stub, _pthread_mutexattr_settype); 59__weak_reference(_pthread_once_stub, _pthread_once); 60__weak_reference(_pthread_self_stub, _pthread_self); 61__weak_reference(_pthread_rwlock_init_stub, _pthread_rwlock_init); | 54__weak_reference(_pthread_cond_wait_stub, _pthread_cond_wait); 55__weak_reference(_pthread_cond_destroy_stub, _pthread_cond_destroy); 56__weak_reference(_pthread_getspecific_stub, _pthread_getspecific); 57__weak_reference(_pthread_key_create_stub, _pthread_key_create); 58__weak_reference(_pthread_key_delete_stub, _pthread_key_delete); 59__weak_reference(_pthread_main_np_stub, _pthread_main_np); 60__weak_reference(_pthread_mutex_destroy_stub, _pthread_mutex_destroy); 61__weak_reference(_pthread_mutex_init_stub, _pthread_mutex_init); 62__weak_reference(_pthread_mutex_lock_stub, _pthread_mutex_lock); 63__weak_reference(_pthread_mutex_trylock_stub, _pthread_mutex_trylock); 64__weak_reference(_pthread_mutex_unlock_stub, _pthread_mutex_unlock); 65__weak_reference(_pthread_mutexattr_init_stub, _pthread_mutexattr_init); 66__weak_reference(_pthread_mutexattr_destroy_stub, _pthread_mutexattr_destroy); 67__weak_reference(_pthread_mutexattr_settype_stub, _pthread_mutexattr_settype); 68__weak_reference(_pthread_once_stub, _pthread_once); 69__weak_reference(_pthread_self_stub, _pthread_self); 70__weak_reference(_pthread_rwlock_init_stub, _pthread_rwlock_init); |
71__weak_reference(_pthread_rwlock_destroy_stub, _pthread_rwlock_destroy); |
|
62__weak_reference(_pthread_rwlock_rdlock_stub, _pthread_rwlock_rdlock); 63__weak_reference(_pthread_rwlock_tryrdlock_stub, _pthread_rwlock_tryrdlock); | 72__weak_reference(_pthread_rwlock_rdlock_stub, _pthread_rwlock_rdlock); 73__weak_reference(_pthread_rwlock_tryrdlock_stub, _pthread_rwlock_tryrdlock); |
64__weak_reference(_pthread_rwlock_trywrlock_stub, _pthread_rwlock_trywrloc); | 74__weak_reference(_pthread_rwlock_trywrlock_stub, _pthread_rwlock_trywrlock); |
65__weak_reference(_pthread_rwlock_unlock_stub, _pthread_rwlock_unlock); 66__weak_reference(_pthread_rwlock_wrlock_stub, _pthread_rwlock_wrlock); 67__weak_reference(_pthread_setspecific_stub, _pthread_setspecific); 68__weak_reference(_pthread_sigmask_stub, _pthread_sigmask); 69 | 75__weak_reference(_pthread_rwlock_unlock_stub, _pthread_rwlock_unlock); 76__weak_reference(_pthread_rwlock_wrlock_stub, _pthread_rwlock_wrlock); 77__weak_reference(_pthread_setspecific_stub, _pthread_setspecific); 78__weak_reference(_pthread_sigmask_stub, _pthread_sigmask); 79 |
80__weak_reference(pthread_cond_init_stub, pthread_cond_init); 81__weak_reference(pthread_cond_signal_stub, pthread_cond_signal); 82__weak_reference(pthread_cond_broadcast_stub, pthread_cond_broadcast); 83__weak_reference(pthread_cond_wait_stub, pthread_cond_wait); 84__weak_reference(pthread_cond_destroy_stub, pthread_cond_destroy); 85__weak_reference(pthread_getspecific_stub, pthread_getspecific); 86__weak_reference(pthread_key_create_stub, pthread_key_create); 87__weak_reference(pthread_key_delete_stub, pthread_key_delete); 88__weak_reference(pthread_main_np_stub, pthread_main_np); 89__weak_reference(pthread_mutex_destroy_stub, pthread_mutex_destroy); 90__weak_reference(pthread_mutex_init_stub, pthread_mutex_init); 91__weak_reference(pthread_mutex_lock_stub, pthread_mutex_lock); 92__weak_reference(pthread_mutex_trylock_stub, pthread_mutex_trylock); 93__weak_reference(pthread_mutex_unlock_stub, pthread_mutex_unlock); 94__weak_reference(pthread_mutexattr_init_stub, pthread_mutexattr_init); 95__weak_reference(pthread_mutexattr_destroy_stub, pthread_mutexattr_destroy); 96__weak_reference(pthread_mutexattr_settype_stub, pthread_mutexattr_settype); 97__weak_reference(pthread_once_stub, pthread_once); 98__weak_reference(pthread_self_stub, pthread_self); 99__weak_reference(pthread_rwlock_init_stub, pthread_rwlock_init); 100__weak_reference(pthread_rwlock_destroy_stub, pthread_rwlock_destroy); 101__weak_reference(pthread_rwlock_rdlock_stub, pthread_rwlock_rdlock); 102__weak_reference(pthread_rwlock_tryrdlock_stub, pthread_rwlock_tryrdlock); 103__weak_reference(pthread_rwlock_trywrlock_stub, pthread_rwlock_trywrlock); 104__weak_reference(pthread_rwlock_unlock_stub, pthread_rwlock_unlock); 105__weak_reference(pthread_rwlock_wrlock_stub, pthread_rwlock_wrlock); 106__weak_reference(pthread_setspecific_stub, pthread_setspecific); 107__weak_reference(pthread_sigmask_stub, pthread_sigmask); 108 |
|
70/* Define a null pthread structure just to satisfy _pthread_self. */ 71struct pthread { 72}; 73 74static struct pthread main_thread; 75 | 109/* Define a null pthread structure just to satisfy _pthread_self. */ 110struct pthread { 111}; 112 113static struct pthread main_thread; 114 |
76int | 115static int |
77_pthread_cond_init_stub(pthread_cond_t *cond, 78 const pthread_condattr_t *cond_attr) 79{ 80 return (0); 81} 82 | 116_pthread_cond_init_stub(pthread_cond_t *cond, 117 const pthread_condattr_t *cond_attr) 118{ 119 return (0); 120} 121 |
83int | 122static int |
84_pthread_cond_signal_stub(pthread_cond_t *cond) 85{ 86 return (0); 87} 88 | 123_pthread_cond_signal_stub(pthread_cond_t *cond) 124{ 125 return (0); 126} 127 |
89int | 128static int 129_pthread_cond_broadcast_stub(pthread_cond_t *cond) 130{ 131 return (0); 132} 133 134static int |
90_pthread_cond_wait_stub(pthread_cond_t *cond, pthread_mutex_t *mutex) 91{ 92 return (0); 93} 94 | 135_pthread_cond_wait_stub(pthread_cond_t *cond, pthread_mutex_t *mutex) 136{ 137 return (0); 138} 139 |
95int | 140static int |
96_pthread_cond_destroy_stub(pthread_cond_t *cond) 97{ 98 return (0); 99} 100 | 141_pthread_cond_destroy_stub(pthread_cond_t *cond) 142{ 143 return (0); 144} 145 |
101void * | 146static void * |
102_pthread_getspecific_stub(pthread_key_t key) 103{ 104 return (NULL); 105} 106 | 147_pthread_getspecific_stub(pthread_key_t key) 148{ 149 return (NULL); 150} 151 |
107int | 152static int |
108_pthread_key_create_stub(pthread_key_t *key, void (*destructor) (void *)) 109{ 110 return (0); 111} 112 | 153_pthread_key_create_stub(pthread_key_t *key, void (*destructor) (void *)) 154{ 155 return (0); 156} 157 |
113int | 158static int |
114_pthread_key_delete_stub(pthread_key_t key) 115{ 116 return (0); 117} 118 | 159_pthread_key_delete_stub(pthread_key_t key) 160{ 161 return (0); 162} 163 |
119int | 164static int |
120_pthread_main_np_stub() 121{ 122 return (-1); 123} 124 | 165_pthread_main_np_stub() 166{ 167 return (-1); 168} 169 |
125int | 170static int |
126_pthread_mutex_destroy_stub(pthread_mutex_t *mattr) 127{ 128 return (0); 129} 130 | 171_pthread_mutex_destroy_stub(pthread_mutex_t *mattr) 172{ 173 return (0); 174} 175 |
131int | 176static int |
132_pthread_mutex_init_stub(pthread_mutex_t *mutex, const pthread_mutexattr_t *mattr) 133{ 134 return (0); 135} 136 | 177_pthread_mutex_init_stub(pthread_mutex_t *mutex, const pthread_mutexattr_t *mattr) 178{ 179 return (0); 180} 181 |
137int | 182static int |
138_pthread_mutex_lock_stub(pthread_mutex_t *mutex) 139{ 140 return (0); 141} 142 | 183_pthread_mutex_lock_stub(pthread_mutex_t *mutex) 184{ 185 return (0); 186} 187 |
143int | 188static int |
144_pthread_mutex_trylock_stub(pthread_mutex_t *mutex) 145{ 146 return (0); 147} 148 | 189_pthread_mutex_trylock_stub(pthread_mutex_t *mutex) 190{ 191 return (0); 192} 193 |
149int | 194static int |
150_pthread_mutex_unlock_stub(pthread_mutex_t *mutex) 151{ 152 return (0); 153} 154 | 195_pthread_mutex_unlock_stub(pthread_mutex_t *mutex) 196{ 197 return (0); 198} 199 |
155int | 200static int |
156_pthread_mutexattr_init_stub(pthread_mutexattr_t *mattr) 157{ 158 return (0); 159} 160 | 201_pthread_mutexattr_init_stub(pthread_mutexattr_t *mattr) 202{ 203 return (0); 204} 205 |
161int | 206static int |
162_pthread_mutexattr_destroy_stub(pthread_mutexattr_t *mattr) 163{ 164 return (0); 165} 166 | 207_pthread_mutexattr_destroy_stub(pthread_mutexattr_t *mattr) 208{ 209 return (0); 210} 211 |
167int | 212static int |
168_pthread_mutexattr_settype_stub(pthread_mutexattr_t *mattr, int type) 169{ 170 return (0); 171} 172 | 213_pthread_mutexattr_settype_stub(pthread_mutexattr_t *mattr, int type) 214{ 215 return (0); 216} 217 |
173int | 218static int |
174_pthread_once_stub(pthread_once_t *once_control, void (*init_routine) (void)) 175{ 176 return (0); 177} 178 | 219_pthread_once_stub(pthread_once_t *once_control, void (*init_routine) (void)) 220{ 221 return (0); 222} 223 |
179int | 224static int |
180_pthread_rwlock_init_stub(pthread_rwlock_t *rwlock, 181 const pthread_rwlockattr_t *attr) 182{ 183 return (0); 184} 185 | 225_pthread_rwlock_init_stub(pthread_rwlock_t *rwlock, 226 const pthread_rwlockattr_t *attr) 227{ 228 return (0); 229} 230 |
186int | 231static int |
187_pthread_rwlock_destroy_stub(pthread_rwlock_t *rwlock) 188{ 189 return (0); 190} 191 | 232_pthread_rwlock_destroy_stub(pthread_rwlock_t *rwlock) 233{ 234 return (0); 235} 236 |
192int | 237static int |
193_pthread_rwlock_rdlock_stub(pthread_rwlock_t *rwlock) 194{ 195 return (0); 196} 197 | 238_pthread_rwlock_rdlock_stub(pthread_rwlock_t *rwlock) 239{ 240 return (0); 241} 242 |
198int | 243static int |
199_pthread_rwlock_tryrdlock_stub(pthread_rwlock_t *rwlock) 200{ 201 return (0); 202} 203 | 244_pthread_rwlock_tryrdlock_stub(pthread_rwlock_t *rwlock) 245{ 246 return (0); 247} 248 |
204int | 249static int |
205_pthread_rwlock_trywrlock_stub(pthread_rwlock_t *rwlock) 206{ 207 return (0); 208} 209 | 250_pthread_rwlock_trywrlock_stub(pthread_rwlock_t *rwlock) 251{ 252 return (0); 253} 254 |
210int | 255static int |
211_pthread_rwlock_unlock_stub(pthread_rwlock_t *rwlock) 212{ 213 return (0); 214} 215 | 256_pthread_rwlock_unlock_stub(pthread_rwlock_t *rwlock) 257{ 258 return (0); 259} 260 |
216int | 261static int |
217_pthread_rwlock_wrlock_stub(pthread_rwlock_t *rwlock) 218{ 219 return (0); 220} 221 | 262_pthread_rwlock_wrlock_stub(pthread_rwlock_t *rwlock) 263{ 264 return (0); 265} 266 |
222pthread_t | 267static pthread_t |
223_pthread_self_stub(void) 224{ 225 return (&main_thread); 226} 227 | 268_pthread_self_stub(void) 269{ 270 return (&main_thread); 271} 272 |
228int | 273static int |
229_pthread_setspecific_stub(pthread_key_t key, const void *value) 230{ 231 return (0); 232} 233 | 274_pthread_setspecific_stub(pthread_key_t key, const void *value) 275{ 276 return (0); 277} 278 |
234int | 279static int |
235_pthread_sigmask_stub(int how, const sigset_t *set, sigset_t *oset) 236{ 237 return (0); 238} | 280_pthread_sigmask_stub(int how, const sigset_t *set, sigset_t *oset) 281{ 282 return (0); 283} |
284 285static int 286pthread_cond_init_stub(pthread_cond_t *cond, 287 const pthread_condattr_t *cond_attr) 288{ 289 return (_pthread_cond_init(cond, cond_attr)); 290} 291 292static int 293pthread_cond_signal_stub(pthread_cond_t *cond) 294{ 295 return (_pthread_cond_signal(cond)); 296} 297 298static int 299pthread_cond_broadcast_stub(pthread_cond_t *cond) 300{ 301 return (_pthread_cond_broadcast(cond)); 302} 303 304static int 305pthread_cond_wait_stub(pthread_cond_t *cond, pthread_mutex_t *mutex) 306{ 307 return (_pthread_cond_wait(cond, mutex)); 308} 309 310static int 311pthread_cond_destroy_stub(pthread_cond_t *cond) 312{ 313 return (_pthread_cond_destroy(cond)); 314} 315 316static void * 317pthread_getspecific_stub(pthread_key_t key) 318{ 319 return (_pthread_getspecific(key)); 320} 321 322static int 323pthread_key_create_stub(pthread_key_t *key, void (*destructor) (void *)) 324{ 325 return (_pthread_key_create(key, destructor)); 326} 327 328static int 329pthread_key_delete_stub(pthread_key_t key) 330{ 331 return (_pthread_key_delete(key)); 332} 333 334static int 335pthread_main_np_stub() 336{ 337 return (_pthread_main_np()); 338} 339 340static int 341pthread_mutex_destroy_stub(pthread_mutex_t *mattr) 342{ 343 return (_pthread_mutex_destroy(mattr)); 344} 345 346static int 347pthread_mutex_init_stub(pthread_mutex_t *mutex, const pthread_mutexattr_t *mattr) 348{ 349 return (_pthread_mutex_init(mutex, mattr)); 350} 351 352static int 353pthread_mutex_lock_stub(pthread_mutex_t *mutex) 354{ 355 return (_pthread_mutex_lock(mutex)); 356} 357 358static int 359pthread_mutex_trylock_stub(pthread_mutex_t *mutex) 360{ 361 return (_pthread_mutex_trylock(mutex)); 362} 363 364static int 365pthread_mutex_unlock_stub(pthread_mutex_t *mutex) 366{ 367 return (_pthread_mutex_unlock(mutex)); 368} 369 370static int 371pthread_mutexattr_init_stub(pthread_mutexattr_t *mattr) 372{ 373 return (_pthread_mutexattr_init(mattr)); 374} 375 376static int 377pthread_mutexattr_destroy_stub(pthread_mutexattr_t *mattr) 378{ 379 return (_pthread_mutexattr_destroy(mattr)); 380} 381 382static int 383pthread_mutexattr_settype_stub(pthread_mutexattr_t *mattr, int type) 384{ 385 return (_pthread_mutexattr_settype(mattr, type)); 386} 387 388static int 389pthread_once_stub(pthread_once_t *once_control, void (*init_routine) (void)) 390{ 391 return (_pthread_once(once_control, init_routine)); 392} 393 394static int 395pthread_rwlock_init_stub(pthread_rwlock_t *rwlock, 396 const pthread_rwlockattr_t *attr) 397{ 398 return (_pthread_rwlock_init(rwlock, attr)); 399} 400 401static int 402pthread_rwlock_destroy_stub(pthread_rwlock_t *rwlock) 403{ 404 return (_pthread_rwlock_destroy(rwlock)); 405} 406 407static int 408pthread_rwlock_rdlock_stub(pthread_rwlock_t *rwlock) 409{ 410 return (_pthread_rwlock_rdlock(rwlock)); 411} 412 413static int 414pthread_rwlock_tryrdlock_stub(pthread_rwlock_t *rwlock) 415{ 416 return (_pthread_rwlock_tryrdlock(rwlock)); 417} 418 419static int 420pthread_rwlock_trywrlock_stub(pthread_rwlock_t *rwlock) 421{ 422 return (_pthread_rwlock_trywrlock(rwlock)); 423} 424 425static int 426pthread_rwlock_unlock_stub(pthread_rwlock_t *rwlock) 427{ 428 return (_pthread_rwlock_unlock(rwlock)); 429} 430 431static int 432pthread_rwlock_wrlock_stub(pthread_rwlock_t *rwlock) 433{ 434 return (_pthread_rwlock_wrlock(rwlock)); 435} 436 437static pthread_t 438pthread_self_stub(void) 439{ 440 return (_pthread_self()); 441} 442 443static int 444pthread_setspecific_stub(pthread_key_t key, const void *value) 445{ 446 return (_pthread_setspecific(key, value)); 447} 448 449static int 450pthread_sigmask_stub(int how, const sigset_t *set, sigset_t *oset) 451{ 452 return (_pthread_sigmask(how, set, oset)); 453} |
|