Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

rust-osdev/volatile

Build StatusDocs.rs Badge

Provides volatile wrapper types for raw pointers.

The volatile wrapper types in this crate wrap a pointer to anyCopy-able type and provide volatile memory access to wrapped value.Volatile memory accesses are never optimized away by the compiler, and are useful in many low-level systems programming and concurrent contexts.

This crate provides two different wrapper types:VolatilePtr andVolatileRef.The difference between the two types is that the former behaves like a raw pointer, while the latter behaves like a Rust reference type.For example,VolatilePtr can be freely copied, but not sent across threads because this could introduce mutable aliasing.TheVolatileRef type, on the other hand, requires exclusive access for mutation, so that sharing it across thread boundaries is safe.

Both wrapper typesdo not enforce any atomicity guarantees; to also get atomicity, consider looking at theAtomic wrapper types found inlibcore orlibstd.

Why is there noVolatileCell?

Many people expressed interest in aVolatileCell type, i.e. a transparent wrapper type that owns the wrapped value.Such a type would be similar tocore::cell::Cell, with the difference that all methods are volatile.Unfortunately, it is not sound to implement such aVolatileCell type in Rust.The reason is that Rust and LLVM consider& and&mut references asdereferencable.This means that the compiler is allowed to freely access the referenced value without any restrictions.So no matter how aVolatileCell type is implemented, the compiler is allowed to perform non-volatile read operations of the contained value, which can lead to unexpected (or even undefined?) behavior.For more details, see the discussionin our repository andin theunsafe-code-guidelines repository.

License

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors11

Languages


[8]ページ先頭

©2009-2025 Movatter.jp