diff options
| author | guenther <> | 2017-12-16 20:06:56 +0000 |
|---|---|---|
| committer | guenther <> | 2017-12-16 20:06:56 +0000 |
| commit | 09687c04dc436ea29235c588185e43443b906e9f (patch) | |
| tree | 2fa5dfadabf13e01a2eeaa103c96c8e3c59c40c9 /src/lib/libc/stdlib/atexit.c | |
| parent | 95bd5261c689f60078c0b683fa28a76360fb28e4 (diff) | |
| download | openbsd-09687c04dc436ea29235c588185e43443b906e9f.tar.gz openbsd-09687c04dc436ea29235c588185e43443b906e9f.tar.bz2 openbsd-09687c04dc436ea29235c588185e43443b906e9f.zip | |
Move __cxa_thread_atexit* to its own .c file to avoid pulling the code
(w/ _dlctl reference) into static executables. It's all Mark's code so
put his preferred copyright on it.
ok kettenis@
Diffstat (limited to 'src/lib/libc/stdlib/atexit.c')
| -rw-r--r-- | src/lib/libc/stdlib/atexit.c | 39 |
1 files changed, 3 insertions, 36 deletions
diff --git a/src/lib/libc/stdlib/atexit.c b/src/lib/libc/stdlib/atexit.c index fe4d5bc79f..ea9dd129c1 100644 --- a/src/lib/libc/stdlib/atexit.c +++ b/src/lib/libc/stdlib/atexit.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: atexit.c,v 1.26 2017/12/05 21:11:10 kettenis Exp $ */ | 1 | /* $OpenBSD: atexit.c,v 1.27 2017/12/16 20:06:56 guenther Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2002 Daniel Hartmeier | 3 | * Copyright (c) 2002 Daniel Hartmeier |
| 4 | * All rights reserved. | 4 | * All rights reserved. |
| @@ -31,24 +31,14 @@ | |||
| 31 | 31 | ||
| 32 | #include <sys/types.h> | 32 | #include <sys/types.h> |
| 33 | #include <sys/mman.h> | 33 | #include <sys/mman.h> |
| 34 | #include <dlfcn.h> | ||
| 35 | #include <elf.h> | ||
| 36 | #pragma weak _DYNAMIC | ||
| 37 | #include <stdlib.h> | 34 | #include <stdlib.h> |
| 38 | #include <string.h> | 35 | #include <string.h> |
| 36 | #include <tib.h> | ||
| 39 | #include <unistd.h> | 37 | #include <unistd.h> |
| 38 | |||
| 40 | #include "atexit.h" | 39 | #include "atexit.h" |
| 41 | #include "atfork.h" | 40 | #include "atfork.h" |
| 42 | #include "thread_private.h" | 41 | #include "thread_private.h" |
| 43 | #include "tib.h" | ||
| 44 | |||
| 45 | typeof(dlctl) dlctl asm("_dlctl") __attribute__((weak)); | ||
| 46 | |||
| 47 | struct thread_atexit_fn { | ||
| 48 | void (*func)(void *); | ||
| 49 | void *arg; | ||
| 50 | struct thread_atexit_fn *next; | ||
| 51 | }; | ||
| 52 | 42 | ||
| 53 | struct atexit *__atexit; | 43 | struct atexit *__atexit; |
| 54 | static int restartloop; | 44 | static int restartloop; |
| @@ -133,29 +123,6 @@ atexit(void (*fn)(void)) | |||
| 133 | } | 123 | } |
| 134 | DEF_STRONG(atexit); | 124 | DEF_STRONG(atexit); |
| 135 | 125 | ||
| 136 | __weak_alias(__cxa_thread_atexit, __cxa_thread_atexit_impl); | ||
| 137 | |||
| 138 | int | ||
| 139 | __cxa_thread_atexit_impl(void (*func)(void *), void *arg, void *dso) | ||
| 140 | { | ||
| 141 | struct thread_atexit_fn *fnp; | ||
| 142 | struct tib *tib = TIB_GET(); | ||
| 143 | |||
| 144 | fnp = calloc(1, sizeof(struct thread_atexit_fn)); | ||
| 145 | if (fnp == NULL) | ||
| 146 | return -1; | ||
| 147 | |||
| 148 | if (_DYNAMIC) | ||
| 149 | dlctl(NULL, DL_REFERENCE, dso); | ||
| 150 | |||
| 151 | fnp->func = func; | ||
| 152 | fnp->arg = arg; | ||
| 153 | fnp->next = tib->tib_atexit; | ||
| 154 | tib->tib_atexit = fnp; | ||
| 155 | |||
| 156 | return 0; | ||
| 157 | } | ||
| 158 | |||
| 159 | void | 126 | void |
| 160 | _thread_finalize(void) | 127 | _thread_finalize(void) |
| 161 | { | 128 | { |
