package runtime
import (
"runtime/internal/atomic"
"unsafe"
)
var ticks ticksType
type ticksType struct {
lock mutex
val atomic .Int64
}
func tickspersecond () int64 {
r := ticks .val .Load ()
if r != 0 {
return r
}
lock (&ticks .lock )
r = ticks .val .Load ()
if r == 0 {
t0 := nanotime ()
c0 := cputicks ()
usleep (100 * 1000 )
t1 := nanotime ()
c1 := cputicks ()
if t1 == t0 {
t1 ++
}
r = (c1 - c0 ) * 1000 * 1000 * 1000 / (t1 - t0 )
if r == 0 {
r ++
}
ticks .val .Store (r )
}
unlock (&ticks .lock )
return r
}
var envs []string
var argslice []string
func syscall_runtime_envs () []string { return append ([]string {}, envs ...) }
func syscall_Getpagesize () int { return int (physPageSize ) }
func os_runtime_args () []string { return append ([]string {}, argslice ...) }
func syscall_Exit (code int ) {
exit (int32 (code ))
}
var godebugDefault string
var godebugUpdate atomic .Pointer [func (string , string )]
var godebugEnv atomic .Pointer [string ]
var godebugNewIncNonDefault atomic .Pointer [func (string ) func ()]
func godebug_setUpdate (update func (string , string )) {
p := new (func (string , string ))
*p = update
godebugUpdate .Store (p )
godebugNotify (false )
}
func godebug_setNewIncNonDefault (newIncNonDefault func (string ) func ()) {
p := new (func (string ) func ())
*p = newIncNonDefault
godebugNewIncNonDefault .Store (p )
}
type godebugInc struct {
name string
inc atomic .Pointer [func ()]
}
func (g *godebugInc ) IncNonDefault () {
inc := g .inc .Load ()
if inc == nil {
newInc := godebugNewIncNonDefault .Load ()
if newInc == nil {
return
}
inc = new (func ())
*inc = (*newInc )(g .name )
g .inc .Store (inc )
}
(*inc )()
}
func godebugNotify (envChanged bool ) {
update := godebugUpdate .Load ()
var env string
if p := godebugEnv .Load (); p != nil {
env = *p
}
if envChanged {
reparsedebugvars (env )
}
if update != nil {
(*update )(godebugDefault , env )
}
}
func syscall_runtimeSetenv (key , value string ) {
setenv_c (key , value )
if key == "GODEBUG" {
p := new (string )
*p = value
godebugEnv .Store (p )
godebugNotify (true )
}
}
func syscall_runtimeUnsetenv (key string ) {
unsetenv_c (key )
if key == "GODEBUG" {
godebugEnv .Store (nil )
godebugNotify (true )
}
}
func writeErrStr (s string ) {
write (2 , unsafe .Pointer (unsafe .StringData (s )), int32 (len (s )))
}
var auxv []uintptr
func getAuxv () []uintptr { return auxv }
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .