summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/darwin
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-02-14 13:23:51 +0100
committerOndřej Surý <ondrej@sury.org>2011-02-14 13:23:51 +0100
commit758ff64c69e34965f8af5b2d6ffd65e8d7ab2150 (patch)
tree6d6b34f8c678862fe9b56c945a7b63f68502c245 /src/pkg/runtime/darwin
parent3e45412327a2654a77944249962b3652e6142299 (diff)
downloadgolang-upstream/2011-02-01.1.tar.gz
Imported Upstream version 2011-02-01.1upstream/2011-02-01.1
Diffstat (limited to 'src/pkg/runtime/darwin')
-rw-r--r--src/pkg/runtime/darwin/386/signal.c1
-rw-r--r--src/pkg/runtime/darwin/386/sys.s2
-rw-r--r--src/pkg/runtime/darwin/amd64/signal.c1
-rw-r--r--src/pkg/runtime/darwin/amd64/sys.s2
-rw-r--r--src/pkg/runtime/darwin/mem.c19
-rw-r--r--src/pkg/runtime/darwin/runtime_defs.go23
-rw-r--r--src/pkg/runtime/darwin/thread.c8
7 files changed, 24 insertions, 32 deletions
diff --git a/src/pkg/runtime/darwin/386/signal.c b/src/pkg/runtime/darwin/386/signal.c
index 53a4e2f17..33f47d44f 100644
--- a/src/pkg/runtime/darwin/386/signal.c
+++ b/src/pkg/runtime/darwin/386/signal.c
@@ -66,6 +66,7 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context)
gp->sig = sig;
gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr;
+ gp->sigpc = r->eip;
// Only push runtime·sigpanic if r->eip != 0.
// If r->eip == 0, probably panicked because of a
diff --git a/src/pkg/runtime/darwin/386/sys.s b/src/pkg/runtime/darwin/386/sys.s
index 79bbfb68b..7961e369c 100644
--- a/src/pkg/runtime/darwin/386/sys.s
+++ b/src/pkg/runtime/darwin/386/sys.s
@@ -138,7 +138,7 @@ TEXT runtime·bsdthread_create(SB),7,$32
MOVL $0x1000000, 20(SP) // flags = PTHREAD_START_CUSTOM
INT $0x80
JAE 3(PC)
- MOVL $-1, AX
+ NEGL AX
RET
MOVL $0, AX
RET
diff --git a/src/pkg/runtime/darwin/amd64/signal.c b/src/pkg/runtime/darwin/amd64/signal.c
index 474a1bd5c..948b6c9c2 100644
--- a/src/pkg/runtime/darwin/amd64/signal.c
+++ b/src/pkg/runtime/darwin/amd64/signal.c
@@ -76,6 +76,7 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context)
gp->sig = sig;
gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr;
+ gp->sigpc = r->rip;
// Only push runtime·sigpanic if r->rip != 0.
// If r->rip == 0, probably panicked because of a
diff --git a/src/pkg/runtime/darwin/amd64/sys.s b/src/pkg/runtime/darwin/amd64/sys.s
index 05dbc7b93..bc970156a 100644
--- a/src/pkg/runtime/darwin/amd64/sys.s
+++ b/src/pkg/runtime/darwin/amd64/sys.s
@@ -141,7 +141,7 @@ TEXT runtime·bsdthread_create(SB),7,$0
MOVQ $(0x2000000+360), AX // bsdthread_create
SYSCALL
JCC 3(PC)
- MOVL $-1, AX
+ NEGL AX
RET
MOVL $0, AX
RET
diff --git a/src/pkg/runtime/darwin/mem.c b/src/pkg/runtime/darwin/mem.c
index 7fb2c2807..cbae18718 100644
--- a/src/pkg/runtime/darwin/mem.c
+++ b/src/pkg/runtime/darwin/mem.c
@@ -10,10 +10,8 @@ runtime·SysAlloc(uintptr n)
mstats.sys += n;
v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
- if(v < (void*)4096) {
- runtime·printf("mmap: errno=%p\n", v);
- runtime·throw("mmap");
- }
+ if(v < (void*)4096)
+ return nil;
return v;
}
@@ -32,8 +30,19 @@ runtime·SysFree(void *v, uintptr n)
runtime·munmap(v, n);
}
+void*
+runtime·SysReserve(void *v, uintptr n)
+{
+ return runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
+}
void
-runtime·SysMemInit(void)
+runtime·SysMap(void *v, uintptr n)
{
+ void *p;
+
+ mstats.sys += n;
+ p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
+ if(p != v)
+ runtime·throw("runtime: cannot map pages in arena address space");
}
diff --git a/src/pkg/runtime/darwin/runtime_defs.go b/src/pkg/runtime/darwin/runtime_defs.go
deleted file mode 100644
index cf0b414a9..000000000
--- a/src/pkg/runtime/darwin/runtime_defs.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Go definitions of internal structures. Master is runtime.h
-
-package runtime
-
-type lock struct {
- key uint32
- sema uint32
-}
-
-type usema struct {
- u uint32
- k uint32
-}
-
-
-type note struct {
- wakeup int32
- sema usema
-}
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).