]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: always initialise procid on netbsd
authorJoel Sing <jsing@google.com>
Wed, 30 May 2012 17:27:04 +0000 (03:27 +1000)
committerJoel Sing <jsing@google.com>
Wed, 30 May 2012 17:27:04 +0000 (03:27 +1000)
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

src/pkg/runtime/sys_netbsd_386.s
src/pkg/runtime/sys_netbsd_amd64.s
src/pkg/runtime/thread_netbsd.c

index 1c1254ddaf3a87754094f4bd02acd639665fb96c..d8b422ea2aa90d942c53036a7e755f5b578f4c81 100644 (file)
@@ -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
index d0543c92acd203d79a69a1ce779dde71b3856d8a..b13800c47e4d3a5cdece6cc911699ec06d20fac3 100644 (file)
@@ -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
index d87c6b003e73da4efad3ddc135c298712bcd58ad..be6c205c28110d7176846b2944e732b7c2bfb85a 100644 (file)
@@ -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);