wasm: include wasi-libc

This allows CGo code to call some libc functions. Additionally, by
putting memset/memmove/memcpy in an archive they're not included anymore
when not necessary, reducing code size for small programs.
This commit is contained in:
Ayke van Laethem
2020-01-12 20:31:30 +01:00
committed by Ron Evans
parent c61657d22d
commit e2aa3789c3
7 changed files with 67 additions and 33 deletions
-26
View File
@@ -2,10 +2,6 @@
package runtime
import (
"unsafe"
)
type timeUnit float64 // time in milliseconds, just like Date.now() in JavaScript
const tickMicros = 1000000
@@ -68,25 +64,3 @@ func ticks() timeUnit
func abort() {
trap()
}
//go:export memset
func memset(ptr unsafe.Pointer, c byte, size uintptr) unsafe.Pointer {
for i := uintptr(0); i < size; i++ {
*(*byte)(unsafe.Pointer(uintptr(ptr) + i)) = c
}
return ptr
}
// Implement memmove for LLVM and compiler-rt.
//go:export memmove
func libc_memmove(dst, src unsafe.Pointer, size uintptr) unsafe.Pointer {
memmove(dst, src, size)
return dst
}
// Implement memcpy for LLVM and compiler-rt.
//go:export memcpy
func libc_memcpy(dst, src unsafe.Pointer, size uintptr) unsafe.Pointer {
memcpy(dst, src, size)
return dst
}