]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/test: test of issue 4339
authorRuss Cox <rsc@golang.org>
Wed, 11 Sep 2013 13:56:38 +0000 (09:56 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 11 Sep 2013 13:56:38 +0000 (09:56 -0400)
This is not quite what that issue reports,
because this does not involve a DLL.
But I wanted to make sure this much was working.

Update #4339

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13653043

misc/cgo/test/cgo_test.go
misc/cgo/test/issue4339.c [new file with mode: 0644]
misc/cgo/test/issue4339.go [new file with mode: 0644]
misc/cgo/test/issue4339.h [new file with mode: 0644]

index f86305bf65c7f96ce84c539f870e57c6aa035298..e36f93597c1dd5df39e5a5e474a0c87589a9303f 100644 (file)
@@ -45,5 +45,6 @@ func Test5603(t *testing.T)                { test5603(t) }
 func Test3250(t *testing.T)                { test3250(t) }
 func TestCallbackStack(t *testing.T)       { testCallbackStack(t) }
 func TestFpVar(t *testing.T)               { testFpVar(t) }
+func Test4339(t *testing.T)                { test4339(t) }
 
 func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
diff --git a/misc/cgo/test/issue4339.c b/misc/cgo/test/issue4339.c
new file mode 100644 (file)
index 0000000..15d0004
--- /dev/null
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include "issue4339.h"
+
+static void
+impl(void)
+{
+       //printf("impl\n");
+}
+
+Issue4339 exported4339 = {"bar", impl};
+
+void
+handle4339(Issue4339 *x)
+{
+       //printf("handle\n");
+       x->bar();
+       //printf("done\n");
+}
diff --git a/misc/cgo/test/issue4339.go b/misc/cgo/test/issue4339.go
new file mode 100644 (file)
index 0000000..f734a25
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2013 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cgotest
+
+/*
+#include "issue4339.h"
+*/
+import "C"
+
+import "testing"
+
+func test4339(t *testing.T) {
+       C.handle4339(&C.exported4339)
+}
diff --git a/misc/cgo/test/issue4339.h b/misc/cgo/test/issue4339.h
new file mode 100644 (file)
index 0000000..20f6ceb
--- /dev/null
@@ -0,0 +1,9 @@
+typedef struct Issue4339 Issue4339;
+
+struct Issue4339 {
+       char *name;
+       void (*bar)(void);
+};
+
+extern Issue4339 exported4339;
+void   handle4339(Issue4339*);