aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorKen Thompson <ken@golang.org>2008-11-05 21:50:28 -0800
committerKen Thompson <ken@golang.org>2008-11-05 21:50:28 -0800
commit79fbbe37a76502e6f5f9647d2d82bab953ab1546 (patch)
tree9385ccda57027bd5d93f7709dfe95a71dcb11c20 /src/runtime
parenta6af48432819fcc6c963d1ac883aefe8cd6f7555 (diff)
downloadgo-79fbbe37a76502e6f5f9647d2d82bab953ab1546.tar.xz
select default
R=r OCL=18646 CL=18646
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/chan.c16
-rw-r--r--src/runtime/runtime.c5
-rw-r--r--src/runtime/runtime.h1
3 files changed, 12 insertions, 10 deletions
diff --git a/src/runtime/chan.c b/src/runtime/chan.c
index 3777190e29..c30cb07004 100644
--- a/src/runtime/chan.c
+++ b/src/runtime/chan.c
@@ -497,14 +497,14 @@ sys·selectrecv(Select *sel, Hchan *c, ...)
}
}
+
+// selectrecv(sel *byte) (selected bool);
void
-sys·selectdefault(Select *sel)
+sys·selectdefault(Select *sel, ...)
{
- int32 i, eo;
+ int32 i;
Scase *cas;
- Hchan *c;
- c = nil;
i = sel->ncase;
if(i >= sel->tcase)
throw("selectdefault: too many cases");
@@ -512,13 +512,11 @@ sys·selectdefault(Select *sel)
cas = &sel->scase[i];
cas->pc = sys·getcallerpc(&sel);
- cas->chan = c;
+ cas->chan = nil;
- eo = rnd(sizeof(sel), sizeof(c));
- eo = rnd(eo+sizeof(c), sizeof(byte*));
- cas->so = rnd(eo+sizeof(byte*), 1);
+ cas->so = rnd(sizeof(sel), 1);
cas->send = 2;
- cas->u.elemp = *(byte**)((byte*)&sel + eo);
+ cas->u.elemp = nil;
if(debug) {
prints("newselect s=");
diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c
index 5fde296700..db31b77df3 100644
--- a/src/runtime/runtime.c
+++ b/src/runtime/runtime.c
@@ -4,7 +4,8 @@
#include "runtime.h"
-int32 panicking = 0;
+int32 panicking = 0;
+int32 maxround = 8;
int32
gotraceback(void)
@@ -91,6 +92,8 @@ rnd(uint32 n, uint32 m)
{
uint32 r;
+ if(m > maxround)
+ m = maxround;
r = n % m;
if(r)
n += m-r;
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
index f182aebae7..30fa915b48 100644
--- a/src/runtime/runtime.h
+++ b/src/runtime/runtime.h
@@ -190,6 +190,7 @@ G* allg;
int32 goidgen;
extern int32 gomaxprocs;
extern int32 panicking;
+extern int32 maxround;
/*
* common functions and data