diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-11-16 18:33:11 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-11-16 18:33:11 +0000 |
commit | 5ed3bd2cd0fb519a0a22b99117b8a131fd6983d0 (patch) | |
tree | 9e5c736cd7c7630d6a53f936ec67bcef18a1db00 /libgo/go | |
parent | fa1f9c9ed97f703af5ac3ffd65f2c3379dea5afd (diff) |
runtime: replace runtime1.goc with Go and C code
A step toward eliminating goc2c.
Drop the exported parfor code; it was needed for tests in the past, but
no longer is. The Go 1.7 runtime no longer uses parfor.
Reviewed-on: https://go-review.googlesource.com/33324
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242509 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go')
-rw-r--r-- | libgo/go/runtime/debug.go | 17 | ||||
-rw-r--r-- | libgo/go/runtime/error.go | 5 | ||||
-rw-r--r-- | libgo/go/runtime/export_test.go | 28 | ||||
-rw-r--r-- | libgo/go/runtime/extern.go | 4 | ||||
-rw-r--r-- | libgo/go/runtime/stubs.go | 1 |
5 files changed, 23 insertions, 32 deletions
diff --git a/libgo/go/runtime/debug.go b/libgo/go/runtime/debug.go index 56e307fb3f55..43f6e1e00f62 100644 --- a/libgo/go/runtime/debug.go +++ b/libgo/go/runtime/debug.go @@ -4,6 +4,11 @@ package runtime +import ( + "runtime/internal/atomic" + "unsafe" +) + // GOMAXPROCS sets the maximum number of CPUs that can be executing // simultaneously and returns the previous setting. If n < 1, it does not // change the current setting. @@ -19,10 +24,18 @@ func GOMAXPROCS(n int) int func NumCPU() int // NumCgoCall returns the number of cgo calls made by the current process. -func NumCgoCall() int64 +func NumCgoCall() int64 { + var n int64 + for mp := (*m)(atomic.Loadp(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()) +} // Get field tracking information. Only fields with a tag go:"track" // are tracked. This function will add every such field that is diff --git a/libgo/go/runtime/error.go b/libgo/go/runtime/error.go index 36830016a5b4..d5d502c396d1 100644 --- a/libgo/go/runtime/error.go +++ b/libgo/go/runtime/error.go @@ -133,7 +133,10 @@ type stringer interface { String() string } -func typestring(interface{}) string +func typestring(x interface{}) string { + e := efaceOf(&x) + return *e._type.string +} // For calling from C. // Prints an argument passed to panic. diff --git a/libgo/go/runtime/export_test.go b/libgo/go/runtime/export_test.go index d3443566d920..b8b129d815db 100644 --- a/libgo/go/runtime/export_test.go +++ b/libgo/go/runtime/export_test.go @@ -21,11 +21,10 @@ import ( //var F64toint = f64toint //var Sqrt = sqrt -func golockedOSThread() bool - var Entersyscall = entersyscall var Exitsyscall = exitsyscall -var LockedOSThread = golockedOSThread + +// var LockedOSThread = lockedOSThread // var Xadduintptr = xadduintptr @@ -44,29 +43,6 @@ func LFStackPop(head *uint64) *LFNode { return (*LFNode)(unsafe.Pointer(lfstackpop(head))) } -type ParFor struct { - body func(*ParFor, uint32) - done uint32 - Nthr uint32 - thrseq uint32 - Cnt uint32 - wait bool -} - -func newParFor(nthrmax uint32) *ParFor -func parForSetup(desc *ParFor, nthr, n uint32, wait bool, body func(*ParFor, uint32)) -func parForDo(desc *ParFor) -func parForIters(desc *ParFor, tid uintptr) (uintptr, uintptr) - -var NewParFor = newParFor -var ParForSetup = parForSetup -var ParForDo = parForDo - -func ParForIters(desc *ParFor, tid uint32) (uint32, uint32) { - begin, end := parForIters(desc, uintptr(tid)) - return uint32(begin), uint32(end) -} - func GCMask(x interface{}) (ret []byte) { return nil } diff --git a/libgo/go/runtime/extern.go b/libgo/go/runtime/extern.go index e0c5aacc55a6..c0746878c4f0 100644 --- a/libgo/go/runtime/extern.go +++ b/libgo/go/runtime/extern.go @@ -274,13 +274,11 @@ func SetFinalizer(obj interface{}, finalizer interface{}) // the actual system call. func KeepAlive(interface{}) -func getgoroot() string - // GOROOT returns the root of the Go tree. // It uses the GOROOT environment variable, if set, // or else the root used during the Go build. func GOROOT() string { - s := getgoroot() + s := gogetenv("GOROOT") if s != "" { return s } diff --git a/libgo/go/runtime/stubs.go b/libgo/go/runtime/stubs.go index d0641ed71503..8d90cd6061f5 100644 --- a/libgo/go/runtime/stubs.go +++ b/libgo/go/runtime/stubs.go @@ -501,6 +501,7 @@ func needm() func dropm() func sigprof() func mcount() int32 +func gcount() int32 // Signal trampoline, written in C. func sigtramp() |