diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2013-06-02 21:08:37 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2013-06-02 21:08:37 +0000 |
commit | c539e28317cab718c896f9bf699bc7d821dfdaf4 (patch) | |
tree | 58d5786b179a298bd6eb43bd6bbe6b5bd5ac65d9 /lib/libc/stdlib | |
parent | 6aa0871199c60f997a2537be5a932b64e2503330 (diff) |
Two small cleanups to atexit: remove unneeded __atexit_invalid, and
move the call_depth decrement so it happens unconditionally and can
still return to 0 when called with dso!=NULL.
ok millert
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r-- | lib/libc/stdlib/atexit.c | 14 | ||||
-rw-r--r-- | lib/libc/stdlib/atexit.h | 3 |
2 files changed, 5 insertions, 12 deletions
diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c index e28ccf29d0d..52f1cf3c5c7 100644 --- a/lib/libc/stdlib/atexit.c +++ b/lib/libc/stdlib/atexit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atexit.c,v 1.15 2011/03/02 18:34:05 matthew Exp $ */ +/* $OpenBSD: atexit.c,v 1.16 2013/06/02 21:08:36 matthew Exp $ */ /* * Copyright (c) 2002 Daniel Hartmeier * All rights reserved. @@ -37,7 +37,6 @@ #include "atexit.h" #include "thread_private.h" -int __atexit_invalid = 1; struct atexit *__atexit; /* @@ -89,8 +88,6 @@ __cxa_atexit(void (*func)(void *), void *arg, void *dso) sizeof(p->fns[0]); p->next = __atexit; __atexit = p; - if (__atexit_invalid) - __atexit_invalid = 0; } fnp = &p->fns[p->ind++]; fnp->fn_ptr.cxa_func = func; @@ -126,9 +123,6 @@ __cxa_finalize(void *dso) int n, pgsize = getpagesize(); static int call_depth; - if (__atexit_invalid) - return; - call_depth++; for (p = __atexit; p != NULL; p = p->next) { @@ -154,12 +148,14 @@ __cxa_finalize(void *dso) } } + call_depth--; + /* * If called via exit(), unmap the pages since we have now run * all the handlers. We defer this until calldepth == 0 so that * we don't unmap things prematurely if called recursively. */ - if (dso == NULL && --call_depth == 0) { + if (dso == NULL && call_depth == 0) { for (p = __atexit; p != NULL; ) { q = p; p = p->next; @@ -194,8 +190,6 @@ __atexit_register_cleanup(void (*func)(void)) sizeof(p->fns[0]); p->next = NULL; __atexit = p; - if (__atexit_invalid) - __atexit_invalid = 0; } else { if (mprotect(p, pgsize, PROT_READ | PROT_WRITE)) goto unlock; diff --git a/lib/libc/stdlib/atexit.h b/lib/libc/stdlib/atexit.h index 1b23565dd06..c44005deda5 100644 --- a/lib/libc/stdlib/atexit.h +++ b/lib/libc/stdlib/atexit.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atexit.h,v 1.7 2007/09/03 14:40:16 millert Exp $ */ +/* $OpenBSD: atexit.h,v 1.8 2013/06/02 21:08:36 matthew Exp $ */ /* * Copyright (c) 2002 Daniel Hartmeier @@ -44,7 +44,6 @@ struct atexit { } fns[1]; /* the table itself */ }; -extern int __atexit_invalid; extern struct atexit *__atexit; /* points to head of LIFO stack */ int __cxa_atexit(void (*)(void *), void *, void *); |