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

     1  // Copyright 2021 The Go Darwin Authors
     2  // SPDX-License-Identifier: BSD-3-Clause
     3  
     4  //go:build darwin
     5  // +build darwin
     6  
     7  package sys
     8  
     9  import (
    10  	_ "unsafe" // for go:linkname
    11  )
    12  
    13  //go:nosplit
    14  //go:linkname FuncPC runtime.funcPC
    15  func funcPC(f interface{}) uintptr
    16  
    17  // FuncPC returns the entry PC of the function f.
    18  // It assumes that f is a func value. Otherwise the behavior is undefined.
    19  //
    20  // CAREFUL: In programs with plugins, funcPC can return different values
    21  // for the same function (because there are actually multiple copies of
    22  // the same function in the address space). To be safe, don't use the
    23  // results of this function in any == expression. It is only safe to
    24  // use the result as an address at which to start executing code.
    25  //
    26  //go:nosplit
    27  func FuncPC(f interface{}) uintptr {
    28  	return funcPC(f)
    29  }