tlog.app/go/tlog@v0.23.1/unsafe.go (about)

     1  package tlog
     2  
     3  import (
     4  	"unsafe"
     5  
     6  	"tlog.app/go/loc"
     7  )
     8  
     9  //go:noescape
    10  //go:linkname caller1 runtime.callers
    11  func caller1(skip int, pc *loc.PC, len, cap int) int
    12  
    13  // noescape hides a pointer from escape analysis.  noescape is
    14  // the identity function but escape analysis doesn't think the
    15  // output depends on the input.  noescape is inlined and currently
    16  // compiles down to zero instructions.
    17  // USE CAREFULLY!
    18  //
    19  //go:nosplit
    20  func noescape(p unsafe.Pointer) unsafe.Pointer {
    21  	x := uintptr(p)
    22  	return unsafe.Pointer(x ^ 0) //nolint:staticcheck
    23  }