diff options
Diffstat (limited to 'stdlib/on_exit.c')
-rw-r--r-- | stdlib/on_exit.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/stdlib/on_exit.c b/stdlib/on_exit.c index 83845e76d8..f4ede2b1a7 100644 --- a/stdlib/on_exit.c +++ b/stdlib/on_exit.c @@ -17,25 +17,30 @@ #include <stdlib.h> #include "exit.h" -#include <atomic.h> #include <sysdep.h> /* Register a function to be called by exit. */ int __on_exit (void (*func) (int status, void *arg), void *arg) { - struct exit_function *new = __new_exitfn (&__exit_funcs); + struct exit_function *new; + + __libc_lock_lock (__exit_funcs_lock); + new = __new_exitfn (&__exit_funcs); if (new == NULL) - return -1; + { + __libc_lock_unlock (__exit_funcs_lock); + return -1; + } #ifdef PTR_MANGLE PTR_MANGLE (func); #endif new->func.on.fn = func; new->func.on.arg = arg; - atomic_write_barrier (); new->flavor = ef_on; + __libc_lock_unlock (__exit_funcs_lock); return 0; } weak_alias (__on_exit, on_exit) |