all: Go 1.21 support

This commit is contained in:
Ayke van Laethem
2023-07-06 12:01:52 +02:00
committed by Ron Evans
parent c25dd0a972
commit a93f0ed12a
16 changed files with 76 additions and 20 deletions
+2
View File
@@ -38,6 +38,8 @@ func growHeap() bool {
//export malloc
func libc_malloc(size uintptr) unsafe.Pointer {
// Note: this zeroes the returned buffer which is not necessary.
// The same goes for bytealg.MakeNoZero.
return alloc(size, nil)
}
+10
View File
@@ -0,0 +1,10 @@
package runtime
// Implementation of functions needed by runtime/metrics.
// Mostly just dummy implementations: we don't currently use any of these
// metrics.
//go:linkname godebug_registerMetric internal/godebug.registerMetric
func godebug_registerMetric(name string, read func() uint64) {
// Dummy function for compatibility with Go 1.21.
}
+24
View File
@@ -100,3 +100,27 @@ func godebug_setUpdate(update func(string, string)) {
// variable changes (for example, via os.Setenv).
godebugUpdate = update
}
//go:linkname godebug_setNewIncNonDefault internal/godebug.setNewIncNonDefault
func godebug_setNewIncNonDefault(newIncNonDefault func(string) func()) {
// Dummy function necessary in Go 1.21.
}
// Write to the given file descriptor.
// This is called from internal/godebug starting with Go 1.21, and only seems to
// be called with the stderr file descriptor.
func write(fd uintptr, p unsafe.Pointer, n int32) int32 {
if fd == 2 { // stderr
// Convert to a string, because we know that p won't change during the
// call to printstring.
// TODO: use unsafe.String instead once we require Go 1.20.
s := _string{
ptr: (*byte)(p),
length: uintptr(n),
}
str := *(*string)(unsafe.Pointer(&s))
printstring(str)
return n
}
return 0
}
+1 -1
View File
@@ -105,7 +105,7 @@ func abort() {
}
//export write
func write(fd int32, buf *byte, count int) int {
func libc_write(fd int32, buf *byte, count int) int {
// TODO: Proper handling write
for i := 0; i < count; i++ {
putchar(*buf)
+2 -2
View File
@@ -44,8 +44,8 @@ func nanosecondsToTicks(ns int64) timeUnit {
// This function is called by the scheduler.
// Schedule a call to runtime.scheduler, do not actually sleep.
//
//export runtime.sleepTicks
//go:wasmimport gojs runtime.sleepTicks
func sleepTicks(d timeUnit)
//export runtime.ticks
//go:wasmimport gojs runtime.ticks
func ticks() timeUnit
+4 -1
View File
@@ -5,11 +5,14 @@ type Frames struct {
}
type Frame struct {
PC uintptr
Func *Func
Function string
File string
Line int
PC uintptr
}
func CallersFrames(callers []uintptr) *Frames {