diff options
Diffstat (limited to 'src/pkg/runtime/plan9')
-rw-r--r-- | src/pkg/runtime/plan9/386/defs.h | 1 | ||||
-rw-r--r-- | src/pkg/runtime/plan9/386/sys.s | 5 | ||||
-rw-r--r-- | src/pkg/runtime/plan9/mem.c | 29 |
3 files changed, 22 insertions, 13 deletions
diff --git a/src/pkg/runtime/plan9/386/defs.h b/src/pkg/runtime/plan9/386/defs.h index 5df757613..58fd9d94d 100644 --- a/src/pkg/runtime/plan9/386/defs.h +++ b/src/pkg/runtime/plan9/386/defs.h @@ -1 +1,2 @@ // nothing to see here +#define tos_pid 48 diff --git a/src/pkg/runtime/plan9/386/sys.s b/src/pkg/runtime/plan9/386/sys.s index 867b8940f..f760b782f 100644 --- a/src/pkg/runtime/plan9/386/sys.s +++ b/src/pkg/runtime/plan9/386/sys.s @@ -58,9 +58,10 @@ TEXT runtime·rfork(SB),7,$0 MOVL BX, m(AX) // Initialize AX from _tos->pid - MOVL 0xdfffeff8, AX + MOVL _tos(SB), AX + MOVL tos_pid(AX), AX MOVL AX, m_procid(BX) // save pid as m->procid - + CALL runtime·stackcheck(SB) // smashes AX, CX MOVL 0(DX), DX // paranoia; check they are not nil diff --git a/src/pkg/runtime/plan9/mem.c b/src/pkg/runtime/plan9/mem.c index 651e6728e..b840de984 100644 --- a/src/pkg/runtime/plan9/mem.c +++ b/src/pkg/runtime/plan9/mem.c @@ -10,40 +10,47 @@ static byte *bloc = { end }; enum { - Round = 7 + Round = 4095 }; void* -runtime·SysAlloc(uintptr ask) +runtime·SysAlloc(uintptr nbytes) { uintptr bl; // Plan 9 sbrk from /sys/src/libc/9sys/sbrk.c bl = ((uintptr)bloc + Round) & ~Round; - if(runtime·brk_((void*)(bl + ask)) < 0) + if(runtime·brk_((void*)(bl + nbytes)) < 0) return (void*)-1; - bloc = (byte*)bl + ask; + bloc = (byte*)bl + nbytes; return (void*)bl; } void -runtime·SysFree(void *v, uintptr n) +runtime·SysFree(void *v, uintptr nbytes) { // from tiny/mem.c // Push pointer back if this is a free // of the most recent SysAlloc. - n += (n + Round) & ~Round; - if(bloc == (byte*)v+n) - bloc -= n; + nbytes += (nbytes + Round) & ~Round; + if(bloc == (byte*)v+nbytes) + bloc -= nbytes; } void -runtime·SysUnused(void *v, uintptr n) +runtime·SysUnused(void *v, uintptr nbytes) { - USED(v, n); + USED(v, nbytes); } void -runtime·SysMemInit(void) +runtime·SysMap(void *v, uintptr nbytes) { + USED(v, nbytes); +} + +void* +runtime·SysReserve(void *v, uintptr nbytes) +{ + return runtime·SysAlloc(nbytes); } |