]> Cypherpunks repositories - gostls13.git/commitdiff
darwin: bsdthread_create can fail; print good error
authorRuss Cox <rsc@golang.org>
Thu, 29 Apr 2010 02:36:42 +0000 (19:36 -0700)
committerRuss Cox <rsc@golang.org>
Thu, 29 Apr 2010 02:36:42 +0000 (19:36 -0700)
Fixes #549.

R=adg
CC=golang-dev
https://golang.org/cl/1019042

src/pkg/runtime/darwin/386/sys.s
src/pkg/runtime/darwin/amd64/sys.s
src/pkg/runtime/darwin/os.h
src/pkg/runtime/darwin/thread.c

index 242800a5f5cec75597d1166482bce1b69b916aaf..f88f6b2468a8a1a0091f1fee90ef276261bdcb0c 100644 (file)
@@ -130,8 +130,10 @@ TEXT bsdthread_create(SB),7,$32
        MOVL    BX, 16(SP)      // pthread
        MOVL    $0x1000000, 20(SP)      // flags = PTHREAD_START_CUSTOM
        INT     $0x80
-       JAE     2(PC)
-       CALL    notok(SB)
+       JAE     3(PC)
+       MOVL    $-1, AX
+       RET
+       MOVL    $0, AX
        RET
 
 // The thread that bsdthread_create creates starts executing here,
index db922f7a0307014107d2a85bb095d9f0fbaf97b4..1654fa2b0ccf10726e4c23991ba9bbf5cadf3c3b 100644 (file)
@@ -116,8 +116,10 @@ TEXT bsdthread_create(SB),7,$0
        MOVQ    $0, R9  // paranoia
        MOVQ    $(0x2000000+360), AX    // bsdthread_create
        SYSCALL
-       JCC 2(PC)
-       CALL    notok(SB)
+       JCC 3(PC)
+       MOVL    $-1, AX
+       RET
+       MOVL    $0, AX
        RET
 
 // The thread that bsdthread_create creates starts executing here,
index 24496485c43da3e9ad09e0d686cecb705149446d..51a164c3391f924db0f670c50c60e78fe01e4cba 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-void   bsdthread_create(void*, M*, G*, void(*)(void));
+int32  bsdthread_create(void*, M*, G*, void(*)(void));
 void   bsdthread_register(void);
 int32  mach_msg_trap(MachHeader*, int32, uint32, uint32, uint32, uint32, uint32);
 uint32 mach_reply_port(void);
index d9acfa8d30697d17393051702207b814dca50cdd..e51d5301966763901619a5e5124d0051bfe56a1d 100644 (file)
@@ -157,7 +157,8 @@ newosproc(M *m, G *g, void *stk, void (*fn)(void))
                printf("newosproc stk=%p m=%p g=%p fn=%p id=%d/%d ostk=%p\n",
                        stk, m, g, fn, m->id, m->tls[0], &m);
        }
-       bsdthread_create(stk, m, g, fn);
+       if(bsdthread_create(stk, m, g, fn) < 0)
+               throw("cannot create new OS thread");
 }
 
 // Called to initialize a new m (including the bootstrap m).