From: Russ Cox Date: Tue, 10 Jan 2012 02:45:59 +0000 (-0800) Subject: runtime: add NumCPU X-Git-Tag: weekly.2012-01-15~105 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6dfdd4c1e34c753fb9c897eee355ee6ca3f007a8;p=gostls13.git runtime: add NumCPU R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5528061 --- diff --git a/src/pkg/runtime/extern.go b/src/pkg/runtime/extern.go index ea36355e66..e86da01732 100644 --- a/src/pkg/runtime/extern.go +++ b/src/pkg/runtime/extern.go @@ -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. diff --git a/src/pkg/runtime/runtime1.goc b/src/pkg/runtime/runtime1.goc index da2d0c5720..667131c1ee 100644 --- a/src/pkg/runtime/runtime1.goc +++ b/src/pkg/runtime/runtime1.goc @@ -8,3 +8,7 @@ package runtime func GOMAXPROCS(n int32) (ret int32) { ret = runtime·gomaxprocsfunc(n); } + +func NumCPU() (ret int32) { + ret = runtime·ncpu; +}