diff options
| author | Amlal <amlal@nekernel.org> | 2025-04-25 13:08:33 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-04-25 13:08:33 +0200 |
| commit | fb790b07aeba8e22e4190cf3e1834d11ecde6c96 (patch) | |
| tree | 4cec7d1b321307b1d5935577631dae116a658a37 /dev/kernel/src/CxxAbi-AMD64.cc | |
| parent | 63a2d92c5dfe976175cda024ec01905d11b43738 (diff) | |
dev: better .clang-format, ran format command.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/src/CxxAbi-AMD64.cc')
| -rw-r--r-- | dev/kernel/src/CxxAbi-AMD64.cc | 111 |
1 files changed, 49 insertions, 62 deletions
diff --git a/dev/kernel/src/CxxAbi-AMD64.cc b/dev/kernel/src/CxxAbi-AMD64.cc index 950e0c02..452f23cd 100644 --- a/dev/kernel/src/CxxAbi-AMD64.cc +++ b/dev/kernel/src/CxxAbi-AMD64.cc @@ -1,14 +1,14 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ #ifdef __NE_AMD64__ #include <KernelKit/DebugOutput.h> -#include <NewKit/CxxAbi.h> #include <KernelKit/KPC.h> +#include <NewKit/CxxAbi.h> atexit_func_entry_t __atexit_funcs[kAtExitMacDestructors]; @@ -17,74 +17,61 @@ uarch_t __atexit_func_count; /// @brief dynamic shared object Handle. Kernel::UIntPtr __dso_handle; -EXTERN_C Kernel::Void __cxa_pure_virtual(void* self) -{ - (Kernel::Void)(Kernel::kout << "object: " << Kernel::number(reinterpret_cast<Kernel::UIntPtr>(self))); - (Kernel::Void)(Kernel::kout << ", has unimplemented virtual functions.\r"); +EXTERN_C Kernel::Void __cxa_pure_virtual(void* self) { + (Kernel::Void)(Kernel::kout << "object: " + << Kernel::number(reinterpret_cast<Kernel::UIntPtr>(self))); + (Kernel::Void)(Kernel::kout << ", has unimplemented virtual functions.\r"); } -EXTERN_C void ___chkstk_ms(void) -{ - (Kernel::Void)(Kernel::kout << "Stack smashing detected!\r"); - dbg_break_point(); +EXTERN_C void ___chkstk_ms(void) { + (Kernel::Void)(Kernel::kout << "Stack smashing detected!\r"); + dbg_break_point(); } -EXTERN_C int atexit(void (*f)()) -{ - if (__atexit_func_count >= kAtExitMacDestructors) - return 1; +EXTERN_C int atexit(void (*f)()) { + if (__atexit_func_count >= kAtExitMacDestructors) return 1; + + __atexit_funcs[__atexit_func_count].destructor_func = f; + + __atexit_func_count++; - __atexit_funcs[__atexit_func_count].destructor_func = f; + return 0; +} + +EXTERN_C void __cxa_finalize(void* f) { + uarch_t i = __atexit_func_count; + if (!f) { + while (i--) { + if (__atexit_funcs[i].destructor_func) { + (*__atexit_funcs[i].destructor_func)(); + }; + } + + return; + } + + while (i--) { + if (__atexit_funcs[i].destructor_func) { + (*__atexit_funcs[i].destructor_func)(); + __atexit_funcs[i].destructor_func = 0; + }; + } +} - __atexit_func_count++; +namespace cxxabiv1 { +EXTERN_C int __cxa_guard_acquire(__guard* g) { + (void) g; + return 0; +} - return 0; +EXTERN_C int __cxa_guard_release(__guard* g) { + *(char*) g = 1; + return 0; } -EXTERN_C void __cxa_finalize(void* f) -{ - uarch_t i = __atexit_func_count; - if (!f) - { - while (i--) - { - if (__atexit_funcs[i].destructor_func) - { - (*__atexit_funcs[i].destructor_func)(); - }; - } - - return; - } - - while (i--) - { - if (__atexit_funcs[i].destructor_func) - { - (*__atexit_funcs[i].destructor_func)(); - __atexit_funcs[i].destructor_func = 0; - }; - } +EXTERN_C void __cxa_guard_abort(__guard* g) { + (void) g; } +} // namespace cxxabiv1 -namespace cxxabiv1 -{ - EXTERN_C int __cxa_guard_acquire(__guard* g) - { - (void)g; - return 0; - } - - EXTERN_C int __cxa_guard_release(__guard* g) - { - *(char*)g = 1; - return 0; - } - - EXTERN_C void __cxa_guard_abort(__guard* g) - { - (void)g; - } -} // namespace cxxabiv1 - -#endif // ifdef __NE_AMD64__ +#endif // ifdef __NE_AMD64__ |
