From 54fd7f685f42878f99a2e2d8428d084f9b1125ab Mon Sep 17 00:00:00 2001 From: Daniel Eischen Date: Tue, 10 Apr 2001 04:11:50 +0000 Subject: [PATCH] To be consistent, use the __weak_reference macro from instead of #pragma weak to create weak definitions. This macro is improperly named, though, since a weak definition is not the same thing as a weak reference. Suggested by: bde --- lib/libc/gen/_pthread_stubs.c | 53 +++++++++++++++++------------------ lib/libc/gen/_spinlock_stub.c | 7 +++-- lib/libc/gen/_thread_init.c | 6 ++-- lib/libc/stdio/_flock_stub.c | 8 +++--- lib/libc/sys/__error.c | 2 +- 5 files changed, 39 insertions(+), 37 deletions(-) diff --git a/lib/libc/gen/_pthread_stubs.c b/lib/libc/gen/_pthread_stubs.c index 478335902297..869574156a82 100644 --- a/lib/libc/gen/_pthread_stubs.c +++ b/lib/libc/gen/_pthread_stubs.c @@ -39,31 +39,31 @@ * between application locks and libc locks (threads holding the * latter can't be allowed to exit/terminate). */ -#pragma weak _pthread_cond_init=_pthread_cond_init_stub -#pragma weak _pthread_cond_signal=_pthread_cond_signal_stub -#pragma weak _pthread_cond_wait=_pthread_cond_wait_stub -#pragma weak _pthread_getspecific=_pthread_getspecific_stub -#pragma weak _pthread_key_create=_pthread_key_create_stub -#pragma weak _pthread_key_delete=_pthread_key_delete_stub -#pragma weak _pthread_main_np=_pthread_main_np_stub -#pragma weak _pthread_mutex_destroy=_pthread_mutex_destroy_stub -#pragma weak _pthread_mutex_init=_pthread_mutex_init_stub -#pragma weak _pthread_mutex_lock=_pthread_mutex_lock_stub -#pragma weak _pthread_mutex_trylock=_pthread_mutex_trylock_stub -#pragma weak _pthread_mutex_unlock=_pthread_mutex_unlock_stub -#pragma weak _pthread_mutexattr_init=_pthread_mutexattr_init_stub -#pragma weak _pthread_mutexattr_destroy=_pthread_mutexattr_destroy_stub -#pragma weak _pthread_mutexattr_settype=_pthread_mutexattr_settype_stub -#pragma weak _pthread_once=_pthread_once_stub -#pragma weak _pthread_self=_pthread_self_stub -#pragma weak _pthread_rwlock_init=_pthread_rwlock_init_stub -#pragma weak _pthread_rwlock_rdlock=_pthread_rwlock_rdlock_stub -#pragma weak _pthread_rwlock_tryrdlock=_pthread_rwlock_tryrdlock_stub -#pragma weak _pthread_rwlock_trywrloc=_pthread_rwlock_trywrlock_stub -#pragma weak _pthread_rwlock_unlock=_pthread_rwlock_unlock_stub -#pragma weak _pthread_rwlock_wrlock=_pthread_rwlock_wrlock_stub -#pragma weak _pthread_setspecific=_pthread_setspecific_stub -#pragma weak _pthread_sigmask=_pthread_sigmask_stub +__weak_reference(_pthread_cond_init_stub, _pthread_cond_init); +__weak_reference(_pthread_cond_signal_stub, _pthread_cond_signal); +__weak_reference(_pthread_cond_wait_stub, _pthread_cond_wait); +__weak_reference(_pthread_getspecific_stub, _pthread_getspecific); +__weak_reference(_pthread_key_create_stub, _pthread_key_create); +__weak_reference(_pthread_key_delete_stub, _pthread_key_delete); +__weak_reference(_pthread_main_np_stub, _pthread_main_np); +__weak_reference(_pthread_mutex_destroy_stub, _pthread_mutex_destroy); +__weak_reference(_pthread_mutex_init_stub, _pthread_mutex_init); +__weak_reference(_pthread_mutex_lock_stub, _pthread_mutex_lock); +__weak_reference(_pthread_mutex_trylock_stub, _pthread_mutex_trylock); +__weak_reference(_pthread_mutex_unlock_stub, _pthread_mutex_unlock); +__weak_reference(_pthread_mutexattr_init_stub, _pthread_mutexattr_init); +__weak_reference(_pthread_mutexattr_destroy_stub, _pthread_mutexattr_destroy); +__weak_reference(_pthread_mutexattr_settype_stub, _pthread_mutexattr_settype); +__weak_reference(_pthread_once_stub, _pthread_once); +__weak_reference(_pthread_self_stub, _pthread_self); +__weak_reference(_pthread_rwlock_init_stub, _pthread_rwlock_init); +__weak_reference(_pthread_rwlock_rdlock_stub, _pthread_rwlock_rdlock); +__weak_reference(_pthread_rwlock_tryrdlock_stub, _pthread_rwlock_tryrdlock); +__weak_reference(_pthread_rwlock_trywrlock_stub, _pthread_rwlock_trywrloc); +__weak_reference(_pthread_rwlock_unlock_stub, _pthread_rwlock_unlock); +__weak_reference(_pthread_rwlock_wrlock_stub, _pthread_rwlock_wrlock); +__weak_reference(_pthread_setspecific_stub, _pthread_setspecific); +__weak_reference(_pthread_sigmask_stub, _pthread_sigmask); /* Define a null pthread structure just to satisfy _pthread_self. */ struct pthread { @@ -85,8 +85,7 @@ _pthread_cond_signal_stub(pthread_cond_t *cond) } int -_pthread_cond_wait_stub(pthread_cond_t *cond, - pthread_mutex_t *mutex) +_pthread_cond_wait_stub(pthread_cond_t *cond, pthread_mutex_t *mutex) { return (0); } diff --git a/lib/libc/gen/_spinlock_stub.c b/lib/libc/gen/_spinlock_stub.c index 071fc206e53c..78c8dea496f5 100644 --- a/lib/libc/gen/_spinlock_stub.c +++ b/lib/libc/gen/_spinlock_stub.c @@ -41,9 +41,10 @@ * Declare weak definitions in case the application is not linked * with libpthread. */ -#pragma weak _atomic_lock=_atomic_lock_stub -#pragma weak _spinlock=_spinlock_stub -#pragma weak _spinlock_debug=_spinlock_debug_stub +__weak_reference(_atomic_lock_stub, _atomic_lock); +__weak_reference(_spinlock_stub, _spinlock); +__weak_reference(_spinlock_debug_stub, _spinlock_debug); + /* * This function is a stub for the _atomic_lock function in libpthread. diff --git a/lib/libc/gen/_thread_init.c b/lib/libc/gen/_thread_init.c index d6be5f22717c..1d2f15afed50 100644 --- a/lib/libc/gen/_thread_init.c +++ b/lib/libc/gen/_thread_init.c @@ -26,8 +26,10 @@ * $FreeBSD$ */ -#pragma weak _thread_init=_thread_init_stub -#pragma weak _thread_autoinit_dummy_decl=_thread_autoinit_dummy_decl_stub +#include + +__weak_reference(_thread_init_stub, _thread_init); +__weak_reference(_thread_autoinit_dummy_decl_stub, _thread_autoinit_dummy_decl); int _thread_autoinit_dummy_decl_stub = 0; diff --git a/lib/libc/stdio/_flock_stub.c b/lib/libc/stdio/_flock_stub.c index cc0cffeb2636..2be797a48ff2 100644 --- a/lib/libc/stdio/_flock_stub.c +++ b/lib/libc/stdio/_flock_stub.c @@ -53,10 +53,10 @@ /* * Weak symbols for externally visible functions in this file: */ -#pragma weak flockfile=_flockfile -#pragma weak _flockfile_debug=_flockfile_debug_stub -#pragma weak ftrylockfile=_ftrylockfile -#pragma weak funlockfile=_funlockfile +__weak_reference(_flockfile, flockfile); +__weak_reference(_flockfile_debug_stub, _flockfile_debug); +__weak_reference(_ftrylockfile, ftrylockfile); +__weak_reference(_funlockfile, funlockfile); /* * We need to retain binary compatibility for a while. So pretend diff --git a/lib/libc/sys/__error.c b/lib/libc/sys/__error.c index 8c14b0f75153..3641e77e0527 100644 --- a/lib/libc/sys/__error.c +++ b/lib/libc/sys/__error.c @@ -40,7 +40,7 @@ extern int errno; * Declare a weak reference in case the application is not linked * with libpthread. */ -#pragma weak __error=__error_unthreaded +__weak_reference(__error_unthreaded, __error); int * __error_unthreaded()