From 92810a71d6e64f0174ca53042aee0217a28115b3 Mon Sep 17 00:00:00 2001 From: Youjie Zheng Date: Sat, 25 Jan 2025 15:49:28 +0800 Subject: [PATCH] [fix] fix error for unsafe attr and bump to v0.2.1 --- Cargo.toml | 2 +- ctor_bare/Cargo.toml | 2 +- ctor_bare/tests/test_ctor.rs | 3 +-- ctor_bare_macros/src/lib.rs | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c382220..fc0fca6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ members = [ ] [workspace.package] -version = "0.2.0" +version = "0.2.1" edition = "2024" authors = ["Youjie Zheng "] license = "GPL-3.0-or-later OR Apache-2.0 OR MulanPSL-2.0" diff --git a/ctor_bare/Cargo.toml b/ctor_bare/Cargo.toml index c8cc2ea..e851631 100644 --- a/ctor_bare/Cargo.toml +++ b/ctor_bare/Cargo.toml @@ -13,4 +13,4 @@ categories.workspace = true readme = "README.md" [dependencies] -ctor_bare_macros = "0.1" \ No newline at end of file +ctor_bare_macros = "0.2" \ No newline at end of file diff --git a/ctor_bare/tests/test_ctor.rs b/ctor_bare/tests/test_ctor.rs index f46242b..b3bd6de 100644 --- a/ctor_bare/tests/test_ctor.rs +++ b/ctor_bare/tests/test_ctor.rs @@ -1,7 +1,6 @@ +use ctor_bare::register_ctor; use std::sync::{Mutex, atomic::AtomicUsize}; -use ctor_bare::*; - static INIT_NUM: AtomicUsize = AtomicUsize::new(0); #[register_ctor] diff --git a/ctor_bare_macros/src/lib.rs b/ctor_bare_macros/src/lib.rs index afdd8b0..63d26c9 100644 --- a/ctor_bare_macros/src/lib.rs +++ b/ctor_bare_macros/src/lib.rs @@ -57,12 +57,12 @@ pub fn register_ctor(attr: TokenStream, function: TokenStream) -> TokenStream { let block = &func.block; quote! { - #[link_section = ".init_array"] + #[unsafe(link_section = ".init_array")] #[used] #[allow(non_upper_case_globals)] static #name_ident: extern "C" fn() = #name; - #[no_mangle] + #[unsafe(no_mangle)] #[allow(non_upper_case_globals)] pub extern "C" fn #name() { #block