var ticks … type ticksType … // init initializes ticks to maximize the chance that we have a good ticksPerSecond reference. // // Must not run concurrently with ticksPerSecond. func (t *ticksType) init() { … } const minTimeForTicksPerSecond … // ticksPerSecond returns a conversion rate between the cputicks clock and the nanotime clock. // // Note: Clocks are hard. Using this as an actual conversion rate for timestamps is ill-advised // and should be avoided when possible. Use only for durations, where a tiny error term isn't going // to make a meaningful difference in even a 1ms duration. If an accurate timestamp is needed, // use nanotime instead. (The entire Windows platform is a broad exception to this rule, where nanotime // produces timestamps on such a coarse granularity that the error from this conversion is actually // preferable.) // // The strategy for computing the conversion rate is to write down nanotime and cputicks as // early in process startup as possible. From then, we just need to wait until we get values // from nanotime that we can use (some platforms have a really coarse system time granularity). // We require some amount of time to pass to ensure that the conversion rate is fairly accurate // in aggregate. But because we compute this rate lazily, there's a pretty good chance a decent // amount of time has passed by the time we get here. // // Must be called from a normal goroutine context (running regular goroutine with a P). // // Called by runtime/pprof in addition to runtime code. // // TODO(mknyszek): This doesn't account for things like CPU frequency scaling. Consider // a more sophisticated and general approach in the future. func ticksPerSecond() int64 { … } var envs … var argslice … //go:linkname syscall_runtime_envs syscall.runtime_envs func syscall_runtime_envs() []string { … } //go:linkname syscall_Getpagesize syscall.Getpagesize func syscall_Getpagesize() int { … } //go:linkname os_runtime_args os.runtime_args func os_runtime_args() []string { … } //go:linkname syscall_Exit syscall.Exit //go:nosplit func syscall_Exit(code int) { … } var godebugDefault … var godebugUpdate … var godebugEnv … var godebugNewIncNonDefault … //go:linkname godebug_setUpdate internal/godebug.setUpdate func godebug_setUpdate(update func(string, string)) { … } //go:linkname godebug_setNewIncNonDefault internal/godebug.setNewIncNonDefault func godebug_setNewIncNonDefault(newIncNonDefault func(string) func()) { … } type godebugInc … func (g *godebugInc) IncNonDefault() { … } func godebugNotify(envChanged bool) { … } //go:linkname syscall_runtimeSetenv syscall.runtimeSetenv func syscall_runtimeSetenv(key, value string) { … } //go:linkname syscall_runtimeUnsetenv syscall.runtimeUnsetenv func syscall_runtimeUnsetenv(key string) { … } // writeErrStr writes a string to descriptor 2. // If SetCrashOutput(f) was called, it also writes to f. // //go:nosplit func writeErrStr(s string) { … } // writeErrData is the common parts of writeErr{,Str}. // //go:nosplit func writeErrData(data *byte, n int32) { … } var crashFD … //go:linkname setCrashFD func setCrashFD(fd uintptr) uintptr { … } var auxv … // golang.org/x/sys/cpu uses getAuxv via linkname. // Do not remove or change the type signature. // (See go.dev/issue/57336.) // // getAuxv should be an internal detail, // but widely used packages access it using linkname. // Notable members of the hall of shame include: // - github.com/cilium/ebpf // // Do not remove or change the type signature. // See go.dev/issue/67401. // //go:linkname getAuxv func getAuxv() []uintptr { … } var zeroVal …