summaryrefslogtreecommitdiff
path: root/misc/cgo/test
diff options
context:
space:
mode:
Diffstat (limited to 'misc/cgo/test')
-rw-r--r--misc/cgo/test/backdoor/backdoor.go7
-rw-r--r--misc/cgo/test/backdoor/runtime.c (renamed from misc/cgo/test/runtime.c)4
-rw-r--r--misc/cgo/test/basic.go4
-rw-r--r--misc/cgo/test/callback.go8
-rw-r--r--misc/cgo/test/callback_c.c20
-rw-r--r--misc/cgo/test/issue1328.go2
-rw-r--r--misc/cgo/test/issue1560.go5
7 files changed, 37 insertions, 13 deletions
diff --git a/misc/cgo/test/backdoor/backdoor.go b/misc/cgo/test/backdoor/backdoor.go
new file mode 100644
index 000000000..efe4f01f4
--- /dev/null
+++ b/misc/cgo/test/backdoor/backdoor.go
@@ -0,0 +1,7 @@
+// Copyright 2012 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 backdoor
+
+func LockedOSThread() bool // in runtime.c
diff --git a/misc/cgo/test/runtime.c b/misc/cgo/test/backdoor/runtime.c
index e087c7622..54e6a1ef8 100644
--- a/misc/cgo/test/runtime.c
+++ b/misc/cgo/test/backdoor/runtime.c
@@ -3,6 +3,8 @@
// license that can be found in the LICENSE file.
// Expose some runtime functions for testing.
+// Must be in a non-cgo-using package so that
+// the go command compiles this file with 6c, not gcc.
typedef char bool;
@@ -14,7 +16,7 @@ FLUSH(void*)
}
void
-·lockedOSThread(bool b)
+·LockedOSThread(bool b)
{
b = runtime·lockedOSThread();
FLUSH(&b);
diff --git a/misc/cgo/test/basic.go b/misc/cgo/test/basic.go
index cd6d88168..70ec5e43a 100644
--- a/misc/cgo/test/basic.go
+++ b/misc/cgo/test/basic.go
@@ -55,7 +55,7 @@ int add(int x, int y) {
*/
import "C"
import (
- "os"
+ "syscall"
"testing"
"unsafe"
)
@@ -110,7 +110,7 @@ func testErrno(t *testing.T) {
C.fclose(f)
t.Fatalf("C.fopen: should fail")
}
- if err != os.ENOENT {
+ if err != syscall.ENOENT {
t.Fatalf("C.fopen: unexpected error: %v", err)
}
}
diff --git a/misc/cgo/test/callback.go b/misc/cgo/test/callback.go
index ef852561b..e6a1462b3 100644
--- a/misc/cgo/test/callback.go
+++ b/misc/cgo/test/callback.go
@@ -6,14 +6,12 @@ package cgotest
/*
void callback(void *f);
-void callGoFoo(void) {
- extern void goFoo(void);
- goFoo();
-}
+void callGoFoo(void);
*/
import "C"
import (
+ "./backdoor"
"runtime"
"testing"
"unsafe"
@@ -43,7 +41,7 @@ func testCallbackGC(t *testing.T) {
nestedCall(runtime.GC)
}
-func lockedOSThread() bool // in runtime.c
+var lockedOSThread = backdoor.LockedOSThread
func testCallbackPanic(t *testing.T) {
// Make sure panic during callback unwinds properly.
diff --git a/misc/cgo/test/callback_c.c b/misc/cgo/test/callback_c.c
index c296d70e0..47f07301b 100644
--- a/misc/cgo/test/callback_c.c
+++ b/misc/cgo/test/callback_c.c
@@ -15,3 +15,23 @@ callback(void *f)
goCallback(f);
data[sizeof(data)-1] = 0;
}
+
+void
+callGoFoo(void)
+{
+ extern void goFoo(void);
+ goFoo();
+}
+
+void
+IntoC(void)
+{
+ BackIntoGo();
+}
+
+void
+twoSleep(int n)
+{
+ BackgroundSleep(n);
+ sleep(n);
+}
diff --git a/misc/cgo/test/issue1328.go b/misc/cgo/test/issue1328.go
index e01207dd9..e1796d6f7 100644
--- a/misc/cgo/test/issue1328.go
+++ b/misc/cgo/test/issue1328.go
@@ -7,7 +7,7 @@ package cgotest
import "testing"
// extern void BackIntoGo(void);
-// void IntoC() { BackIntoGo(); }
+// void IntoC(void);
import "C"
//export BackIntoGo
diff --git a/misc/cgo/test/issue1560.go b/misc/cgo/test/issue1560.go
index 833b14ae6..3faa966e7 100644
--- a/misc/cgo/test/issue1560.go
+++ b/misc/cgo/test/issue1560.go
@@ -10,10 +10,7 @@ package cgotest
unsigned int sleep(unsigned int seconds);
extern void BackgroundSleep(int);
-void twoSleep(int n) {
- BackgroundSleep(n);
- sleep(n);
-}
+void twoSleep(int);
*/
import "C"