diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-08-22 15:46:57 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-08-22 15:46:57 +0200 |
| commit | bdc13bdc0a163d6839ed19a6077e61c162220826 (patch) | |
| tree | b00940c1ef5f585b7d481892ce02de535ad76f4a /dev/LibC++ | |
| parent | 209373b1f5770dc175e06996a152df6484f59af2 (diff) | |
feat: c++abi: introduce atexit ptr to cleanup data when exiting program.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/LibC++')
| -rw-r--r-- | dev/LibC++/base_process.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/dev/LibC++/base_process.h b/dev/LibC++/base_process.h index 126ac60..900198f 100644 --- a/dev/LibC++/base_process.h +++ b/dev/LibC++/base_process.h @@ -12,7 +12,10 @@ /// @param code the exit code. /// @return the return > 0 for non successful. extern "C" int exit_(int code); -extern "C" int signal_(int code); + +/// @brief CRT signal handler. +/// @param code the signal code. +extern "C" void signal_(int code); /// @brief Standard C++ namespace namespace std::base_process { @@ -21,7 +24,14 @@ inline int signal(int code) { return -1; } +extern "C" void (*__atexit_lst_ptr)(void); +extern "C" size_t __atexit_lst_cnt; + inline int exit(int code) { + for (auto i = 0UL; i < __atexit_lst_cnt; ++i) { + __atexit_lst_ptr(); + } + exit_(code); return -1; } |
