• Ian Lance Taylor's avatar
    cmd/cgo: use alias for unsafe rather than separate functions · 3c1e1c30
    Ian Lance Taylor authored
    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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    3c1e1c30
main.go 9.53 KB