github.com/primecitizens/pcz/std@v0.2.1/core/mem/move.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 //go:build pcz 5 6 package mem 7 8 import ( 9 "unsafe" 10 11 "github.com/primecitizens/pcz/std/core/abi" 12 ) 13 14 // Move copies n bytes from "src" to "dst". 15 // 16 // Move ensures that any pointer in "from" is written to "to" with 17 // an indivisible write, so that racy reads cannot observe a 18 // half-written pointer. This is necessary to prevent the garbage 19 // collector from observing invalid pointers, and differs from memmove 20 // in unmanaged languages. However, memmove is only required to do 21 // this if "from" and "to" may contain pointers, which can only be the 22 // case if "from", "to", and "n" are all be word-aligned. 23 // 24 // Implementations are in move_*.s. 25 // 26 // See ${GOROOT}/src/runtime/stubs.go#func:memmove 27 // 28 //go:noescape 29 func Move(dst, src unsafe.Pointer, n uintptr) 30 31 //go:linkname typedmemmove runtime.typedmemmove 32 func typedmemmove(typ *abi.Type, dst, src unsafe.Pointer)