summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-06-04 21:09:06 -0700
committerRuss Cox <rsc@golang.org>2009-06-04 21:09:06 -0700
commitb99f94c7b001c877c84917b6cabe48211114ef26 (patch)
tree9cb3038771ca4903a50485973e6e24a21280c73e /src/runtime
parent6ee0b38a258e8786ec720b339364082c159e50dd (diff)
downloadgolang-b99f94c7b001c877c84917b6cabe48211114ef26.tar.gz
386-related fixes and guards
R=r DELTA=44 (19 added, 1 deleted, 24 changed) OCL=29912 CL=29915
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/386/asm.s2
-rw-r--r--src/runtime/hashmap.h6
-rw-r--r--src/runtime/iface.c6
-rw-r--r--src/runtime/malloc.c11
-rw-r--r--src/runtime/runtime.c22
-rw-r--r--src/runtime/runtime.h8
6 files changed, 33 insertions, 22 deletions
diff --git a/src/runtime/386/asm.s b/src/runtime/386/asm.s
index cb6af7a15..5d3c4261a 100644
--- a/src/runtime/386/asm.s
+++ b/src/runtime/386/asm.s
@@ -116,7 +116,7 @@ TEXT gosave(SB), 7, $0
// save AX, jmp to lesstack to switch back
TEXT retfromnewstack(SB),7,$0
MOVL 4(FS), BX // m
- MOVL AX, 8(BX) // save AX in m->cret
+ MOVL AX, 12(BX) // save AX in m->cret
JMP lessstack(SB)
// gogo, returning 2nd arg instead of 1
diff --git a/src/runtime/hashmap.h b/src/runtime/hashmap.h
index 970e9e12e..ff93e9ee3 100644
--- a/src/runtime/hashmap.h
+++ b/src/runtime/hashmap.h
@@ -54,7 +54,7 @@
} else {
printf ("not found in table\n");
}
-
+
Example iteration over the elements of *h:
char **data;
struct hash_iter it;
@@ -76,7 +76,7 @@ struct hash; /* opaque */
struct hash_subtable; /* opaque */
struct hash_entry; /* opaque */
-typedef uint64 uintptr_t;
+typedef uintptr uintptr_t;
typedef uintptr_t hash_hash_t;
struct hash_iter {
@@ -96,7 +96,7 @@ struct hash_iter {
};
/* Return a hashtable h 2**init_power empty entries, each with
- "datasize" data bytes.
+ "datasize" data bytes.
(*data_hash)(a) should return the hash value of data element *a.
(*data_eq)(a,b) should return whether the data at "a" and the data at "b"
are equal.
diff --git a/src/runtime/iface.c b/src/runtime/iface.c
index 2351f422d..6c933b1b2 100644
--- a/src/runtime/iface.c
+++ b/src/runtime/iface.c
@@ -542,7 +542,7 @@ sys·ifaceE2I2(Sigi *si, Eface e, Iface ret, bool ok)
FLUSH(&ok);
}
-static uint64
+static uintptr
ifacehash1(void *data, Sigt *sigt)
{
int32 alg, wid;
@@ -565,7 +565,7 @@ ifacehash1(void *data, Sigt *sigt)
return algarray[alg].hash(wid, data);
}
-uint64
+uintptr
ifacehash(Iface a)
{
if(a.type == nil)
@@ -573,7 +573,7 @@ ifacehash(Iface a)
return ifacehash1(a.data, a.type->sigt);
}
-uint64
+uintptr
efacehash(Eface a)
{
return ifacehash1(a.data, a.type);
diff --git a/src/runtime/malloc.c b/src/runtime/malloc.c
index b33cc6fe2..81cdfb300 100644
--- a/src/runtime/malloc.c
+++ b/src/runtime/malloc.c
@@ -58,7 +58,10 @@ malloc(uintptr size)
}
// setup for mark sweep
- mlookup(v, nil, nil, &ref);
+ if(!mlookup(v, nil, nil, &ref)) {
+ printf("malloc %D; mlookup failed\n", (uint64)size);
+ throw("malloc mlookup");
+ }
*ref = RefNone;
m->mallocing = 0;
@@ -93,7 +96,8 @@ free(void *v)
throw("malloc/free - deadlock");
m->mallocing = 1;
- mlookup(v, nil, nil, &ref);
+ if(!mlookup(v, nil, nil, &ref))
+ throw("free mlookup");
*ref = RefFree;
// Find size class for v.
@@ -283,7 +287,8 @@ stackalloc(uint32 n)
return v;
}
v = malloc(n);
- mlookup(v, nil, nil, &ref);
+ if(!mlookup(v, nil, nil, &ref))
+ throw("stackalloc mlookup");
*ref = RefStack;
return v;
}
diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c
index fb9bf5cbc..c5ba3e6a5 100644
--- a/src/runtime/runtime.c
+++ b/src/runtime/runtime.c
@@ -267,16 +267,22 @@ check(void)
* map and chan helpers for
* dealing with unknown types
*/
-static uint64
+static uintptr
memhash(uint32 s, void *a)
{
byte *b;
- uint64 hash;
+ uintptr hash;
b = a;
- hash = 33054211828000289ULL;
+ if(sizeof(hash) == 4)
+ hash = 2860486313U;
+ else
+ hash = 33054211828000289ULL;
while(s > 0) {
- hash = (hash ^ *b) * 23344194077549503ULL;
+ if(sizeof(hash) == 4)
+ hash = (hash ^ *b) * 3267000013UL;
+ else
+ hash = (hash ^ *b) * 23344194077549503ULL;
b++;
s--;
}
@@ -337,7 +343,7 @@ memcopy(uint32 s, void *a, void *b)
ba[i] = bb[i];
}
-static uint64
+static uintptr
strhash(uint32 s, String *a)
{
USED(s);
@@ -358,7 +364,7 @@ strprint(uint32 s, String *a)
sys·printstring(*a);
}
-static uint64
+static uintptr
interhash(uint32 s, Iface *a)
{
USED(s);
@@ -379,7 +385,7 @@ interequal(uint32 s, Iface *a, Iface *b)
return ifaceeq(*a, *b);
}
-static uint64
+static uintptr
nilinterhash(uint32 s, Eface *a)
{
USED(s);
@@ -400,7 +406,7 @@ nilinterequal(uint32 s, Eface *a, Eface *b)
return efaceeq(*a, *b);
}
-uint64
+uintptr
nohash(uint32 s, void *a)
{
USED(s);
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
index 8c20c1d02..749364f95 100644
--- a/src/runtime/runtime.h
+++ b/src/runtime/runtime.h
@@ -194,7 +194,7 @@ struct Stktop
};
struct Alg
{
- uint64 (*hash)(uint32, void*);
+ uintptr (*hash)(uint32, void*);
uint32 (*equal)(uint32, void*, void*);
void (*print)(uint32, void*);
void (*copy)(uint32, void*, void*);
@@ -333,9 +333,9 @@ MCache* allocmcache(void);
void mallocinit(void);
bool ifaceeq(Iface, Iface);
bool efaceeq(Eface, Eface);
-uint64 ifacehash(Iface);
-uint64 efacehash(Eface);
-uint64 nohash(uint32, void*);
+uintptr ifacehash(Iface);
+uintptr efacehash(Eface);
+uintptr nohash(uint32, void*);
uint32 noequal(uint32, void*, void*);
void* malloc(uintptr size);
void* mallocgc(uintptr size);