1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
8 "runtime/internal/atomic"
12 //go:generate go run wincallback.go
13 //go:generate go run mkduff.go
14 //go:generate go run mkfastlog2table.go
15 //go:generate go run mklockrank.go -o lockrank.go
19 type ticksType struct {
24 // Note: Called by runtime/pprof in addition to runtime code.
25 func tickspersecond() int64 {
41 r = (c1 - c0) * 1000 * 1000 * 1000 / (t1 - t0)
54 //go:linkname syscall_runtime_envs syscall.runtime_envs
55 func syscall_runtime_envs() []string { return append([]string{}, envs...) }
57 //go:linkname syscall_Getpagesize syscall.Getpagesize
58 func syscall_Getpagesize() int { return int(physPageSize) }
60 //go:linkname os_runtime_args os.runtime_args
61 func os_runtime_args() []string { return append([]string{}, argslice...) }
63 //go:linkname syscall_Exit syscall.Exit
65 func syscall_Exit(code int) {
69 var godebugDefault string
70 var godebugUpdate atomic.Pointer[func(string, string)]
71 var godebugEnv atomic.Pointer[string] // set by parsedebugvars
72 var godebugNewIncNonDefault atomic.Pointer[func(string) func()]
74 //go:linkname godebug_setUpdate internal/godebug.setUpdate
75 func godebug_setUpdate(update func(string, string)) {
76 p := new(func(string, string))
78 godebugUpdate.Store(p)
82 //go:linkname godebug_setNewIncNonDefault internal/godebug.setNewIncNonDefault
83 func godebug_setNewIncNonDefault(newIncNonDefault func(string) func()) {
84 p := new(func(string) func())
86 godebugNewIncNonDefault.Store(p)
89 // A godebugInc provides access to internal/godebug's IncNonDefault function
90 // for a given GODEBUG setting.
91 // Calls before internal/godebug registers itself are dropped on the floor.
92 type godebugInc struct {
94 inc atomic.Pointer[func()]
97 func (g *godebugInc) IncNonDefault() {
100 newInc := godebugNewIncNonDefault.Load()
104 // If other goroutines are racing here, no big deal. One will win,
105 // and all the inc functions will be using the same underlying
108 *inc = (*newInc)(g.name)
114 func godebugNotify(envChanged bool) {
115 update := godebugUpdate.Load()
117 if p := godebugEnv.Load(); p != nil {
121 reparsedebugvars(env)
124 (*update)(godebugDefault, env)
128 //go:linkname syscall_runtimeSetenv syscall.runtimeSetenv
129 func syscall_runtimeSetenv(key, value string) {
131 if key == "GODEBUG" {
139 //go:linkname syscall_runtimeUnsetenv syscall.runtimeUnsetenv
140 func syscall_runtimeUnsetenv(key string) {
142 if key == "GODEBUG" {
143 godebugEnv.Store(nil)
148 // writeErrStr writes a string to descriptor 2.
151 func writeErrStr(s string) {
152 write(2, unsafe.Pointer(unsafe.StringData(s)), int32(len(s)))