mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-05 05:04:04 -08:00
48 lines
747 B
Go
48 lines
747 B
Go
|
// +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
|
||
|
}
|