github.com/go-darwin/sys@v0.0.0-20220510002607-68fd01f054ca/abi.go (about)

     1  // Copyright 2021 The Go Darwin Authors
     2  // SPDX-License-Identifier: BSD-3-Clause
     3  
     4  //go:build darwin && amd64 && gc
     5  // +build darwin,amd64,gc
     6  
     7  package sys
     8  
     9  import (
    10  	_ "unsafe" // for go:linkname
    11  )
    12  
    13  // FuncPC* intrinsics.
    14  //
    15  // CAREFUL: In programs with plugins, FuncPC* can return different values
    16  // for the same function (because there are actually multiple copies of
    17  // the same function in the address space). To be safe, don't use the
    18  // results of this function in any == expression. It is only safe to
    19  // use the result as an address at which to start executing code.
    20  
    21  // FuncPCABI0 returns the entry PC of the function f, which must be a
    22  // direct reference of a function defined as ABI0. Otherwise it is a
    23  // compile-time error.
    24  //
    25  // Implemented as a compile intrinsic.
    26  //
    27  //go:linkname FuncPCABI0 internal/abi.FuncPCABI0
    28  func FuncPCABI0(f interface{}) uintptr
    29  
    30  // FuncPCABIInternal returns the entry PC of the function f. If f is a
    31  // direct reference of a function, it must be defined as ABIInternal.
    32  // Otherwise it is a compile-time error. If f is not a direct reference
    33  // of a defined function, it assumes that f is a func value. Otherwise
    34  // the behavior is undefined.
    35  //
    36  // Implemented as a compile intrinsic.
    37  //
    38  //go:linkname FuncPCABIInternal internal/abi.FuncPCABIInternal
    39  func FuncPCABIInternal(f interface{}) uintptr