Skip to content

Commit

Permalink
fix: avoid symbol collisions (ariel-os#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
ROMemories authored Nov 29, 2024
2 parents 2769a83 + 5728129 commit 7a20485
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/ariel-os-embassy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub(crate) fn init() {
}

#[cfg(feature = "executor-single-thread")]
#[export_name = "ariel_os_embassy_init"]
#[export_name = "__ariel_os_embassy_init"]
fn init() -> ! {
debug!("ariel-os-embassy::init(): using single thread executor");
let p = hal::init();
Expand Down
4 changes: 2 additions & 2 deletions src/ariel-os-embassy/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ pub(crate) fn config() -> embassy_net::Config {
#[cfg(feature = "override-network-config")]
{
extern "Rust" {
fn ariel_os_network_config() -> embassy_net::Config;
fn __ariel_os_network_config() -> embassy_net::Config;
}
unsafe { ariel_os_network_config() }
unsafe { __ariel_os_network_config() }
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/ariel-os-embassy/src/thread_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use embassy_executor::{raw, Spawner};
// doesn't matter.
const THREAD_FLAG_WAKEUP: ThreadFlags = 0x01;

#[export_name = "__pender"]
// This name is required by embassy-executor.
#[no_mangle]
fn __pender(context: *mut ()) {
// SAFETY: `context` is a `ThreadId` passed by `ThreadExecutor::new`.
let thread_id = ThreadId::new(context as usize as u8);
Expand Down
4 changes: 2 additions & 2 deletions src/ariel-os-embassy/src/usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ pub(crate) fn config() -> embassy_usb::Config<'static> {
#[cfg(feature = "override-usb-config")]
{
extern "Rust" {
fn ariel_os_usb_config() -> embassy_usb::Config<'static>;
fn __ariel_os_usb_config() -> embassy_usb::Config<'static>;
}
unsafe { ariel_os_usb_config() }
unsafe { __ariel_os_usb_config() }
}
}
4 changes: 2 additions & 2 deletions src/ariel-os-macros/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ pub fn config(args: TokenStream, item: TokenStream) -> TokenStream {

let (config_fn_name, return_type) = match attrs.kind {
Some(ConfigKind::Network) => (
format_ident!("ariel_os_network_config"),
format_ident!("__ariel_os_network_config"),
quote! {#ariel_os_crate::reexports::embassy_net::Config},
),
Some(ConfigKind::Usb) => (
format_ident!("ariel_os_usb_config"),
format_ident!("__ariel_os_usb_config"),
quote! {#ariel_os_crate::reexports::embassy_usb::Config<'static>},
),
None => {
Expand Down
13 changes: 0 additions & 13 deletions src/ariel-os-macros/src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ pub fn thread(args: TokenStream, item: TokenStream) -> TokenStream {
}
};

let no_mangle_attr = if attrs.no_mangle {
quote! {#[no_mangle]}
} else {
quote! {}
};

let maybe_wait_for_start_event = if attrs.no_wait {
quote! {}
} else {
Expand All @@ -85,7 +79,6 @@ pub fn thread(args: TokenStream, item: TokenStream) -> TokenStream {
} = Parameters::from(attrs);

let expanded = quote! {
#no_mangle_attr
#[inline(always)]
#thread_function

Expand Down Expand Up @@ -143,7 +136,6 @@ mod thread {
pub stack_size: Option<syn::Expr>,
pub priority: Option<syn::Expr>,
pub affinity: Option<syn::Expr>,
pub no_mangle: bool,
pub no_wait: bool,
}

Expand Down Expand Up @@ -174,11 +166,6 @@ mod thread {
return Ok(());
}

if meta.path.is_ident("no_mangle") {
self.no_mangle = true;
return Ok(());
}

if meta.path.is_ident("no_wait") {
self.no_wait = true;
return Ok(());
Expand Down
4 changes: 2 additions & 2 deletions src/ariel-os-rt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ fn startup() -> ! {
#[cfg(feature = "executor-single-thread")]
{
extern "Rust" {
fn ariel_os_embassy_init() -> !;
fn __ariel_os_embassy_init() -> !;
}
debug!("ariel_os_rt::startup() launching single thread executor");
unsafe { ariel_os_embassy_init() };
unsafe { __ariel_os_embassy_init() };
}

#[cfg(not(any(feature = "threading", feature = "executor-single-thread")))]
Expand Down
5 changes: 2 additions & 3 deletions src/ariel-os-threads/src/arch/cortex_m.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ unsafe extern "C" fn PendSV() {
unsafe {
asm!(
"
bl sched
bl {sched}
cmp r0, #0
beq 99f
Expand Down Expand Up @@ -171,6 +171,7 @@ unsafe extern "C" fn PendSV() {
999:
.word 0xFFFFFFFD
",
sched = sym sched,
options(noreturn)
)
};
Expand All @@ -190,8 +191,6 @@ unsafe extern "C" fn PendSV() {
/// - `r0`: stack-pointer for new thread
///
/// This function is called in PendSV.
// TODO: make arch independent, or move to arch
#[no_mangle]
unsafe fn sched() -> u128 {
loop {
if let Some(res) = critical_section::with(|cs| {
Expand Down

0 comments on commit 7a20485

Please sign in to comment.