From 3c8372ba712e7b27e28a9ea857a25c2347d8a7d6 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Tue, 8 Aug 2023 00:31:07 +0200 Subject: [PATCH] Use correct __cxa_atexit function definition (#293) --- ctor/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ctor/src/lib.rs b/ctor/src/lib.rs index 64e3d6e..b91b0b3 100644 --- a/ctor/src/lib.rs +++ b/ctor/src/lib.rs @@ -346,10 +346,10 @@ pub fn dtor(_attribute: TokenStream, function: TokenStream) -> TokenStream { // For platforms that have __cxa_atexit, we register the dtor as scoped to dso_handle #[cfg(any(target_os = "macos", target_os = "ios"))] #[inline(always)] - unsafe fn do_atexit(cb: unsafe extern fn()) { + unsafe fn do_atexit(cb: unsafe extern fn(_: *const u8)) { extern "C" { static __dso_handle: *const u8; - fn __cxa_atexit(cb: unsafe extern fn(), arg: *const u8, dso_handle: *const u8); + fn __cxa_atexit(cb: unsafe extern fn(_: *const u8), arg: *const u8, dso_handle: *const u8); } __cxa_atexit(cb, std::ptr::null(), __dso_handle); } @@ -361,8 +361,11 @@ pub fn dtor(_attribute: TokenStream, function: TokenStream) -> TokenStream { : unsafe extern "C" fn() = { + #[cfg(not(any(target_os = "macos", target_os = "ios")))] #[cfg_attr(any(target_os = "linux", target_os = "android"), link_section = ".text.exit")] unsafe extern "C" fn #dtor_ident() { #ident() }; + #[cfg(any(target_os = "macos", target_os = "ios"))] + unsafe extern "C" fn #dtor_ident(_: *const u8) { #ident() }; #[cfg_attr(any(target_os = "linux", target_os = "android"), link_section = ".text.startup")] unsafe extern fn __dtor_atexit() { do_atexit(#dtor_ident);