aboutsummaryrefslogtreecommitdiff
path: root/libgo/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2016-11-16 18:33:11 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2016-11-16 18:33:11 +0000
commit350767bf22688f7645fe959370240825a3cf0421 (patch)
tree9e5c736cd7c7630d6a53f936ec67bcef18a1db00 /libgo/go
parent660e6c2c127fdec06bfa428b08ab4123e37281a5 (diff)
downloadgcc-350767bf22688f7645fe959370240825a3cf0421.zip
gcc-350767bf22688f7645fe959370240825a3cf0421.tar.gz
gcc-350767bf22688f7645fe959370240825a3cf0421.tar.bz2
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 From-SVN: r242509
Diffstat (limited to 'libgo/go')
-rw-r--r--libgo/go/runtime/debug.go17
-rw-r--r--libgo/go/runtime/error.go5
-rw-r--r--libgo/go/runtime/export_test.go28
-rw-r--r--libgo/go/runtime/extern.go4
-rw-r--r--libgo/go/runtime/stubs.go1
5 files changed, 23 insertions, 32 deletions
diff --git a/libgo/go/runtime/debug.go b/libgo/go/runtime/debug.go
index 56e307f..43f6e1e 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 3683001..d5d502c 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 d3443566..b8b129d 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 e0c5aac..c074687 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 d0641ed..8d90cd6 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()