-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
interrupt: Support no-std pre-v6 ARM targets #28
Conversation
5937598
to
b1ff9ec
Compare
I think it is okay that we only disable the I bit because in some environments the F bit seems not to be able to be changed. Also, it seems that only IRQ is used in GBA. |
b1ff9ec
to
58fa110
Compare
58fa110
to
ec78759
Compare
ec78759
to
a5b7f88
Compare
Your readme should likely note that this does not work in User mode. |
https://github.com/taiki-e/portable-atomic#optional-cfg
|
Oh, i only looked at the lines that the PR diff highlighted in green XD |
macro_rules! atomic_load { | ||
($name:ident, $int_ty:ty, $atomic_ty:ident) => { | ||
#[no_mangle] | ||
#[cfg_attr(all(not(windows), not(target_vendor = "apple")), linkage = "weak")] | ||
pub unsafe extern "C" fn $name(dst: *mut $int_ty, ordering: c_int) -> $int_ty { | ||
unsafe { | ||
let guard = FFIPanicGuard; | ||
let res = mem::transmute( | ||
(*dst.cast::<portable_atomic::$atomic_ty>()).load(c_load_ordering(ordering)), | ||
); | ||
mem::forget(guard); | ||
res | ||
} | ||
} | ||
}; | ||
} | ||
atomic_load!(__atomic_load_1, u8, AtomicU8); | ||
atomic_load!(__atomic_load_2, u16, AtomicU16); | ||
atomic_load!(__atomic_load_4, u32, AtomicU32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, this is needed due to LLVM 15's change (rust-lang/rust#99668). Other GBA users seem to be affected as well (rust-lang/rust#100619). Passing +atomics-32 target feature is another way to solve this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed the fix to upstream: rust-lang/rust#100621
I just wanted to say that this is really cool and much appreciated! As for running mGBA in "headless" mode, you can take a look at how agb compiles and uses its mgba-test-runner. |
Thanks @Jinxit! I will look into mgba-test-runner. |
Pass +atomics-32 feature for {arm,thumb}v4t-none-eabi Similar to rust-lang@89582e8, but for ARMv4t. Pre-v6 ARM target does not have atomic CAS, except for Linux and Android where atomic CAS is provided by compiler-builtins. So, there is a similar issue as thumbv6m. I have confirmed that enabling the `atomics-32` target feature fixes the problem in the project affected by this issue. (taiki-e/portable-atomic#28 (comment)) Closes rust-lang#100619 r? `@nikic` cc `@Lokathor`
Pass +atomics-32 feature for {arm,thumb}v4t-none-eabi Similar to rust-lang@89582e8, but for ARMv4t. Pre-v6 ARM target does not have atomic CAS, except for Linux and Android where atomic CAS is provided by compiler-builtins. So, there is a similar issue as thumbv6m. I have confirmed that enabling the `atomics-32` target feature fixes the problem in the project affected by this issue. (taiki-e/portable-atomic#28 (comment)) Closes rust-lang#100619 r? ``@nikic`` cc ``@Lokathor``
Closes #26
This currently disables only IRQs. This is explained in the document on safety requirements:
I have a few questions:
Should we also disable FIQs? The emulation of atomic operation on Linux seemed to disable only IRQs, but they may have disabled FIQs globally.EDIT: see interrupt: Support no-std pre-v6 ARM targets #28 (comment)