Fixed atexit()

See b.android.com/66595

Change-Id: I1d4c3db424c7f839e48756359cc095a6b1028ace
This commit is contained in:
Andrew Hsieh
2014-09-04 13:17:25 -07:00
parent 83fb2f6940
commit 2db7f63f99
13 changed files with 76 additions and 21 deletions

View File

@@ -26,10 +26,20 @@
* SUCH DAMAGE.
*/
extern void *__dso_handle;
#include <stddef.h>
extern void* __dso_handle;
extern int __cxa_atexit(void (*)(void*), void*, void*);
__attribute__ ((visibility ("hidden")))
int atexit(void (*func)(void))
{
return (__cxa_atexit((void (*)(void *))func, (void *)0, &__dso_handle));
void __atexit_handler_wrapper(void* func) {
if (func != NULL) {
(*(void (*)(void))func)();
}
}
__attribute__ ((visibility ("hidden")))
int atexit(void (*func)(void)) {
return (__cxa_atexit(&__atexit_handler_wrapper, func, &__dso_handle));
}