" mspan struct{}; m struct{}; lock struct{}; slicetype struct{};" +
" iface struct{}; eface struct{}; interfacetype struct{}; itab struct{};" +
" mcache struct{}; bucket struct{}; sudog struct{}; g struct{};" +
+ " note struct{};" +
")"
f, err = parser.ParseFile(fset, filename, src, 0)
if err != nil {
var F64toint = f64toint
func entersyscall()
-func exitsyscall()
func golockedOSThread() bool
func stackguard() (sp, limit uintptr)
runtime·futexwakeup((uint32*)&n->key, 1);
}
+void
+runtime·notewakeup_m(void)
+{
+ Note *n;
+
+ n = g->m->ptrarg[0];
+ g->m->ptrarg[0] = nil;
+ runtime·notewakeup(n);
+}
+
void
runtime·notesleep(Note *n)
{
runtime·exitsyscall();
return res;
}
+
+void
+runtime·notetsleepg_m(void)
+{
+ Note *n;
+ int64 ns;
+
+ n = g->m->ptrarg[0];
+ g->m->ptrarg[0] = nil;
+ ns = g->m->scalararg[0] + ((int64)g->m->scalararg[1] << 32);
+
+ runtime·entersyscallblock_m(pc, sp);
+ notetsleep(n, ns, 0, 0);
+ // caller will call exitsyscall on g stack
+ runtime·gogo(&g->m->curg->sched);
+}
}
}
+void
+runtime·notewakeup_m(void)
+{
+ Note *n;
+
+ n = g->m->ptrarg[0];
+ g->m->ptrarg[0] = nil;
+ runtime·notewakeup(n);
+}
+
void
runtime·notesleep(Note *n)
{
runtime·exitsyscall();
return res;
}
+
+void
+runtime·notetsleepg_m(void)
+{
+ Note *n;
+ int64 ns;
+
+ n = g->m->ptrarg[0];
+ g->m->ptrarg[0] = nil;
+ ns = g->m->scalararg[0] + ((int64)g->m->scalararg[1] << 32);
+
+ if(g->m->waitsema == 0)
+ g->m->waitsema = runtime·semacreate();
+
+ runtime·entersyscallblock_m();
+ notetsleep(n, ns, 0, nil);
+ // caller will call exitsyscall on g stack
+ runtime·gogo(&g->m->curg->sched);
+}
g->m->locks--;
}
+// The same as runtime·entersyscallblock(), but called on g0 stack.
+void
+runtime·entersyscallblock_m(void)
+{
+ G *gp;
+
+ gp = g->m->curg;
+ // sched.{g,pc,sp,lr} are already set by mcall.
+ gp->stackguard0 = StackPreempt; // we are on g0, the goroutine must not touch its stack until exitsyscall
+ gp->sched.ret = 0;
+ gp->sched.ctxt = 0;
+ gp->syscallsp = gp->sched.sp;
+ gp->syscallpc = gp->sched.pc;
+ gp->syscallstack = gp->stackbase;
+ gp->syscallguard = gp->stackguard;
+ gp->status = Gsyscall;
+ if(gp->syscallsp < gp->syscallguard-StackGuard || gp->syscallstack < gp->syscallsp) {
+ // runtime·printf("entersyscall inconsistent %p [%p,%p]\n",
+ // gp->syscallsp, gp->syscallguard-StackGuard, gp->syscallstack);
+ runtime·throw("entersyscall_m");
+ }
+
+ handoffp(releasep());
+}
+
// The goroutine g exited its system call.
// Arrange for it to run on a cpu again.
// This is called only from the go syscall library, not
void runtime·entersyscall(void);
void runtime·entersyscallblock(void);
void runtime·exitsyscall(void);
+void runtime·entersyscallblock_m(void);
G* runtime·newproc1(FuncVal*, byte*, int32, int32, void*);
bool runtime·sigsend(int32 sig);
int32 runtime·callers(int32, uintptr*, int32);
gosched_m,
ready_m,
park_m,
- blockevent_m mFunction
+ blockevent_m,
+ notewakeup_m,
+ notetsleepg_m mFunction
)
// memclr clears n bytes starting at ptr.
func gopersistentalloc(n uintptr) unsafe.Pointer
func gocputicks() int64
+
+func gonoteclear(n *note) {
+ n.key = 0
+}
+
+func gonotewakeup(n *note) {
+ mp := acquirem()
+ mp.ptrarg[0] = unsafe.Pointer(n)
+ onM(¬ewakeup_m)
+ releasem(mp)
+}
+
+func gonotetsleepg(n *note, t int64) {
+ mp := acquirem()
+ mp.ptrarg[0] = unsafe.Pointer(n)
+ mp.scalararg[0] = uint(uint32(t)) // low 32 bits
+ mp.scalararg[1] = uint(t >> 32) // high 32 bits
+ releasem(mp)
+ mcall(¬etsleepg_m)
+ exitsyscall()
+}
+
+func exitsyscall()