diff options
| author | Ken Thompson <ken@golang.org> | 2008-11-05 21:50:28 -0800 |
|---|---|---|
| committer | Ken Thompson <ken@golang.org> | 2008-11-05 21:50:28 -0800 |
| commit | 79fbbe37a76502e6f5f9647d2d82bab953ab1546 (patch) | |
| tree | 9385ccda57027bd5d93f7709dfe95a71dcb11c20 /src/runtime | |
| parent | a6af48432819fcc6c963d1ac883aefe8cd6f7555 (diff) | |
| download | go-79fbbe37a76502e6f5f9647d2d82bab953ab1546.tar.xz | |
select default
R=r
OCL=18646
CL=18646
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/chan.c | 16 | ||||
| -rw-r--r-- | src/runtime/runtime.c | 5 | ||||
| -rw-r--r-- | src/runtime/runtime.h | 1 |
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 |
