From f5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 7 Mar 2024 17:28:52 -0500 Subject: build: Build mlibc + add distclean target Signed-off-by: Ian Moffett --- lib/mlibc/options/lsb/generic/dso_exit.cpp | 42 ------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 lib/mlibc/options/lsb/generic/dso_exit.cpp (limited to 'lib/mlibc/options/lsb/generic/dso_exit.cpp') diff --git a/lib/mlibc/options/lsb/generic/dso_exit.cpp b/lib/mlibc/options/lsb/generic/dso_exit.cpp deleted file mode 100644 index b8b239d..0000000 --- a/lib/mlibc/options/lsb/generic/dso_exit.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// for memcpy() -#include - -#include -#include - -#include -#include - -struct ExitHandler { - void (*function)(void *); - void *argument; - void *dsoHandle; -}; - -using ExitQueue = frg::vector; - -ExitQueue &getExitQueue() { - // use frg::eternal to prevent the compiler from scheduling the destructor - // by generating a call to __cxa_atexit(). - static frg::eternal singleton(getAllocator()); - return singleton.get(); -} - -extern "C" int __cxa_atexit(void (*function)(void *), void *argument, void *handle) { - ExitHandler handler; - handler.function = function; - handler.argument = argument; - handler.dsoHandle = handle; - getExitQueue().push(handler); - return 0; -} - -void __mlibc_do_finalize() { - ExitQueue &eq = getExitQueue(); - for(size_t i = eq.size(); i > 0; i--) { - auto handler = &eq[i - 1]; - handler->function(handler->argument); - } -} - -- cgit v1.2.3