diff options
Diffstat (limited to 'src/runtime/wincallback.go')
-rw-r--r-- | src/runtime/wincallback.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/runtime/wincallback.go b/src/runtime/wincallback.go index fb452222da..56f0674f4e 100644 --- a/src/runtime/wincallback.go +++ b/src/runtime/wincallback.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ignore // +build ignore // Generate Windows callback assembly file. @@ -72,6 +73,34 @@ TEXT runtime·callbackasm(SB),NOSPLIT|NOFRAME,$0 } } +func genasmArm64() { + var buf bytes.Buffer + + buf.WriteString(`// Code generated by wincallback.go using 'go generate'. DO NOT EDIT. + +// External code calls into callbackasm at an offset corresponding +// to the callback index. Callbackasm is a table of MOV and B instructions. +// The MOV instruction loads R12 with the callback index, and the +// B instruction branches to callbackasm1. +// callbackasm1 takes the callback index from R12 and +// indexes into an array that stores information about each callback. +// It then calls the Go implementation for that callback. +#include "textflag.h" + +TEXT runtime·callbackasm(SB),NOSPLIT|NOFRAME,$0 +`) + for i := 0; i < maxCallback; i++ { + buf.WriteString(fmt.Sprintf("\tMOVD\t$%d, R12\n", i)) + buf.WriteString("\tB\truntime·callbackasm1(SB)\n") + } + + err := os.WriteFile("zcallback_windows_arm64.s", buf.Bytes(), 0666) + if err != nil { + fmt.Fprintf(os.Stderr, "wincallback: %s\n", err) + os.Exit(2) + } +} + func gengo() { var buf bytes.Buffer @@ -91,5 +120,6 @@ const cb_max = %d // maximum number of windows callbacks allowed func main() { genasm386Amd64() genasmArm() + genasmArm64() gengo() } |