Commit 2fa39ad8 by Ian Lance Taylor

runtime: Merge master revision 19185.

This revision renames several files in the runtime directory
from .c to .goc.

From-SVN: r212472
parent ca76ae5c
50c8fc924389
63484e8b6b76
The first line of this file holds the Mercurial revision number of the
last merge done from the master library sources.
......@@ -446,7 +446,6 @@ runtime_files = \
runtime/go-eface-compare.c \
runtime/go-eface-val-compare.c \
runtime/go-fieldtrack.c \
runtime/go-getgoroot.c \
runtime/go-int-array-to-string.c \
runtime/go-int-to-string.c \
runtime/go-interface-compare.c \
......@@ -487,16 +486,12 @@ runtime_files = \
runtime/go-type-interface.c \
runtime/go-type-string.c \
runtime/go-typedesc-equal.c \
runtime/go-typestring.c \
runtime/go-unsafe-new.c \
runtime/go-unsafe-newarray.c \
runtime/go-unsafe-pointer.c \
runtime/go-unwind.c \
runtime/go-varargs.c \
runtime/chan.c \
runtime/cpuprof.c \
runtime/env_posix.c \
runtime/lfstack.c \
$(runtime_lock_files) \
runtime/mcache.c \
runtime/mcentral.c \
......@@ -515,11 +510,15 @@ runtime_files = \
runtime/thread.c \
runtime/yield.c \
$(rtems_task_variable_add_file) \
chan.c \
cpuprof.c \
go-iface.c \
lfstack.c \
malloc.c \
map.c \
mprof.c \
netpoll.c \
rdebug.c \
reflect.c \
runtime1.c \
sema.c \
......
......@@ -29,11 +29,11 @@ type LFNode struct {
Pushcnt uintptr
}
func lfstackpush(head *uint64, node *LFNode)
func lfstackpop2(head *uint64) *LFNode
func lfstackpush_go(head *uint64, node *LFNode)
func lfstackpop_go(head *uint64) *LFNode
var LFStackPush = lfstackpush
var LFStackPop = lfstackpop2
var LFStackPush = lfstackpush_go
var LFStackPop = lfstackpop_go
type ParFor struct {
body *byte
......@@ -46,17 +46,17 @@ type ParFor struct {
wait bool
}
func parforalloc2(nthrmax uint32) *ParFor
func parforsetup2(desc *ParFor, nthr, n uint32, ctx *byte, wait bool, body func(*ParFor, uint32))
func parfordo(desc *ParFor)
func parforiters(desc *ParFor, tid uintptr) (uintptr, uintptr)
func newParFor(nthrmax uint32) *ParFor
func parForSetup(desc *ParFor, nthr, n uint32, ctx *byte, wait bool, body func(*ParFor, uint32))
func parForDo(desc *ParFor)
func parForIters(desc *ParFor, tid uintptr) (uintptr, uintptr)
var NewParFor = parforalloc2
var ParForSetup = parforsetup2
var ParForDo = parfordo
var NewParFor = newParFor
var ParForSetup = parForSetup
var ParForDo = parForDo
func ParForIters(desc *ParFor, tid uint32) (uint32, uint32) {
begin, end := parforiters(desc, uintptr(tid))
begin, end := parForIters(desc, uintptr(tid))
return uint32(begin), uint32(end)
}
......@@ -78,11 +78,13 @@ var TestSchedLocalQueueSteal1 = testSchedLocalQueueSteal
// var Int32Hash = int32Hash
// var Int64Hash = int64Hash
// func GogoBytes() int32
var hashLoad float64 // declared in hashmap.c
var HashLoad = &hashLoad
func memclrBytes(b []byte)
var MemclrBytes = memclrBytes
// func gogoBytes() int32
// var GogoBytes = gogoBytes
......@@ -280,31 +280,31 @@ func TestBlockProfile(t *testing.T) {
tests := [...]TestCase{
{"chan recv", blockChanRecv, `
[0-9]+ [0-9]+ @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+
# 0x[0-9,a-f]+ runtime\.chanrecv1\+0x[0-9,a-f]+ .*/src/pkg/runtime/chan.c:[0-9]+
# 0x[0-9,a-f]+ runtime\.chanrecv1\+0x[0-9,a-f]+ .*/src/pkg/runtime/chan.goc:[0-9]+
# 0x[0-9,a-f]+ runtime/pprof_test\.blockChanRecv\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
# 0x[0-9,a-f]+ runtime/pprof_test\.TestBlockProfile\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
`},
{"chan send", blockChanSend, `
[0-9]+ [0-9]+ @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+
# 0x[0-9,a-f]+ runtime\.chansend1\+0x[0-9,a-f]+ .*/src/pkg/runtime/chan.c:[0-9]+
# 0x[0-9,a-f]+ runtime\.chansend1\+0x[0-9,a-f]+ .*/src/pkg/runtime/chan.goc:[0-9]+
# 0x[0-9,a-f]+ runtime/pprof_test\.blockChanSend\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
# 0x[0-9,a-f]+ runtime/pprof_test\.TestBlockProfile\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
`},
{"chan close", blockChanClose, `
[0-9]+ [0-9]+ @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+
# 0x[0-9,a-f]+ runtime\.chanrecv1\+0x[0-9,a-f]+ .*/src/pkg/runtime/chan.c:[0-9]+
# 0x[0-9,a-f]+ runtime\.chanrecv1\+0x[0-9,a-f]+ .*/src/pkg/runtime/chan.goc:[0-9]+
# 0x[0-9,a-f]+ runtime/pprof_test\.blockChanClose\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
# 0x[0-9,a-f]+ runtime/pprof_test\.TestBlockProfile\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
`},
{"select recv async", blockSelectRecvAsync, `
[0-9]+ [0-9]+ @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+
# 0x[0-9,a-f]+ runtime\.selectgo\+0x[0-9,a-f]+ .*/src/pkg/runtime/chan.c:[0-9]+
# 0x[0-9,a-f]+ runtime\.selectgo\+0x[0-9,a-f]+ .*/src/pkg/runtime/chan.goc:[0-9]+
# 0x[0-9,a-f]+ runtime/pprof_test\.blockSelectRecvAsync\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
# 0x[0-9,a-f]+ runtime/pprof_test\.TestBlockProfile\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
`},
{"select send sync", blockSelectSendSync, `
[0-9]+ [0-9]+ @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+
# 0x[0-9,a-f]+ runtime\.selectgo\+0x[0-9,a-f]+ .*/src/pkg/runtime/chan.c:[0-9]+
# 0x[0-9,a-f]+ runtime\.selectgo\+0x[0-9,a-f]+ .*/src/pkg/runtime/chan.goc:[0-9]+
# 0x[0-9,a-f]+ runtime/pprof_test\.blockSelectSendSync\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
# 0x[0-9,a-f]+ runtime/pprof_test\.TestBlockProfile\+0x[0-9,a-f]+ .*/src/pkg/runtime/pprof/pprof_test.go:[0-9]+
`},
......
......@@ -163,7 +163,7 @@ done
done
done
runtime="chan.c cpuprof.c env_posix.c lock_futex.c lock_sema.c mcache.c mcentral.c mfixalloc.c mgc0.c mgc0.h mheap.c msize.c netpoll.goc netpoll_epoll.c netpoll_kqueue.c netpoll_stub.c panic.c print.c proc.c race.h runtime.c runtime.h signal_unix.c signal_unix.h malloc.h malloc.goc mprof.goc parfor.c runtime1.goc sema.goc sigqueue.goc string.goc time.goc"
runtime="chan.goc chan.h cpuprof.goc env_posix.c lock_futex.c lfstack.goc lock_sema.c mcache.c mcentral.c mfixalloc.c mgc0.c mgc0.h mheap.c msize.c netpoll.goc netpoll_epoll.c netpoll_kqueue.c netpoll_stub.c panic.c print.c proc.c race.h rdebug.goc runtime.c runtime.h signal_unix.c signal_unix.h malloc.h malloc.goc mprof.goc parfor.c runtime1.goc sema.goc sigqueue.goc string.goc time.goc"
for f in $runtime; do
merge_c $f $f
done
......
// Copyright 2009 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.
typedef struct WaitQ WaitQ;
typedef struct SudoG SudoG;
typedef struct Select Select;
typedef struct Scase Scase;
typedef struct __go_type_descriptor Type;
typedef struct __go_channel_type ChanType;
struct SudoG
{
G* g;
uint32* selectdone;
SudoG* link;
int64 releasetime;
byte* elem; // data element
};
struct WaitQ
{
SudoG* first;
SudoG* last;
};
// The garbage collector is assuming that Hchan can only contain pointers into the stack
// and cannot contain pointers into the heap.
struct Hchan
{
uintgo qcount; // total data in the q
uintgo dataqsiz; // size of the circular q
uint16 elemsize;
uint16 pad; // ensures proper alignment of the buffer that follows Hchan in memory
bool closed;
const Type* elemtype; // element type
uintgo sendx; // send index
uintgo recvx; // receive index
WaitQ recvq; // list of recv waiters
WaitQ sendq; // list of send waiters
Lock;
};
// Buffer follows Hchan immediately in memory.
// chanbuf(c, i) is pointer to the i'th slot in the buffer.
#define chanbuf(c, i) ((byte*)((c)+1)+(uintptr)(c)->elemsize*(i))
enum
{
debug = 0,
// Scase.kind
CaseRecv,
CaseSend,
CaseDefault,
};
struct Scase
{
SudoG sg; // must be first member (cast to Scase)
Hchan* chan; // chan
uint16 kind;
uint16 index; // index to return
bool* receivedp; // pointer to received bool (recv2)
};
struct Select
{
uint16 tcase; // total count of scase[]
uint16 ncase; // currently filled scase[]
uint16* pollorder; // case poll order
Hchan** lockorder; // channel lock order
Scase scase[1]; // one per case (in order of appearance)
};
......@@ -48,6 +48,7 @@
// in order to let the log closer set the high bit to indicate "EOF" safely
// in the situation when normally the goroutine "owns" handoff.
package runtime
#include "runtime.h"
#include "arch.h"
#include "malloc.h"
......@@ -435,13 +436,8 @@ breakflush:
return ret; // set to nil at top of function
}
extern Slice runtime_CPUProfile(void)
__asm__ (GOSYM_PREFIX "runtime.CPUProfile");
// CPUProfile returns the next cpu profile block as a []byte.
// The user documentation is in debug.go.
Slice
runtime_CPUProfile(void)
{
return getprofile(prof);
func CPUProfile() (ret Slice) {
ret = getprofile(prof);
}
......@@ -177,19 +177,3 @@ _cgo_panic (const char *p)
__go_panic (e);
}
/* Return the number of CGO calls. */
int64 runtime_NumCgoCall (void) __asm__ (GOSYM_PREFIX "runtime.NumCgoCall");
int64
runtime_NumCgoCall (void)
{
int64 ret;
M* m;
ret = 0;
for (m = runtime_atomicloadp (&runtime_allm); m != NULL; m = m->alllink)
ret += m->ncgocall;
return ret;
}
/* go-getgoroot.c -- getgoroot function for runtime package.
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. */
#include <stdlib.h>
#include "runtime.h"
String getgoroot (void) __asm__ (GOSYM_PREFIX "runtime.getgoroot");
String
getgoroot ()
{
const char *p;
String ret;
p = getenv ("GOROOT");
ret.str = (const byte *) p;
if (ret.str == NULL)
ret.len = 0;
else
ret.len = __builtin_strlen (p);
return ret;
}
/* go-typestring.c -- the runtime.typestring function.
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. */
#include "runtime.h"
#include "interface.h"
#include "go-type.h"
String typestring(struct __go_empty_interface) __asm__ (GOSYM_PREFIX "runtime.typestring");
String
typestring (struct __go_empty_interface e)
{
return *e.__type_descriptor->__reflection;
}
......@@ -617,9 +617,22 @@ process_file(void)
package = read_package();
read_preprocessor_lines();
while (read_func_header(&name, &params, &rets)) {
write_func_header(package, name, params, rets);
char *p;
char *pkg;
char *nm;
p = strchr(name, '.');
if (p == NULL) {
pkg = package;
nm = name;
} else {
pkg = name;
nm = p + 1;
*p = '\0';
}
write_func_header(pkg, nm, params, rets);
copy_body();
write_func_trailer(package, name, rets);
write_func_trailer(pkg, nm, rets);
free(name);
free_params(params);
free_params(rets);
......
......@@ -4,6 +4,7 @@
// Lock-free stack.
package runtime
#include "runtime.h"
#include "arch.h"
......@@ -69,11 +70,10 @@ runtime_lfstackpop(uint64 *head)
}
}
LFNode* runtime_lfstackpop2(uint64*)
__asm__ (GOSYM_PREFIX "runtime.lfstackpop2");
func lfstackpush_go(head *uint64, node *LFNode) {
runtime_lfstackpush(head, node);
}
LFNode*
runtime_lfstackpop2(uint64 *head)
{
return runtime_lfstackpop(head);
func lfstackpop_go(head *uint64) (node *LFNode) {
node = runtime_lfstackpop(head);
}
......@@ -905,10 +905,8 @@ runtime_mal(uintptr n)
return runtime_mallocgc(n, 0, 0);
}
void *
runtime_new(const Type *typ)
{
return runtime_mallocgc(typ->__size, (uintptr)typ | TypeInfo_SingleObject, typ->kind&KindNoPointers ? FlagNoScan : 0);
func new(typ *Type) (ret *uint8) {
ret = runtime_mallocgc(typ->__size, (uintptr)typ | TypeInfo_SingleObject, typ->kind&KindNoPointers ? FlagNoScan : 0);
}
static void*
......
......@@ -586,6 +586,7 @@ void runtime_gc_m_ptr(Eface*);
void runtime_gc_itab_ptr(Eface*);
void runtime_memorydump(void);
int32 runtime_setgcpercent(int32);
void runtime_proc_scan(struct Workbuf**, void (*)(struct Workbuf**, Obj));
void runtime_time_scan(struct Workbuf**, void (*)(struct Workbuf**, Obj));
......
......@@ -1174,6 +1174,7 @@ scanblock(Workbuf *wbuf, bool keepworking)
#endif
default:
runtime_printf("runtime: invalid GC instruction %p at %p\n", pc[0], pc);
runtime_throw("scanblock: invalid GC instruction");
return;
}
......@@ -2449,13 +2450,9 @@ runtime_debug_readGCStats(Slice *pauses)
pauses->__count = n+3;
}
intgo runtime_debug_setGCPercent(intgo)
__asm__("runtime_debug.setGCPercent");
intgo
runtime_debug_setGCPercent(intgo in)
{
intgo out;
int32
runtime_setgcpercent(int32 in) {
int32 out;
runtime_lock(&runtime_mheap);
if(gcpercent == GcpercentUnknown)
......
......@@ -33,18 +33,6 @@ runtime_parforalloc(uint32 nthrmax)
return desc;
}
// For testing from Go
// func parforalloc2(nthrmax uint32) *ParFor
ParFor *runtime_parforalloc2(uint32)
__asm__ (GOSYM_PREFIX "runtime.parforalloc2");
ParFor *
runtime_parforalloc2(uint32 nthrmax)
{
return runtime_parforalloc(nthrmax);
}
void
runtime_parforsetup(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool wait, void (*body)(ParFor*, uint32))
{
......@@ -78,18 +66,6 @@ runtime_parforsetup(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool wait, v
}
}
// For testing from Go
// func parforsetup2(desc *ParFor, nthr, n uint32, ctx *byte, wait bool, body func(*ParFor, uint32))
void runtime_parforsetup2(ParFor *, uint32, uint32, void *, bool, void *)
__asm__ (GOSYM_PREFIX "runtime.parforsetup2");
void
runtime_parforsetup2(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool wait, void *body)
{
runtime_parforsetup(desc, nthr, n, ctx, wait, *(void(**)(ParFor*, uint32))body);
}
void
runtime_parfordo(ParFor *desc)
{
......@@ -214,23 +190,10 @@ exit:
me->nsleep = 0;
}
// For testing from Go
// func parforiters(desc *ParFor, tid uintptr) (uintptr, uintptr)
struct parforiters_ret {
uintptr start;
uintptr end;
};
struct parforiters_ret runtime_parforiters(ParFor *, uintptr)
__asm__ (GOSYM_PREFIX "runtime.parforiters");
struct parforiters_ret
runtime_parforiters(ParFor *desc, uintptr tid)
// For testing from Go.
void
runtime_parforiters(ParFor *desc, uintptr tid, uintptr *start, uintptr *end)
{
struct parforiters_ret ret;
ret.start = (uint32)desc->thr[tid].pos;
ret.end = (uint32)(desc->thr[tid].pos>>32);
return ret;
*start = (uint32)desc->thr[tid].pos;
*end = (uint32)(desc->thr[tid].pos>>32);
}
......@@ -320,7 +320,7 @@ runtime_printhex(uint64 v)
void
runtime_printpointer(void *p)
{
runtime_printhex((uint64)(uintptr)p);
runtime_printhex((uintptr)p);
}
void
......
......@@ -2456,26 +2456,6 @@ runtime_lockedOSThread(void)
return g->lockedm != nil && m->lockedg != nil;
}
// for testing of callbacks
_Bool runtime_golockedOSThread(void)
__asm__ (GOSYM_PREFIX "runtime.golockedOSThread");
_Bool
runtime_golockedOSThread(void)
{
return runtime_lockedOSThread();
}
intgo runtime_NumGoroutine (void)
__asm__ (GOSYM_PREFIX "runtime.NumGoroutine");
intgo
runtime_NumGoroutine()
{
return runtime_gcount();
}
int32
runtime_gcount(void)
{
......@@ -3321,13 +3301,10 @@ runtime_testSchedLocalQueueSteal(void)
}
}
intgo runtime_debug_setMaxThreads(intgo)
__asm__(GOSYM_PREFIX "runtime_debug.setMaxThreads");
intgo
runtime_debug_setMaxThreads(intgo in)
int32
runtime_setmaxthreads(int32 in)
{
intgo out;
int32 out;
runtime_lock(&runtime_sched);
out = runtime_sched.maxmcount;
......@@ -3370,30 +3347,3 @@ runtime_gcwaiting(void)
{
return runtime_sched.gcwaiting;
}
// func runtime_procPin() int
intgo sync_runtime_procPin(void)
__asm__(GOSYM_PREFIX "sync.runtime_procPin");
intgo
sync_runtime_procPin()
{
M *mp;
mp = m;
// Disable preemption.
mp->locks++;
return mp->p->id;
}
// func runtime_procUnpin()
void sync_runtime_procUnpin(void)
__asm__ (GOSYM_PREFIX "sync.runtime_procUnpin");
void
sync_runtime_procUnpin(void)
{
m->locks--;
}
// Copyright 2013 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_debug
#include "runtime.h"
#include "arch.h"
#include "malloc.h"
func setMaxStack(in int) (out int) {
out = runtime_maxstacksize;
runtime_maxstacksize = in;
}
func setGCPercent(in int) (out int) {
out = runtime_setgcpercent(in);
}
func setMaxThreads(in int) (out int) {
out = runtime_setmaxthreads(in);
}
......@@ -9,7 +9,6 @@
#include "runtime.h"
#include "array.h"
#include "go-panic.h"
// The GOTRACEBACK environment variable controls the
// behavior of a Go program that is crashing and exiting.
......@@ -221,15 +220,6 @@ runtime_tickspersecond(void)
return res;
}
int64 runtime_pprof_runtime_cyclesPerSecond(void)
__asm__ (GOSYM_PREFIX "runtime_pprof.runtime_cyclesPerSecond");
int64
runtime_pprof_runtime_cyclesPerSecond(void)
{
return runtime_tickspersecond();
}
// Called to initialize a new m (including the bootstrap m).
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
void
......@@ -341,19 +331,6 @@ runtime_timediv(int64 v, int32 div, int32 *rem)
uintptr runtime_maxstacksize = 1<<20; // enough until runtime.main sets it for real
intgo runtime_debug_setMaxStack(intgo)
__asm__ (GOSYM_PREFIX "runtime_debug.setMaxStack");
intgo
runtime_debug_setMaxStack(intgo in)
{
intgo out;
out = runtime_maxstacksize;
runtime_maxstacksize = in;
return out;
}
void memclrBytes(Slice)
__asm__ (GOSYM_PREFIX "runtime.memclrBytes");
......
......@@ -455,7 +455,7 @@ extern bool runtime_precisestack;
#define nelem(x) (sizeof(x)/sizeof((x)[0]))
#define nil ((void*)0)
#define USED(v) ((void) v)
#define ROUND(x, n) (((x)+(n)-1)&~((n)-1)) /* all-caps to mark as macro: it evaluates n twice */
#define ROUND(x, n) (((x)+(n)-1)&~(uintptr)((n)-1)) /* all-caps to mark as macro: it evaluates n twice */
byte* runtime_startup_random_data;
uint32 runtime_startup_random_data_len;
......@@ -491,6 +491,7 @@ extern int8* runtime_goos;
extern int32 runtime_ncpu;
extern void (*runtime_sysargs)(int32, uint8**);
extern DebugVars runtime_debug;
extern uintptr runtime_maxstacksize;
/*
* common functions and data
......@@ -501,9 +502,6 @@ intgo runtime_findnull(const byte*);
intgo runtime_findnullw(const uint16*);
void runtime_dump(byte*, int32);
/*
* very low level c-called
*/
void runtime_gogo(G*);
struct __go_func_type;
void runtime_args(int32, byte**);
......@@ -618,6 +616,7 @@ void runtime_crash(void);
void runtime_parsedebugvars(void);
void _rt0_go(void);
void* runtime_funcdata(Func*, int32);
int32 runtime_setmaxthreads(int32);
void runtime_stoptheworld(void);
void runtime_starttheworld(void);
......@@ -690,7 +689,8 @@ LFNode* runtime_lfstackpop(uint64 *head);
*/
ParFor* runtime_parforalloc(uint32 nthrmax);
void runtime_parforsetup(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool wait, void (*body)(ParFor*, uint32));
void runtime_parfordo(ParFor *desc) __asm__ (GOSYM_PREFIX "runtime.parfordo");
void runtime_parfordo(ParFor *desc);
void runtime_parforiters(ParFor*, uintptr, uintptr*, uintptr*);
/*
* low level C-called
......@@ -762,6 +762,7 @@ void runtime_procyield(uint32);
void runtime_osyield(void);
void runtime_lockOSThread(void);
void runtime_unlockOSThread(void);
bool runtime_lockedOSThread(void);
bool runtime_showframe(String, bool);
void runtime_printcreatedby(G*);
......
......@@ -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,63 @@ 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--;
}
......@@ -73,13 +73,8 @@ runtime_gostringnocopy(const byte *str)
return s;
}
String runtime_cstringToGo(byte*)
__asm__ (GOSYM_PREFIX "runtime.cstringToGo");
String
runtime_cstringToGo(byte *str)
{
return runtime_gostringnocopy(str);
func cstringToGo(str *byte) (s String) {
s = runtime_gostringnocopy(str);
}
enum
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment