aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime.c
diff options
context:
space:
mode:
authorKen Thompson <ken@golang.org>2008-11-13 10:35:44 -0800
committerKen Thompson <ken@golang.org>2008-11-13 10:35:44 -0800
commitbc0b4f0d2a610059afb95ef0360704714815187d (patch)
tree4d8297ca1915b56d9c7cf887ee6dd7e5bf09a2d6 /src/runtime/runtime.c
parentc4d8dc0b835dc307a14b8ef8867eef13139e23c8 (diff)
downloadgo-bc0b4f0d2a610059afb95ef0360704714815187d.tar.xz
mike's map code
R=r OCL=19146 CL=19146
Diffstat (limited to 'src/runtime/runtime.c')
-rw-r--r--src/runtime/runtime.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c
index c84b21092e..ea2c432396 100644
--- a/src/runtime/runtime.c
+++ b/src/runtime/runtime.c
@@ -87,6 +87,28 @@ mcpy(byte *t, byte *f, uint32 n)
}
}
+void
+mmov(byte *t, byte *f, uint32 n)
+{
+ if(t < f) {
+ while(n > 0) {
+ *t = *f;
+ t++;
+ f++;
+ n--;
+ }
+ } else {
+ t += n;
+ f += n;
+ while(n > 0) {
+ t--;
+ f--;
+ *t = *f;
+ n--;
+ }
+ }
+}
+
uint32
rnd(uint32 n, uint32 m)
{
@@ -582,9 +604,17 @@ check(void)
static uint64
memhash(uint32 s, void *a)
{
- USED(s, a);
- prints("memhash\n");
- return 0x12345;
+ byte *b;
+ uint64 hash;
+
+ b = a;
+ hash = 33054211828000289ULL;
+ while(s > 0) {
+ hash = (hash ^ *b) * 23344194077549503ULL;
+ b++;
+ s--;
+ }
+ return hash;
}
static uint32
@@ -644,9 +674,7 @@ memcopy(uint32 s, void *a, void *b)
static uint64
stringhash(uint32 s, string *a)
{
- USED(s, a);
- prints("stringhash\n");
- return 0x12345;
+ return memhash((*a)->len, (*a)->str);
}
static uint32
@@ -677,9 +705,7 @@ stringcopy(uint32 s, string *a, string *b)
static uint64
pointerhash(uint32 s, void **a)
{
- USED(s, a);
- prints("pointerhash\n");
- return 0x12345;
+ return memhash(s, *a);
}
static uint32