From 6b56691a678420477595a531b2d2829980eb51c0 Mon Sep 17 00:00:00 2001 From: Dmitriy Ivanov Date: Tue, 29 Apr 2014 08:41:29 -0700 Subject: 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 --- libc/arch-common/bionic/atexit.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'libc/arch-common') 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 + 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)); } -- cgit v1.1