From 594175d0b5e1c183b0d1642dabbc85437f07407b Mon Sep 17 00:00:00 2001 From: Ken Thompson Date: Sun, 13 Jul 2008 14:29:46 -0700 Subject: chan SVN=126958 --- src/runtime/runtime.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 145 insertions(+), 2 deletions(-) (limited to 'src/runtime/runtime.c') diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index f8dfa954cc..bc6c0ccb9d 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -64,6 +64,17 @@ mcpy(byte *t, byte *f, uint32 n) } } +uint32 +rnd(uint32 n, uint32 m) +{ + uint32 r; + + r = n % m; + if(r) + n += m-r; + return n; +} + static byte* brk(uint32 n) { @@ -81,7 +92,7 @@ mal(uint32 n) byte* v; // round to keep everything 64-bit aligned - n = (n+7) & ~7; + n = rnd(n, 8); nmal += n; // do we have enough in contiguous hunk @@ -469,7 +480,6 @@ static uint8** argv; static int32 envc; static uint8** envv; - void args(int32 c, uint8 **v) { @@ -797,3 +807,136 @@ sys·morestack(uint64 u) *(int32*)234 = 123; } + +/* + * map and chan helpers for + * dealing with unknown types + */ + +static uint64 +memhash(uint32 s, void *a) +{ + prints("memhash\n"); + return 0x12345; +} + +static uint32 +memequal(uint32 s, void *a, void *b) +{ + byte *ba, *bb; + uint32 i; + + ba = a; + bb = b; + for(i=0; i