]> Cypherpunks repositories - gostls13.git/commitdiff
cgo: export unsafe.Pointer as void*
authorGustavo Niemeyer <gustavo@niemeyer.net>
Tue, 11 Jan 2011 16:12:06 +0000 (11:12 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 11 Jan 2011 16:12:06 +0000 (11:12 -0500)
This will enable functions which use unsafe.Pointer as an argument
to be correctly exported by cgo.

R=rsc
CC=golang-dev
https://golang.org/cl/3849043

src/cmd/cgo/out.go

index 481fff21978978472482cbcf4a47acabf547f0cf..c3f9ae60b10d711a0077fa0ca950d1fe3078ea9b 100644 (file)
@@ -606,6 +606,11 @@ func (p *Package) cgoType(e ast.Expr) *Type {
                        }
                        return r
                }
+       case *ast.SelectorExpr:
+               id, ok := t.X.(*ast.Ident)
+               if ok && id.Name == "unsafe" && t.Sel.Name == "Pointer" {
+                       return &Type{Size: p.PtrSize, Align: p.PtrSize, C: "void*"}
+               }
        }
        error(e.Pos(), "unrecognized Go type %T", e)
        return &Type{Size: 4, Align: 4, C: "int"}