summaryrefslogtreecommitdiffstats
path: root/libc/arch-common
diff options
context:
space:
mode:
authorDmitriy Ivanov <dimitry@google.com>2014-04-29 08:41:29 -0700
committerDmitriy Ivanov <dimitry@google.com>2014-05-05 11:36:57 -0700
commit6b56691a678420477595a531b2d2829980eb51c0 (patch)
treefc538a02922495f757b2d9efdebcfceba0bf0279 /libc/arch-common
parent9fb53dd4dbaa7633c234d9da8417827fa3d3c32f (diff)
downloadbionic-6b56691a678420477595a531b2d2829980eb51c0.zip
bionic-6b56691a678420477595a531b2d2829980eb51c0.tar.gz
bionic-6b56691a678420477595a531b2d2829980eb51c0.tar.bz2
Fixes for __cxa_finalize
* Ability to register atexit handler from atexit handler * Correct way to handle both forms of atexit handler Bug: https://code.google.com/p/android/issues/detail?id=66595 Bug: 4998315 Change-Id: I39529afaef97b6e1469c21389d54c0d7d175da28
Diffstat (limited to 'libc/arch-common')
-rw-r--r--libc/arch-common/bionic/atexit.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/libc/arch-common/bionic/atexit.h b/libc/arch-common/bionic/atexit.h
index 16ae7aa..90aa030 100644
--- a/libc/arch-common/bionic/atexit.h
+++ b/libc/arch-common/bionic/atexit.h
@@ -26,11 +26,20 @@
* SUCH DAMAGE.
*/
+#include <stddef.h>
+
extern void* __dso_handle;
extern int __cxa_atexit(void (*)(void*), void*, void*);
__attribute__ ((visibility ("hidden")))
+void __atexit_handler_wrapper(void* func) {
+ if (func != NULL) {
+ (*(void (*)(void))func)();
+ }
+}
+
+__attribute__ ((visibility ("hidden")))
int atexit(void (*func)(void)) {
- return (__cxa_atexit((void (*)(void*)) func, (void*) 0, &__dso_handle));
+ return (__cxa_atexit(&__atexit_handler_wrapper, func, &__dso_handle));
}