diff options
Diffstat (limited to 'libgo/runtime/runtime1.goc')
-rw-r--r-- | libgo/runtime/runtime1.goc | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/libgo/runtime/runtime1.goc b/libgo/runtime/runtime1.goc index 9ce83000b8..6d8f09a6c5 100644 --- a/libgo/runtime/runtime1.goc +++ b/libgo/runtime/runtime1.goc @@ -4,6 +4,8 @@ package runtime #include "runtime.h" +#include "arch.h" +#include "go-type.h" func GOMAXPROCS(n int) (ret int) { ret = runtime_gomaxprocsfunc(n); @@ -12,3 +14,76 @@ func GOMAXPROCS(n int) (ret int) { func NumCPU() (ret int) { ret = runtime_ncpu; } + +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--; +} + +func sync_atomic.runtime_procPin() (p int) { + M *mp; + + mp = runtime_m(); + // Disable preemption. + mp->locks++; + p = mp->p->id; +} + +func sync_atomic.runtime_procUnpin() { + runtime_m()->locks--; +} |