runtime: scan register backing store on ia64
[official-gcc.git] / libgo / go / runtime / runtime.go
blobd19d6afed388fc90b3484adb79a22c81f5112a8b
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.
5 package runtime
7 import (
8 "runtime/internal/atomic"
9 _ "unsafe" // for go:linkname
12 //go:generate go run wincallback.go
13 //go:generate go run mkduff.go
14 //go:generate go run mkfastlog2table.go
16 // For gccgo, while we still have C runtime code, use go:linkname to
17 // rename some functions to themselves, so that the compiler will
18 // export them.
20 //go:linkname tickspersecond runtime.tickspersecond
22 var ticksLock mutex
23 var ticksVal uint64
25 // Note: Called by runtime/pprof in addition to runtime code.
26 func tickspersecond() int64 {
27 r := int64(atomic.Load64(&ticksVal))
28 if r != 0 {
29 return r
31 lock(&ticksLock)
32 r = int64(ticksVal)
33 if r == 0 {
34 t0 := nanotime()
35 c0 := cputicks()
36 usleep(100 * 1000)
37 t1 := nanotime()
38 c1 := cputicks()
39 if t1 == t0 {
40 t1++
42 r = (c1 - c0) * 1000 * 1000 * 1000 / (t1 - t0)
43 if r == 0 {
44 r++
46 atomic.Store64(&ticksVal, uint64(r))
48 unlock(&ticksLock)
49 return r
52 var envs []string
53 var argslice []string
55 //go:linkname syscall_runtime_envs syscall.runtime_envs
56 func syscall_runtime_envs() []string { return append([]string{}, envs...) }
58 //go:linkname syscall_Getpagesize syscall.Getpagesize
59 func syscall_Getpagesize() int { return int(physPageSize) }
61 //go:linkname os_runtime_args os.runtime_args
62 func os_runtime_args() []string { return append([]string{}, argslice...) }
64 //go:linkname syscall_Exit syscall.Exit
65 //go:nosplit
66 func syscall_Exit(code int) {
67 exit(int32(code))
70 // Temporary, for the gccgo runtime code written in C.
71 //go:linkname get_envs runtime_get_envs
72 func get_envs() []string { return envs }
74 //go:linkname get_args runtime_get_args
75 func get_args() []string { return argslice }