]> Cypherpunks repositories - gostls13.git/commit
cmd/cgo: use alias for unsafe rather than separate functions
authorIan Lance Taylor <iant@golang.org>
Thu, 13 Oct 2016 00:09:54 +0000 (17:09 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 13 Oct 2016 16:41:06 +0000 (16:41 +0000)
commit3c1e1c30fdfbdaf7cf5f947c53245f1c28e56f91
tree4ac6a449a7db1070b75ddaae28012544832324fd
parentdc46b882d583a32c7de37a7cfa8b423eb58d0296
cmd/cgo: use alias for unsafe rather than separate functions

When we need to generate a call to _cgoCheckPointer, we need to type
assert the result back to the desired type. That is harder when the type
is unsafe.Pointer, as the package can have values of unsafe.Pointer
types without actually importing unsafe, by mixing C void* and :=. We
used to handle this by generating a special function for each needed
type, and defining that function in a separate file where we did import
unsafe.

Simplify the code by not generating those functions, but instead just
import unsafe under the alias _cgo_unsafe. This is a simplification step
toward a fix for issue #16591.

Change-Id: I0edb3e04b6400ca068751709fe063397cf960a54
Reviewed-on: https://go-review.googlesource.com/30973
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/cgo/gcc.go
src/cmd/cgo/main.go
src/cmd/cgo/out.go