You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
prometheus/vendor/github.com/petermattis/goid/goid_go1.9plus.go

48 lines
747 B

// +build amd64 amd64p32 arm
// +build go1.9
package goid
import "unsafe"
type stack struct {
lo uintptr
hi uintptr
}
type gobuf struct {
sp uintptr
pc uintptr
g uintptr
ctxt uintptr
ret uintptr
lr uintptr
bp uintptr
}
type g struct {
stack stack
stackguard0 uintptr
stackguard1 uintptr
_panic uintptr
_defer uintptr
m uintptr
sched gobuf
syscallsp uintptr
syscallpc uintptr
stktopsp uintptr
param unsafe.Pointer
atomicstatus uint32
stackLock uint32
goid int64 // Here it is!
}
// Backdoor access to runtime·getg().
func getg() uintptr // in goid_go1.5plus{,_arm}.s
func Get() int64 {
gg := (*g)(unsafe.Pointer(getg()))
return gg.goid
}