diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/boot/src/BootSupport.cpp | 19 | ||||
| -rw-r--r-- | src/kernel/HALKit/AMD64/CxxAbi.cpp | 5 |
2 files changed, 21 insertions, 3 deletions
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 <KernelKit/PE.h> #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; } diff --git a/src/kernel/HALKit/AMD64/CxxAbi.cpp b/src/kernel/HALKit/AMD64/CxxAbi.cpp index 26192f91..50b6ccf2 100644 --- a/src/kernel/HALKit/AMD64/CxxAbi.cpp +++ b/src/kernel/HALKit/AMD64/CxxAbi.cpp @@ -8,8 +8,9 @@ #include <KernelKit/UserProcessScheduler.h> #include <NeKit/CxxAbi.h> -atexit_func_entry_t __atexit_funcs[kAtExitMacDestructors]; +#define kAtExitMaxDestructors (128U) +atexit_func_entry_t __atexit_funcs[kAtExitMaxDestructors]; uarch_t __atexit_func_count; /// @brief dynamic shared object Handle. @@ -31,7 +32,7 @@ EXTERN_C void ___chkstk_ms(PtrDiff frame_size) { } EXTERN_C int atexit(void (*f)()) { - if (__atexit_func_count >= kAtExitMacDestructors) return 1; + if (__atexit_func_count >= kAtExitMaxDestructors) return 1; __atexit_funcs[__atexit_func_count].destructor_func = f; |
