diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-01-30 15:38:19 +0100 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-01-30 15:38:19 +0100 |
commit | 4cecda6c347bd6902b960c6a35a967add7070b0d (patch) | |
tree | a462e224ff41ec9f3eb1a0b6e815806f9e8804ad /misc/cgo/testso | |
parent | 6c7ca6e4d4e26e4c8cbe0d183966011b3b088a0a (diff) | |
download | golang-4cecda6c347bd6902b960c6a35a967add7070b0d.tar.gz |
Imported Upstream version 2012.01.27upstream-weekly/2012.01.27
Diffstat (limited to 'misc/cgo/testso')
-rw-r--r-- | misc/cgo/testso/Makefile | 22 | ||||
-rw-r--r-- | misc/cgo/testso/cgoso.go | 16 | ||||
-rw-r--r-- | misc/cgo/testso/cgoso_c.c | 9 | ||||
-rw-r--r-- | misc/cgo/testso/main.go | 11 | ||||
-rwxr-xr-x | misc/cgo/testso/test.bash | 9 |
5 files changed, 67 insertions, 0 deletions
diff --git a/misc/cgo/testso/Makefile b/misc/cgo/testso/Makefile new file mode 100644 index 000000000..e472cf212 --- /dev/null +++ b/misc/cgo/testso/Makefile @@ -0,0 +1,22 @@ +# Copyright 2011 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. + +include ../../../src/Make.inc + +TARG=cgosotest + +CGO_DEPS+=libcgoso.so +CGO_LDFLAGS+=-lcgoso -L. +CLEANFILES+=out libcgoso.so +CGOFILES=\ + cgoso.go\ + +include ../../../src/Make.pkg + +libcgoso.so: cgoso_c.c + gcc cgoso_c.c -fPIC -o $@ $(_CGO_CFLAGS_$(GOARCH)) $(_CGO_LDFLAGS_$(GOOS)) + +out: install main.go + $(GC) $(GCFLAGS) $(GCIMPORTS) main.go + $(LD) -o $@ main.$O diff --git a/misc/cgo/testso/cgoso.go b/misc/cgo/testso/cgoso.go new file mode 100644 index 000000000..6eb9f40e3 --- /dev/null +++ b/misc/cgo/testso/cgoso.go @@ -0,0 +1,16 @@ +// Copyright 2011 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 cgosotest + +//void sofunc(void); +import "C" + +func Test() { + C.sofunc() +} + +//export goCallback +func goCallback() { +} diff --git a/misc/cgo/testso/cgoso_c.c b/misc/cgo/testso/cgoso_c.c new file mode 100644 index 000000000..e29f7e807 --- /dev/null +++ b/misc/cgo/testso/cgoso_c.c @@ -0,0 +1,9 @@ +// Copyright 2011 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. + +void sofunc(void) +{ + extern void goCallback(void); + goCallback(); +} diff --git a/misc/cgo/testso/main.go b/misc/cgo/testso/main.go new file mode 100644 index 000000000..672ab262b --- /dev/null +++ b/misc/cgo/testso/main.go @@ -0,0 +1,11 @@ +// Copyright 2011 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 main + +import "cgosotest" + +func main() { + cgosotest.Test() +} diff --git a/misc/cgo/testso/test.bash b/misc/cgo/testso/test.bash new file mode 100755 index 000000000..f275eb572 --- /dev/null +++ b/misc/cgo/testso/test.bash @@ -0,0 +1,9 @@ +#!/bin/sh +# Copyright 2011 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. + +set -e +gomake out +LD_LIBRARY_PATH=. ./out +gomake clean |