File tree 1 file changed +8
-1
lines changed
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 81
81
//!
82
82
//! # Atomic accesses to read-only memory
83
83
//!
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
85
85
//! to do a `compare_exchange` that will definitely fail (making it conceptually a read-only
86
86
//! operation) can still cause a page fault if the underlying memory page is mapped read-only. Since
87
87
//! atomic `load`s might be implemented using compare-exchange operations, even a `load` can fault
88
88
//! on read-only memory.
89
89
//!
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
+ //!
90
97
//! However, as an exception from this general rule, Rust guarantees that "sufficiently small"
91
98
//! atomic loads are implemented in a way that works on read-only memory. This threshold of
92
99
//! "sufficiently small" depends on the architecture:
You can’t perform that action at this time.
0 commit comments