github.com/nikandfor/loc@v0.5.1/unsafe_pre_go1.20.go (about)

     1  //go:build nikandfor_loc_unsafe && !go1.20
     2  // +build nikandfor_loc_unsafe,!go1.20
     3  
     4  package loc
     5  
     6  import "unsafe"
     7  
     8  //nolint
     9  type (
    10  	funcID uint8
    11  
    12  	funcInfo struct {
    13  		entry *uintptr
    14  		datap unsafe.Pointer
    15  	}
    16  
    17  	inlinedCall struct {
    18  		parent   int16  // index of parent in the inltree, or < 0
    19  		funcID   funcID // type of the called function
    20  		_        byte
    21  		file     int32 // fileno index into filetab
    22  		line     int32 // line number of the call site
    23  		func_    int32 // offset into pclntab for name of called function
    24  		parentPc int32 // position of an instruction whose source position is the call site (offset from entry)
    25  	}
    26  )
    27  
    28  // FuncEntry is functions entry point.
    29  func (l PC) FuncEntry() PC {
    30  	funcInfo := findfunc(l)
    31  	if funcInfo.entry == nil {
    32  		return 0
    33  	}
    34  	return funcInfoEntry(funcInfo)
    35  }