From 0d8f4028aff079cdb11c4fe2e8c7352a67d39dd2 Mon Sep 17 00:00:00 2001 From: jb Date: Wed, 29 Apr 1998 09:08:43 +0000 Subject: 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(+) (limited to 'lib/libc/stdlib/exit.c') diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c index 5df19dc..b0f6d3a 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])(); -- cgit v1.1