Source file
src/runtime/runtime.go
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 struct {
17 lock mutex
18 pad uint32
19 val uint64
20 }
21
22
23 func tickspersecond() int64 {
24 r := int64(atomic.Load64(&ticks.val))
25 if r != 0 {
26 return r
27 }
28 lock(&ticks.lock)
29 r = int64(ticks.val)
30 if r == 0 {
31 t0 := nanotime()
32 c0 := cputicks()
33 usleep(100 * 1000)
34 t1 := nanotime()
35 c1 := cputicks()
36 if t1 == t0 {
37 t1++
38 }
39 r = (c1 - c0) * 1000 * 1000 * 1000 / (t1 - t0)
40 if r == 0 {
41 r++
42 }
43 atomic.Store64(&ticks.val, uint64(r))
44 }
45 unlock(&ticks.lock)
46 return r
47 }
48
49 var envs []string
50 var argslice []string
51
52
53 func syscall_runtime_envs() []string { return append([]string{}, envs...) }
54
55
56 func syscall_Getpagesize() int { return int(physPageSize) }
57
58
59 func os_runtime_args() []string { return append([]string{}, argslice...) }
60
61
62
63 func syscall_Exit(code int) {
64 exit(int32(code))
65 }
66
View as plain text