summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/plan9
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/plan9')
-rw-r--r--src/pkg/runtime/plan9/mem.c11
-rw-r--r--src/pkg/runtime/plan9/thread.c15
2 files changed, 23 insertions, 3 deletions
diff --git a/src/pkg/runtime/plan9/mem.c b/src/pkg/runtime/plan9/mem.c
index 9dfdf2cc3..f795b2c01 100644
--- a/src/pkg/runtime/plan9/mem.c
+++ b/src/pkg/runtime/plan9/mem.c
@@ -8,6 +8,7 @@
extern byte end[];
static byte *bloc = { end };
+static Lock memlock;
enum
{
@@ -19,23 +20,31 @@ runtime·SysAlloc(uintptr nbytes)
{
uintptr bl;
+ runtime·lock(&memlock);
+ mstats.sys += nbytes;
// Plan 9 sbrk from /sys/src/libc/9sys/sbrk.c
bl = ((uintptr)bloc + Round) & ~Round;
- if(runtime·brk_((void*)(bl + nbytes)) < 0)
+ if(runtime·brk_((void*)(bl + nbytes)) < 0) {
+ runtime·unlock(&memlock);
return (void*)-1;
+ }
bloc = (byte*)bl + nbytes;
+ runtime·unlock(&memlock);
return (void*)bl;
}
void
runtime·SysFree(void *v, uintptr nbytes)
{
+ runtime·lock(&memlock);
+ mstats.sys -= nbytes;
// from tiny/mem.c
// Push pointer back if this is a free
// of the most recent SysAlloc.
nbytes += (nbytes + Round) & ~Round;
if(bloc == (byte*)v+nbytes)
bloc -= nbytes;
+ runtime·unlock(&memlock);
}
void
diff --git a/src/pkg/runtime/plan9/thread.c b/src/pkg/runtime/plan9/thread.c
index ef9a23e8e..b091c5978 100644
--- a/src/pkg/runtime/plan9/thread.c
+++ b/src/pkg/runtime/plan9/thread.c
@@ -47,11 +47,11 @@ runtime·exit(int32)
pid = pid/10;
}
p = buf;
- runtime·mcpy((void*)p, (void*)"/proc/", 6);
+ runtime·memmove((void*)p, (void*)"/proc/", 6);
p += 6;
for(q--; q >= tmp;)
*p++ = *q--;
- runtime·mcpy((void*)p, (void*)"/notepg", 7);
+ runtime·memmove((void*)p, (void*)"/notepg", 7);
/* post interrupt note */
fd = runtime·open(buf, OWRITE);
@@ -167,3 +167,14 @@ os·sigpipe(void)
{
runtime·throw("too many writes on closed pipe");
}
+
+/*
+ * placeholder - once notes are implemented,
+ * a signal generating a panic must appear as
+ * a call to this function for correct handling by
+ * traceback.
+ */
+void
+runtime·sigpanic(void)
+{
+}