use core::ffi::c_void;

use crate::{error::CIntZeroResult, process, thread::Thread};

#[no_mangle]
unsafe extern "C" fn __cxa_atexit(
    destructor: extern "C" fn(*mut c_void),
    arg: *mut c_void,
    dso_handle: *mut c_void,
) -> CIntZeroResult {
    process::at_dso_exit(destructor, arg, dso_handle);
    CIntZeroResult::SUCCESS
}

#[no_mangle]
unsafe extern "C" fn __cxa_thread_atexit(
    destructor: extern "C" fn(*mut c_void),
    arg: *mut c_void,
    dso_handle: *mut c_void,
) -> CIntZeroResult {
    Thread::at_thread_exit(destructor, arg, dso_handle);
    CIntZeroResult::SUCCESS
}
