Commit deb93b0f authored by Joel Sing's avatar Joel Sing

runtime: always initialise procid on netbsd

The correct procid is needed for unparking LWPs on NetBSD - always
initialise procid in minit() so that cgo works correctly. The non-cgo
case already works correctly since procid is initialised via
lwp_create().

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6257071
parent 334bf95f
......@@ -292,6 +292,11 @@ TEXT runtime·lwp_unpark(SB),7,$-4
INT $0x80
RET
TEXT runtime·lwp_self(SB),7,$-4
MOVL $311, AX // sys__lwp_self
INT $0x80
RET
TEXT runtime·sysctl(SB),7,$28
LEAL arg0+0(FP), SI
LEAL 4(SP), DI
......
......@@ -61,6 +61,11 @@ TEXT runtime·lwp_unpark(SB),7,$0
SYSCALL
RET
TEXT runtime·lwp_self(SB),7,$0
MOVL $311, AX // sys__lwp_self
SYSCALL
RET
// Exit the entire program (like C exit)
TEXT runtime·exit(SB),7,$-8
MOVL 8(SP), DI // arg 1 - exit status
......
......@@ -28,6 +28,7 @@ extern int32 runtime·lwp_create(UcontextT *context, uintptr flags, void *lwpid)
extern void runtime·lwp_mcontext_init(void *mc, void *stack, M *m, G *g, void (*fn)(void));
extern int32 runtime·lwp_park(Timespec *abstime, int32 unpark, void *hint, void *unparkhint);
extern int32 runtime·lwp_unpark(int32 lwp, void *hint);
extern int32 runtime·lwp_self(void);
// From NetBSD's <sys/sysctl.h>
#define CTL_HW 6
......@@ -181,9 +182,6 @@ void
runtime·osinit(void)
{
runtime·ncpu = getncpu();
// Main thread is always LWP 1.
m->procid = 1;
}
void
......@@ -196,6 +194,8 @@ runtime·goenvs(void)
void
runtime·minit(void)
{
m->procid = runtime·lwp_self();
// Initialize signal handling
m->gsignal = runtime·malg(32*1024);
runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
......
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