-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
No way to emit volatile loads/stores #11172
Comments
We need the intrinsics, but could also probably be a smart pointer type ( |
I like the idea of a smart pointer where |
Regardless of any sugar we can't do anything without the intrinsics. |
The atomic instructions rustc emits are also marked volatile in LLVM (unless it has been changed since I added them?). This should probably be changed since atomics need not be volatile. |
Any advice how to use this on bare metal, given that bare metal implies |
@farcaller Directly refer to intrinsics from your code, i.e. like at 1dcc986#diff-09f379e672ff7785f402be1007a06286L175 |
extern "rust-intrinsic" {
pub extern fn volatile_load<T>(src: *T) -> T;
pub extern fn volatile_store<T>(src: *mut T, value: T);
} See also the intrinsics module and the brief section on compiler internals in the unsafe guide. e: oh, @whitequark was faster. |
@farcaller: You can use https://github.com/thestinger/rust-core on bare metal. No need to go through the work of redefining all this stuff yourself. |
So, we have the intrinsics now. Is there any interest in making this more user friendly? Like a smart pointer type or allow annotating variables as volatile? |
@nick29581 there was a pull request adding a wrapper type: #12079. |
I'm not really sure that types make sense. You're only going to need these in rare cases, and the needs are likely quite specific to the use case. |
I've ended up using a modified |
…sery, r=xFrednet Move tuple_array_conversions to nursery changelog: Move [`tuple_array_conversions`] to `nursery` (Now allow-by-default) <!-- FIY: Ignore this change, if the commit gets backported and also rust-lang/rust-clippy#11146 --> [rust-lang#11172](rust-lang/rust-clippy#11172) The nursery change got lost in rust-lang#11146 and it ended up in pedantic, this puts it in nursery and gives something to backport r? `@xFrednet`
…sery, r=xFrednet Move tuple_array_conversions to nursery changelog: Move [`tuple_array_conversions`] to `nursery` (Now allow-by-default) <!-- FIY: Ignore this change, if the commit gets backported and also rust-lang/rust-clippy#11146 --> [rust-lang#11172](rust-lang/rust-clippy#11172) The nursery change got lost in rust-lang#11146 and it ended up in pedantic, this puts it in nursery and gives something to backport r? `@xFrednet`
I'm interested in using Rust for bare-metal embedded development. For that, Rust would need to support volatile loads and stores.
In a nutshell:
C implements them with a pointer attribute. Arguably, semantically it would be a better fit to use an intrinsic function. What should Rust use?
The text was updated successfully, but these errors were encountered: