Skip to content

Commit bc809e0

Browse files
committed
remark on concurrency in validity section
1 parent 755de3c commit bc809e0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libcore/ptr.rs

+9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
//! * A [null] pointer is *never* valid, not even for accesses of [size zero][zst].
2929
//! * All pointers (except for the null pointer) are valid for all operations of
3030
//! [size zero][zst].
31+
//! * All accesses performed by functions in this module are *non-atomic* in the sense
32+
//! of [atomic operations] used to synchronize between threads. This means it is
33+
//! undefined behavior to perform two concurrent accesses to the same location from different
34+
//! threads unless both accesses only read from memory. Notice that this explicitly
35+
//! includes [`read_volatile`] and [`write_volatile`]: Volatile accesses cannot
36+
//! be used for inter-thread synchronization.
3137
//! * The result of casting a reference to a pointer is valid for as long as the
3238
//! underlying object is live and no reference (just raw pointers) is used to
3339
//! access the same memory.
@@ -56,10 +62,13 @@
5662
//! [ub]: ../../reference/behavior-considered-undefined.html
5763
//! [null]: ./fn.null.html
5864
//! [zst]: ../../nomicon/exotic-sizes.html#zero-sized-types-zsts
65+
//! [atomic operations]: ../../std/sync/atomic/index.html
5966
//! [`copy`]: ../../std/ptr/fn.copy.html
6067
//! [`offset`]: ../../std/primitive.pointer.html#method.offset
6168
//! [`read_unaligned`]: ./fn.read_unaligned.html
6269
//! [`write_unaligned`]: ./fn.write_unaligned.html
70+
//! [`read_volatile`]: ./fn.read_volatile.html
71+
//! [`write_volatile`]: ./fn.write_volatile.html
6372
//! [`NonNull::dangling`]: ./struct.NonNull.html#method.dangling
6473
6574
#![stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)