From 96c76d66dbe7eb660f3d27ca616d2f9d91dbaae6 Mon Sep 17 00:00:00 2001 From: John Birrell Date: Wed, 29 Apr 1998 09:08:43 +0000 Subject: [PATCH] Reference an external variable in threaded programs so that the autoinitialiser gets linked in and therefore called before main(). --- lib/libc/stdlib/exit.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c index 5df19dc1bd4a..b0f6d3a51882 100644 --- a/lib/libc/stdlib/exit.c +++ b/lib/libc/stdlib/exit.c @@ -60,6 +60,12 @@ exit(status) register struct atexit *p; register int n; +#ifdef _THREAD_SAFE + extern int _thread_autoinit_dummy_decl; + /* Ensure that the auto-initialization routine is linked in: */ + _thread_autoinit_dummy_decl = 1; +#endif + for (p = __atexit; p; p = p->next) for (n = p->ind; --n >= 0;) (*p->fns[n])();