]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add NumCPU
authorRuss Cox <rsc@golang.org>
Tue, 10 Jan 2012 02:45:59 +0000 (18:45 -0800)
committerRuss Cox <rsc@golang.org>
Tue, 10 Jan 2012 02:45:59 +0000 (18:45 -0800)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5528061

src/pkg/runtime/extern.go
src/pkg/runtime/runtime1.goc

index ea36355e66cb54124b141fca6a058123a4c1d361..e86da01732422f98665090295beaf153ec4a3afe 100644 (file)
@@ -107,6 +107,9 @@ func (f *Func) FileLine(pc uintptr) (file string, line int) {
 // mid returns the current os thread (m) id.
 func mid() uint32
 
+// NumCPU returns the number of CPUs on the local machine.
+func NumCPU() int
+
 // Semacquire waits until *s > 0 and then atomically decrements it.
 // It is intended as a simple sleep primitive for use by the synchronization
 // library and should not be used directly.
index da2d0c5720832471a5d39832de79015ce3f4dc06..667131c1eee1eaed75b08aa63d3f6e639bb5248c 100644 (file)
@@ -8,3 +8,7 @@ package runtime
 func GOMAXPROCS(n int32) (ret int32) {
        ret = runtime·gomaxprocsfunc(n);
 }
+
+func NumCPU() (ret int32) {
+       ret = runtime·ncpu;
+}