diff --git a/src/stdlib/src/lib.rs b/src/stdlib/src/lib.rs index a9c43f81ebd3a09656ed9877afd7a238876d609b..2a7a0c24ce026653dd7d3dd3e06f2a63f16c97b0 100644 --- a/src/stdlib/src/lib.rs +++ b/src/stdlib/src/lib.rs @@ -15,7 +15,7 @@ static ALLOCATOR: ralloc::Allocator = ralloc::Allocator; pub const EXIT_FAILURE: c_int = 1; pub const EXIT_SUCCESS: c_int = 0; -static mut ATEXIT_FUNCS: [Option<usize>; 32] = [None; 32]; +static mut ATEXIT_FUNCS: [Option<extern "C" fn>; 32] = [None; 32]; #[no_mangle] pub extern "C" fn a64l(s: *const c_char) -> c_long { @@ -41,8 +41,8 @@ pub extern "C" fn abs(i: c_int) -> c_int { #[no_mangle] pub unsafe extern "C" fn atexit(func: Option<extern "C" fn()>) -> c_int { for i in 0..ATEXIT_FUNCS.len() { - if ATEXIT_FUNCS[i] != None { - ATEXIT_FUNCS[i] = Some(func.unwrap() as usize); + if ATEXIT_FUNCS[i] == None { + ATEXIT_FUNCS[i] = func; return 0; } }