2011-11-28 06:45:49 +01:00
|
|
|
// Copyright 2010 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package runtime
|
|
|
|
#include "runtime.h"
|
2014-07-12 02:01:09 +02:00
|
|
|
#include "arch.h"
|
|
|
|
#include "go-type.h"
|
2011-11-28 06:45:49 +01:00
|
|
|
|
2012-10-23 06:31:11 +02:00
|
|
|
func GOMAXPROCS(n int) (ret int) {
|
2011-11-28 06:45:49 +01:00
|
|
|
ret = runtime_gomaxprocsfunc(n);
|
|
|
|
}
|
2012-01-25 21:56:26 +01:00
|
|
|
|
2012-10-23 06:31:11 +02:00
|
|
|
func NumCPU() (ret int) {
|
2012-01-25 21:56:26 +01:00
|
|
|
ret = runtime_ncpu;
|
|
|
|
}
|
2014-07-12 02:01:09 +02:00
|
|
|
|
|
|
|
func NumCgoCall() (ret int64) {
|
|
|
|
M *mp;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
for(mp=runtime_atomicloadp(&runtime_allm); mp; mp=mp->alllink)
|
|
|
|
ret += mp->ncgocall;
|
|
|
|
}
|
|
|
|
|
|
|
|
func newParFor(nthrmax uint32) (desc *ParFor) {
|
|
|
|
desc = runtime_parforalloc(nthrmax);
|
|
|
|
}
|
|
|
|
|
|
|
|
func parForSetup(desc *ParFor, nthr uint32, n uint32, ctx *byte, wait bool, body *byte) {
|
|
|
|
runtime_parforsetup(desc, nthr, n, ctx, wait, *(void(**)(ParFor*, uint32))body);
|
|
|
|
}
|
|
|
|
|
|
|
|
func parForDo(desc *ParFor) {
|
|
|
|
runtime_parfordo(desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
func parForIters(desc *ParFor, tid uintptr) (start uintptr, end uintptr) {
|
|
|
|
runtime_parforiters(desc, tid, &start, &end);
|
|
|
|
}
|
|
|
|
|
|
|
|
func typestring(e Eface) (s String) {
|
|
|
|
s = *e.__type_descriptor->__reflection;
|
|
|
|
}
|
|
|
|
|
|
|
|
func golockedOSThread() (ret bool) {
|
|
|
|
ret = runtime_lockedOSThread();
|
|
|
|
}
|
|
|
|
|
|
|
|
func NumGoroutine() (ret int) {
|
|
|
|
ret = runtime_gcount();
|
|
|
|
}
|
|
|
|
|
|
|
|
func getgoroot() (out String) {
|
|
|
|
const byte *p;
|
|
|
|
|
|
|
|
p = runtime_getenv("GOROOT");
|
|
|
|
out = runtime_gostringnocopy(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
func runtime_pprof.runtime_cyclesPerSecond() (res int64) {
|
|
|
|
res = runtime_tickspersecond();
|
|
|
|
}
|
|
|
|
|
|
|
|
func sync.runtime_procPin() (p int) {
|
|
|
|
M *mp;
|
|
|
|
|
|
|
|
mp = runtime_m();
|
|
|
|
// Disable preemption.
|
|
|
|
mp->locks++;
|
|
|
|
p = mp->p->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
func sync.runtime_procUnpin() {
|
|
|
|
runtime_m()->locks--;
|
|
|
|
}
|