ssa: builtin copy

This commit is contained in:
visualfc
2024-05-19 19:33:41 +08:00
parent af4a0ffa21
commit cda572fd59
6 changed files with 98 additions and 0 deletions

View File

@@ -91,4 +91,16 @@ func SliceAppend(src Slice, data unsafe.Pointer, num, etSize int) Slice {
return src
}
// SliceCopy copy data to slice and returns a slice.
func SliceCopy(dst Slice, data unsafe.Pointer, num int, etSize int) int {
n := dst.len
if n > num {
n = num
}
if n > 0 {
c.Memmove(dst.data, data, uintptr(n*etSize))
}
return n
}
// -----------------------------------------------------------------------------