summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/_spinlock_stub.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2001-01-24 13:01:12 +0000
committerdeischen <deischen@FreeBSD.org>2001-01-24 13:01:12 +0000
commit1635c221b7b2678beeeb2b5fa728edd7c8c3735b (patch)
treed7d4f61b9e319a781a335702fe846592726c22b9 /lib/libc/gen/_spinlock_stub.c
parent08685e9e9fd9de1e8dc51cada55659344adaf0cc (diff)
downloadFreeBSD-src-1635c221b7b2678beeeb2b5fa728edd7c8c3735b.zip
FreeBSD-src-1635c221b7b2678beeeb2b5fa728edd7c8c3735b.tar.gz
Remove _THREAD_SAFE and make libc thread-safe by default by
adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch
Diffstat (limited to 'lib/libc/gen/_spinlock_stub.c')
-rw-r--r--lib/libc/gen/_spinlock_stub.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/libc/gen/_spinlock_stub.c b/lib/libc/gen/_spinlock_stub.c
index e3a800d..071fc20 100644
--- a/lib/libc/gen/_spinlock_stub.c
+++ b/lib/libc/gen/_spinlock_stub.c
@@ -35,18 +35,27 @@
#include <stdio.h>
-/* Don't build these stubs into libc_r: */
-#ifndef _THREAD_SAFE
#include "spinlock.h"
/*
- * Declare weak references in case the application is not linked
+ * 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
/*
+ * This function is a stub for the _atomic_lock function in libpthread.
+ */
+long
+_atomic_lock_stub(volatile long *lck)
+{
+ return (0L);
+}
+
+
+/*
* This function is a stub for the spinlock function in libpthread.
*/
void
@@ -61,4 +70,3 @@ void
_spinlock_debug_stub(spinlock_t *lck, char *fname, int lineno)
{
}
-#endif
OpenPOWER on IntegriCloud