summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjb <jb@FreeBSD.org>1998-04-11 07:02:58 +0000
committerjb <jb@FreeBSD.org>1998-04-11 07:02:58 +0000
commit4c358b50ecd1504c9834001ecd5ea5046a375942 (patch)
tree91460af532b9b09d0aa7edaae8e9a743ea103cbd
parent475fa537796c6bc7939de4fc4bd1ce3a0be7aee6 (diff)
downloadFreeBSD-src-4c358b50ecd1504c9834001ecd5ea5046a375942.zip
FreeBSD-src-4c358b50ecd1504c9834001ecd5ea5046a375942.tar.gz
Add a global variable called __isthreaded that can be tested throughout
libc to determine if locking is required. This is needed in libc for use with kernel threads, but until a thread is created, we don't really want to bother locking things. The variable was added here because the crt code calls exit(main()) so all programs will get the variable.
-rw-r--r--lib/libc/stdlib/exit.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c
index a8f6e24..5df19dc 100644
--- a/lib/libc/stdlib/exit.c
+++ b/lib/libc/stdlib/exit.c
@@ -42,6 +42,15 @@ static char sccsid[] = "@(#)exit.c 8.1 (Berkeley) 6/4/93";
void (*__cleanup)();
/*
+ * This variable is zero until a process has created a thread.
+ * It is used to avoid calling locking functions in libc when they
+ * are not required. By default, libc is intended to be(come)
+ * thread-safe, but without a (significant) penalty to non-threaded
+ * processes.
+ */
+int __isthreaded = 0;
+
+/*
* Exit, flushing stdio buffers if necessary.
*/
void
OpenPOWER on IntegriCloud