summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/darwin/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/darwin/thread.c')
-rw-r--r--src/pkg/runtime/darwin/thread.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pkg/runtime/darwin/thread.c b/src/pkg/runtime/darwin/thread.c
index d69c62412..57e813109 100644
--- a/src/pkg/runtime/darwin/thread.c
+++ b/src/pkg/runtime/darwin/thread.c
@@ -157,13 +157,17 @@ runtime·goenvs(void)
void
runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
{
+ int32 errno;
+
m->tls[0] = m->id; // so 386 asm can find it
if(0){
runtime·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);
}
- if(runtime·bsdthread_create(stk, m, g, fn) < 0)
- runtime·throw("cannot create new OS thread");
+ if((errno = runtime·bsdthread_create(stk, m, g, fn)) < 0) {
+ runtime·printf("runtime: failed to create new OS thread (have %d already; errno=%d)\n", runtime·mcount(), -errno);
+ runtime·throw("runtime.newosproc");
+ }
}
// Called to initialize a new m (including the bootstrap m).