mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-19 03:54:01 +00:00
runtime: return the correct type from the copy builtin
The copy builtin is defined as follows by the Go language spec:
copy(dst, src []T) int
copy(dst []byte, src string) int
In other words, it returns an int. The runtime.sliceCopy compiler
intrinsic returned a uintptr instead, which led to a problem while
compiling the strings package for AVR.
No other architecture should be affected by this change as the
conversion from an uintptr to an int is a no-op on most architectures.
This commit is contained in:
committed by
Ron Evans
parent
928a970782
commit
1a7369af6e
@@ -42,12 +42,12 @@ func sliceAppend(srcBuf, elemsBuf unsafe.Pointer, srcLen, srcCap, elemsLen uintp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Builtin copy(dst, src) function: copy bytes from dst to src.
|
// Builtin copy(dst, src) function: copy bytes from dst to src.
|
||||||
func sliceCopy(dst, src unsafe.Pointer, dstLen, srcLen uintptr, elemSize uintptr) uintptr {
|
func sliceCopy(dst, src unsafe.Pointer, dstLen, srcLen uintptr, elemSize uintptr) int {
|
||||||
// n = min(srcLen, dstLen)
|
// n = min(srcLen, dstLen)
|
||||||
n := srcLen
|
n := srcLen
|
||||||
if n > dstLen {
|
if n > dstLen {
|
||||||
n = dstLen
|
n = dstLen
|
||||||
}
|
}
|
||||||
memmove(dst, src, n*elemSize)
|
memmove(dst, src, n*elemSize)
|
||||||
return n
|
return int(n)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user