diff options
Diffstat (limited to 'src/pkg/runtime')
-rw-r--r-- | src/pkg/runtime/chan.c | 18 | ||||
-rw-r--r-- | src/pkg/runtime/reflect.cgo | 8 | ||||
-rw-r--r-- | src/pkg/runtime/runtime.h | 4 |
3 files changed, 25 insertions, 5 deletions
diff --git a/src/pkg/runtime/chan.c b/src/pkg/runtime/chan.c index ceebebf8b..00d020749 100644 --- a/src/pkg/runtime/chan.c +++ b/src/pkg/runtime/chan.c @@ -905,14 +905,24 @@ sys·closechan(Hchan *c) unlock(&chanlock); } +void +chanclose(Hchan *c) +{ + sys·closechan(c); +} + +bool +chanclosed(Hchan *c) +{ + return (c->closed & Rclosed) != 0; +} + + // closedchan(sel *byte) bool; void sys·closedchan(Hchan *c, bool closed) { - // test Rclosed - closed = 0; - if(c->closed & Rclosed) - closed = 1; + closed = chanclosed(c); FLUSH(&closed); } diff --git a/src/pkg/runtime/reflect.cgo b/src/pkg/runtime/reflect.cgo index 016b9e9ec..81c1d4a12 100644 --- a/src/pkg/runtime/reflect.cgo +++ b/src/pkg/runtime/reflect.cgo @@ -78,6 +78,14 @@ func chanrecv(ch *byte, val *byte, pres *bool) { chanrecv((Hchan*)ch, val, pres); } +func chanclose(ch *byte) { + chanclose((Hchan*)ch); +} + +func chanclosed(ch *byte) (r bool) { + r = chanclosed((Hchan*)ch); +} + /* * Go wrappers around the functions in iface.c diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h index c346c692f..1e89a4578 100644 --- a/src/pkg/runtime/runtime.h +++ b/src/pkg/runtime/runtime.h @@ -73,7 +73,7 @@ typedef struct Hchan Hchan; * amd64: allocated downwards from R15 * x86: allocated upwards from 0(FS) * arm: allocated upwards from R9 - * + * * every C file linked into a Go program must include runtime.h * so that the C compiler knows to avoid other uses of these registers. * the Go compilers know to avoid them. @@ -491,5 +491,7 @@ Hmap* makemap(uint32, uint32, uint32, uint32, uint32); Hchan* makechan(uint32, uint32, uint32); void chansend(Hchan*, void*, bool*); void chanrecv(Hchan*, void*, bool*); +void chanclose(Hchan*); +bool chanclosed(Hchan*); void ifaceE2I(struct InterfaceType*, Eface, Iface*); |