diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-08-03 17:26:15 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-08-03 17:31:49 +0200 |
commit | b757d264230d65f988e08158e096a09497d39eb4 (patch) | |
tree | e20ec608a2ec8ebf603fa7aa060eb9723c4780b9 /src/pkg/runtime/iface.c | |
parent | 5976088995f5c0d0bcada7d491fda4b6245e54e0 (diff) | |
download | golang-b757d264230d65f988e08158e096a09497d39eb4.tar.gz |
Imported Upstream version 2011.07.29
Diffstat (limited to 'src/pkg/runtime/iface.c')
-rw-r--r-- | src/pkg/runtime/iface.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/pkg/runtime/iface.c b/src/pkg/runtime/iface.c index b1015f695..000f834cf 100644 --- a/src/pkg/runtime/iface.c +++ b/src/pkg/runtime/iface.c @@ -81,7 +81,7 @@ itab(InterfaceType *inter, Type *type, int32 canfail) for(locked=0; locked<2; locked++) { if(locked) runtime·lock(&ifacelock); - for(m=hash[h]; m!=nil; m=m->link) { + for(m=runtime·atomicloadp(&hash[h]); m!=nil; m=m->link) { if(m->inter == inter && m->type == type) { if(m->bad) { m = nil; @@ -145,10 +145,11 @@ search: } out: + if(!locked) + runtime·panicstring("invalid itab locking"); m->link = hash[h]; - hash[h] = m; - if(locked) - runtime·unlock(&ifacelock); + runtime·atomicstorep(&hash[h], m); + runtime·unlock(&ifacelock); if(m->bad) return nil; return m; @@ -264,7 +265,7 @@ runtime·assertI2T2(Type *t, Iface i, ...) ret = (byte*)(&i+1); wid = t->size; - ok = (bool*)(ret+runtime·rnd(wid, 1)); + ok = (bool*)(ret + wid); if(i.tab == nil || i.tab->type != t) { *ok = false; @@ -326,7 +327,7 @@ runtime·assertE2T2(Type *t, Eface e, ...) runtime·throw("invalid interface value"); ret = (byte*)(&e+1); wid = t->size; - ok = (bool*)(ret+runtime·rnd(wid, 1)); + ok = (bool*)(ret + wid); if(t != e.type) { *ok = false; |