aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/syscall_windows_test.go
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@golang.org>2016-10-26 13:29:39 -0400
committerDavid Crawshaw <crawshaw@golang.org>2016-10-28 13:13:08 +0000
commit9c02c75639b893cea6dbce1092d07e886ec5f44e (patch)
treeca7eec14ca5471d8b245ecde83e2836f5e0064e0 /src/runtime/syscall_windows_test.go
parentdd500193d3e96e6bc9700fd43fc68b55e662d7c1 (diff)
downloadgo-9c02c75639b893cea6dbce1092d07e886ec5f44e.tar.xz
runtime: pass windows float syscall args via XMM
Based on the calling convention documented in: https://msdn.microsoft.com/en-us/library/zthk2dkh.aspx and long-used in golang.org/x/mobile/gl via some fixup asm: https://go.googlesource.com/mobile/+/master/gl/work_windows_amd64.s Fixes #6510 Change-Id: I97e81baaa2872bcd732b1308915eb66f1ba2168f Reviewed-on: https://go-review.googlesource.com/32173 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Minux Ma <minux@golang.org>
Diffstat (limited to 'src/runtime/syscall_windows_test.go')
-rw-r--r--src/runtime/syscall_windows_test.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/runtime/syscall_windows_test.go b/src/runtime/syscall_windows_test.go
index c19cd71662..11e67df100 100644
--- a/src/runtime/syscall_windows_test.go
+++ b/src/runtime/syscall_windows_test.go
@@ -10,6 +10,7 @@ import (
"internal/syscall/windows/sysdll"
"internal/testenv"
"io/ioutil"
+ "math"
"os"
"os/exec"
"path/filepath"
@@ -622,6 +623,61 @@ uintptr_t cfunc(callback f, uintptr_t n) {
}
}
+func TestFloatArgs(t *testing.T) {
+ if _, err := exec.LookPath("gcc"); err != nil {
+ t.Skip("skipping test: gcc is missing")
+ }
+ if runtime.GOARCH != "amd64" {
+ t.Skipf("skipping test: GOARCH=%s", runtime.GOARCH)
+ }
+
+ const src = `
+#include <stdint.h>
+#include <windows.h>
+
+uintptr_t cfunc(uintptr_t a, double b, float c, double d) {
+ if (a == 1 && b == 2.2 && c == 3.3f && d == 4.4e44) {
+ return 1;
+ }
+ return 0;
+}
+`
+ tmpdir, err := ioutil.TempDir("", "TestFloatArgs")
+ if err != nil {
+ t.Fatal("TempDir failed: ", err)
+ }
+ defer os.RemoveAll(tmpdir)
+
+ srcname := "mydll.c"
+ err = ioutil.WriteFile(filepath.Join(tmpdir, srcname), []byte(src), 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+ outname := "mydll.dll"
+ cmd := exec.Command("gcc", "-shared", "-s", "-Werror", "-o", outname, srcname)
+ cmd.Dir = tmpdir
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Fatalf("failed to build dll: %v - %v", err, string(out))
+ }
+ dllpath := filepath.Join(tmpdir, outname)
+
+ dll := syscall.MustLoadDLL(dllpath)
+ defer dll.Release()
+
+ proc := dll.MustFindProc("cfunc")
+
+ r, _, err := proc.Call(
+ 1,
+ uintptr(math.Float64bits(2.2)),
+ uintptr(math.Float32bits(3.3)),
+ uintptr(math.Float64bits(4.4e44)),
+ )
+ if r != 1 {
+ t.Errorf("got %d want 1 (err=%v)", r, err)
+ }
+}
+
func TestTimeBeginPeriod(t *testing.T) {
const TIMERR_NOERROR = 0
if *runtime.TimeBeginPeriodRetValue != TIMERR_NOERROR {