...
Source file
src/runtime/runtime.go
Documentation: runtime
1
2
3
4
5 package runtime
6
7 import (
8 "runtime/internal/atomic"
9 _ "unsafe"
10 )
11
12
13
14
15
16 var ticks ticksType
17
18 type ticksType struct {
19 lock mutex
20 pad uint32
21 val uint64
22 }
23
24
25 func tickspersecond() int64 {
26 r := int64(atomic.Load64(&ticks.val))
27 if r != 0 {
28 return r
29 }
30 lock(&ticks.lock)
31 r = int64(ticks.val)
32 if r == 0 {
33 t0 := nanotime()
34 c0 := cputicks()
35 usleep(100 * 1000)
36 t1 := nanotime()
37 c1 := cputicks()
38 if t1 == t0 {
39 t1++
40 }
41 r = (c1 - c0) * 1000 * 1000 * 1000 / (t1 - t0)
42 if r == 0 {
43 r++
44 }
45 atomic.Store64(&ticks.val, uint64(r))
46 }
47 unlock(&ticks.lock)
48 return r
49 }
50
51 var envs []string
52 var argslice []string
53
54
55 func syscall_runtime_envs() []string { return append([]string{}, envs...) }
56
57
58 func syscall_Getpagesize() int { return int(physPageSize) }
59
60
61 func os_runtime_args() []string { return append([]string{}, argslice...) }
62
63
64
65 func syscall_Exit(code int) {
66 exit(int32(code))
67 }
68
View as plain text