Loading...
--- Libc/Libc-825.26/stdlib/FreeBSD/exit.c
+++ Libc/Libc-763.13/stdlib/FreeBSD/exit.c
@@ -42,7 +42,15 @@
#include "libc_private.h"
void (*__cleanup)(void);
-extern void __exit(int);
+
+/*
+ * 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.
@@ -51,8 +59,13 @@
exit(status)
int status;
{
+ /* Ensure that the auto-initialization routine is linked in: */
+ extern int _thread_autoinit_dummy_decl;
+
+ _thread_autoinit_dummy_decl = 1;
+
__cxa_finalize(NULL);
if (__cleanup)
(*__cleanup)();
- __exit(status);
+ _exit(status);
}