summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/plan9/mem.c
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-09-13 13:13:44 +0200
committerOndřej Surý <ondrej@sury.org>2011-09-13 13:13:44 +0200
commit9464a0c36318f8a801c07d6874bd0cea40f12504 (patch)
treef0178491c19d4f1ebc7b92eede86690998466480 /src/pkg/runtime/plan9/mem.c
parentba9fda6068cfadd42db0b152fdca7e8b67aaf77d (diff)
parent5ff4c17907d5b19510a62e08fd8d3b11e62b431d (diff)
downloadgolang-9464a0c36318f8a801c07d6874bd0cea40f12504.tar.gz
Merge commit 'upstream/60' into debian-sid
Diffstat (limited to 'src/pkg/runtime/plan9/mem.c')
-rw-r--r--src/pkg/runtime/plan9/mem.c11
1 files changed, 10 insertions, 1 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