mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-04 12:27:37 +03:00
30 lines
528 B
Go
30 lines
528 B
Go
//go:build !disable_unsafe
|
|
|
|
package buf
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
type dbgVar struct {
|
|
name string
|
|
value *int32
|
|
}
|
|
|
|
//go:linkname dbgvars runtime.dbgvars
|
|
var dbgvars any
|
|
|
|
// go.info.runtime.dbgvars: relocation target go.info.[]github.com/sagernet/sing/common/buf.dbgVar not defined
|
|
// var dbgvars []dbgVar
|
|
|
|
//nolint:gochecknoinits
|
|
func init() {
|
|
debugVars := *(*[]dbgVar)(unsafe.Pointer(&dbgvars))
|
|
for _, v := range debugVars {
|
|
if v.name == "invalidptr" {
|
|
*v.value = 0
|
|
return
|
|
}
|
|
}
|
|
panic("can't disable invalidptr")
|
|
}
|