File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 8181//!
8282//! # Atomic accesses to read-only memory
8383//!
84- //! In general, atomic accesses on read-only memory are Undefined Behavior. For instance, attempting
84+ //! In general, *all* atomic accesses on read-only memory are Undefined Behavior. For instance, attempting
8585//! to do a `compare_exchange` that will definitely fail (making it conceptually a read-only
8686//! operation) can still cause a page fault if the underlying memory page is mapped read-only. Since
8787//! atomic `load`s might be implemented using compare-exchange operations, even a `load` can fault
8888//! on read-only memory.
8989//!
90+ //! For the purpose of this section, "read-only memory" is defined as memory that is read-only in
91+ //! the underlying target, i.e., the pages are mapped with a read-only flag and any attempt to write
92+ //! will cause a page fault. In particular, an `&u128` reference that points to memory that is
93+ //! read-write mapped is *not* considered to point to "read-only memory". In Rust, almost all memory
94+ //! is read-write; the only exceptions are memory created by `const` items or `static` items without
95+ //! interior mutability.
96+ //!
9097//! However, as an exception from this general rule, Rust guarantees that "sufficiently small"
9198//! atomic loads are implemented in a way that works on read-only memory. This threshold of
9299//! "sufficiently small" depends on the architecture:
You can’t perform that action at this time.
0 commit comments