Beispiel #1
0
func CgoCallbackGC() {
	const P = 100
	done := make(chan bool)
	// allocate a bunch of stack frames and spray them with pointers
	for i := 0; i < P; i++ {
		go func() {
			grow()
			done <- true
		}()
	}
	for i := 0; i < P; i++ {
		<-done
	}
	// now give these stack frames to cgo callbacks
	for i := 0; i < P; i++ {
		go func() {
			C.foo()
			done <- true
		}()
	}
	for i := 0; i < P; i++ {
		<-done
	}
	fmt.Printf("OK\n")
}
Beispiel #2
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	fmt.Println(C.GoString(C.foo()))
}
func main() {
	// Don't report error for package "C". It's for Cgo.
	println(C.bar)
	println(C.foo())
}
func main() {
	fmt.Println(C.GoString(C.foo()))
}
Beispiel #5
0
func main() {
	fmt.Println(C.count)
	C.foo()
}
Beispiel #6
0
func CallCgo(n int) {
	for i := 0; i < n; i++ {
		C.foo()
	}
}
Beispiel #7
0
func main() {
	fmt.Println("Go: main")
	C.registerIt(C.foo())
}
Beispiel #8
0
func main() {
	fmt.Println("From libfoo: ", C.foo())
}
Beispiel #9
0
func Bar() {
	C.foo()
}