pub unsafe fn well_defined_copy_to<const SYNC_OPT: u8, const WORST_CASE_ALIGNMENT: usize>(
dst: *mut u8,
src: *const u8,
size_bytes: usize,
)Expand description
Copy size_bytes bytes from src to dst using atomic store operations to move
the element into dst so that the behavior of the system is always well
defined, even if there is a well_defined_copy_from operation reading from the
memory pointed to by dst concurrent with this well_defined_copy_to operation.
well_defined_copy_to has memcpy semantics, not memmove semantics. In other
words, it is illegal for src or dst to overlap in any way.
While it is not required, by default, that src and dst have any specific
alignment, both src and dst must have the same alignment.
IOW: (src & 0x7) must equal (dst & 0x7)
§Const Generic Args
SYNC_OPT
Controls the options for memory order synchronization. See the comments on
crate::common::SyncOpt for details.
WORST_CASE_ALIGNMENT
An explicit guarantee of the worst case alignment that src/dst will obey.
When this alignment guarantee is greater than or equal to the maximum
internal transfer granularity of 64 bits, the initial explicit alignment step
of the operation can be optimized away for a minor performance gain.
§Safety
srcanddstmust be valid for reads and writes (respectively) ofsize_bytesbytes, must not overlap, and must have the same alignment modulo 8.- Both pointers must be aligned to at least
WORST_CASE_ALIGNMENT. dstmust only be accessed concurrently through well-defined copy operations, andsrcmust not be concurrently mutated.