diff options
| author | millert <> | 2007-09-03 14:40:16 +0000 |
|---|---|---|
| committer | millert <> | 2007-09-03 14:40:16 +0000 |
| commit | 7e0e6a2581ab1d1bca602865b8e38dfa2f54424a (patch) | |
| tree | 276e35092c38431624dd4e601442d98afb2a617d /src/lib/libc/stdlib/exit.c | |
| parent | 2056049ed6b7a028e611838a742280fced6d2c23 (diff) | |
| download | openbsd-7e0e6a2581ab1d1bca602865b8e38dfa2f54424a.tar.gz openbsd-7e0e6a2581ab1d1bca602865b8e38dfa2f54424a.tar.bz2 openbsd-7e0e6a2581ab1d1bca602865b8e38dfa2f54424a.zip | |
Add __cxa_atexit() support for gcc3. This provides support for shared object destructors called at dlclose() time. Inspired by similar changes in FreeBSD and NetBSD.
Diffstat (limited to 'src/lib/libc/stdlib/exit.c')
| -rw-r--r-- | src/lib/libc/stdlib/exit.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/lib/libc/stdlib/exit.c b/src/lib/libc/stdlib/exit.c index 90b7d5adc2..83fe3d2de5 100644 --- a/src/lib/libc/stdlib/exit.c +++ b/src/lib/libc/stdlib/exit.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: exit.c,v 1.11 2005/08/08 08:05:36 espie Exp $ */ | 1 | /* $OpenBSD: exit.c,v 1.12 2007/09/03 14:40:16 millert Exp $ */ |
| 2 | /*- | 2 | /*- |
| 3 | * Copyright (c) 1990 The Regents of the University of California. | 3 | * Copyright (c) 1990 The Regents of the University of California. |
| 4 | * All rights reserved. | 4 | * All rights reserved. |
| @@ -50,20 +50,10 @@ int __isthreaded = 0; | |||
| 50 | void | 50 | void |
| 51 | exit(int status) | 51 | exit(int status) |
| 52 | { | 52 | { |
| 53 | struct atexit *p, *q; | 53 | /* |
| 54 | int n, pgsize = getpagesize(); | 54 | * Call functions registered by atexit() or _cxa_atexit() |
| 55 | 55 | * (including the stdio cleanup routine) and then _exit(). | |
| 56 | if (!__atexit_invalid) { | 56 | */ |
| 57 | p = __atexit; | 57 | __cxa_finalize(NULL); |
| 58 | while (p != NULL) { | ||
| 59 | for (n = p->ind; --n >= 0;) | ||
| 60 | if (p->fns[n] != NULL) | ||
| 61 | (*p->fns[n])(); | ||
| 62 | q = p; | ||
| 63 | p = p->next; | ||
| 64 | munmap(q, pgsize); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | /* cleanup, if registered, was called through fns[0] in the last page */ | ||
| 68 | _exit(status); | 58 | _exit(status); |
| 69 | } | 59 | } |
