aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/debug.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-08-28 10:46:59 -0400
committerRuss Cox <rsc@golang.org>2014-08-28 10:46:59 -0400
commit6179aca54825867db3ab15bfff28fbda73e49378 (patch)
treeed3dc9d0aa018e90985d6ad7483ed974aa7394cf /src/pkg/runtime/debug.go
parentb53b47f5ac9e11fdcd3f704bc2cb0828bdee6958 (diff)
downloadgo-6179aca54825867db3ab15bfff28fbda73e49378.tar.xz
runtime: convert runtime1.goc, noasm_arm.goc to Go
LGTM=dvyukov R=golang-codereviews, bradfitz, dvyukov CC=golang-codereviews, iant, khr https://golang.org/cl/135070043
Diffstat (limited to 'src/pkg/runtime/debug.go')
-rw-r--r--src/pkg/runtime/debug.go26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/pkg/runtime/debug.go b/src/pkg/runtime/debug.go
index af44a64741..181fac4615 100644
--- a/src/pkg/runtime/debug.go
+++ b/src/pkg/runtime/debug.go
@@ -4,6 +4,8 @@
package runtime
+import "unsafe"
+
// Breakpoint executes a breakpoint trap.
func Breakpoint()
@@ -21,16 +23,32 @@ func UnlockOSThread()
// change the current setting.
// The number of logical CPUs on the local machine can be queried with NumCPU.
// This call will go away when the scheduler improves.
-func GOMAXPROCS(n int) int
+func GOMAXPROCS(n int) int {
+ return int(gomaxprocsfunc(int32(n)))
+}
+
+func gomaxprocsfunc(int32) int32 // proc.c
// NumCPU returns the number of logical CPUs on the local machine.
-func NumCPU() int
+func NumCPU() int {
+ return int(ncpu)
+}
// NumCgoCall returns the number of cgo calls made by the current process.
-func NumCgoCall() int64
+func NumCgoCall() int64 {
+ var n int64
+ for mp := (*m)(atomicloadp(unsafe.Pointer(&allm))); mp != nil; mp = mp.alllink {
+ n += int64(mp.ncgocall)
+ }
+ return n
+}
// NumGoroutine returns the number of goroutines that currently exist.
-func NumGoroutine() int
+func NumGoroutine() int {
+ return int(gcount())
+}
+
+func gcount() int32
// MemProfileRate controls the fraction of memory allocations
// that are recorded and reported in the memory profile.