-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Added Volatile Types #12063
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
Added Volatile Types #12063
Conversation
|
||
pub struct VolatileUint { | ||
v: uint | ||
} |
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.
These fields should all be private.
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.
There seems to be no implementation of a VolatileUint
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.
Ahh yes. I'll remove the other struct definitions for now, since they don't have implementations.
Thanks for the pointers @alexcrichton. I have included those changes in the latest commit (or I think I have addressed them correctly). Let me know if there's anything else that needs to be addressed. |
} | ||
|
||
#[inline] | ||
pub fn take(&self) -> bool { |
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.
bools and ints don't need take
, they can be called load
because these types don't obey the same ownership semantics as ~T
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.
Oops, that's right.
Signed-off-by: Daniel Fagnan <[email protected]>
Just messed up my fork. Gonna close this and submit a new PR. |
fix: Fall back to parameter definitions on error types in signature help Fixes rust-lang#10432
Add `.front()` to `get_first` lint description Fix rust-lang#12063 changelog: none
This PR adds a nicer wrapper around the volatile intrinsics. It also places the new volatile module under unstable.
I added the following types:
VolatilePtr
VolatileInt
VolatileBool
There is also static types that deal with the specialized types (such as
VolatileBool
andVolatileInt
)INIT_VOLATILE_BOOL
INIT_VOLATILE_INT
These can be used basically the same way Atomics are used (I think).
Somethings to consider:
int
andbool
). Other types are super easy to add.VolatilePtr
doesn't work with pure values, because there needs to be a destination pointer for the intrinsics. One way I can think of allowing this directly (without using another variable) is to reserve a new memory region, with the size based on the passed type, and copying the data over to that region.I added tests for all the current functionality and they all pass on my machine.
Let me know if there's anything else I need to change, add, remove, etc...