From bf2892edf4185326c0d47d16106eaead05859f07 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 14 Mar 2026 08:00:45 +0100 Subject: [CHORE] Implemented atexit for BootZ. Signed-off-by: Amlal El Mahrouss --- src/boot/src/BootSupport.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/boot') diff --git a/src/boot/src/BootSupport.cpp b/src/boot/src/BootSupport.cpp index 4ef887bb..232ac965 100644 --- a/src/boot/src/BootSupport.cpp +++ b/src/boot/src/BootSupport.cpp @@ -12,9 +12,26 @@ #include #ifdef __BOOTZ_STANDALONE__ + +#define kAtExitMaxDestructors (128U) + +typedef struct atexit_func_entry { + void(*destructor_func)(); +} atexit_func_entry_t; + +typedef long long uarch_t; + +atexit_func_entry_t __atexit_funcs[kAtExitMaxDestructors]; +uarch_t __atexit_func_count; + /// @note This function is a stub, not implemented by the bootloader as of right now. (AMLALE) EXTERN_C int atexit(void (*f)()) { - NE_UNUSED(f); + if (__atexit_func_count >= kAtExitMaxDestructors) return 1; + + __atexit_funcs[__atexit_func_count].destructor_func = f; + + __atexit_func_count++; + return 0; } -- cgit v1.2.3