summaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-03-25 05:14:57 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-03-25 05:14:57 +0000
commit0dc2f918b17f3bf66aec64d8f9b0630f4677fbbb (patch)
treeace019ab5161d52cce663b4c7408d746727efc5c /libgo
parent7a20d8cd1e1f8916d3c3d9480482ed490f10b7ab (diff)
downloadgcc-0dc2f918b17f3bf66aec64d8f9b0630f4677fbbb.tar.gz
Remove closed function. Fix tuple receive in select.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171440 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r--libgo/Makefile.am1
-rw-r--r--libgo/Makefile.in21
-rw-r--r--libgo/runtime/chan.goc24
-rw-r--r--libgo/runtime/channel.h3
-rw-r--r--libgo/runtime/go-closed.c34
-rw-r--r--libgo/runtime/go-new-channel.c1
-rw-r--r--libgo/runtime/go-rec-nb-small.c1
-rw-r--r--libgo/runtime/go-rec-small.c1
8 files changed, 29 insertions, 57 deletions
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index 77bf27a7c53..e761e3c37d6 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -358,7 +358,6 @@ runtime_files = \
runtime/go-chan-len.c \
runtime/go-check-interface.c \
runtime/go-close.c \
- runtime/go-closed.c \
runtime/go-construct-map.c \
runtime/go-convert-interface.c \
runtime/go-copy.c \
diff --git a/libgo/Makefile.in b/libgo/Makefile.in
index dd942254dcb..5c2407bb027 100644
--- a/libgo/Makefile.in
+++ b/libgo/Makefile.in
@@ -174,11 +174,11 @@ am__libgo_la_SOURCES_DIST = runtime/go-append.c runtime/go-assert.c \
runtime/go-caller.c runtime/go-can-convert-interface.c \
runtime/go-cgo.c runtime/go-chan-cap.c runtime/go-chan-len.c \
runtime/go-check-interface.c runtime/go-close.c \
- runtime/go-closed.c runtime/go-construct-map.c \
- runtime/go-convert-interface.c runtime/go-copy.c \
- runtime/go-defer.c runtime/go-deferred-recover.c \
- runtime/go-eface-compare.c runtime/go-eface-val-compare.c \
- runtime/go-getgoroot.c runtime/go-go.c runtime/go-gomaxprocs.c \
+ runtime/go-construct-map.c runtime/go-convert-interface.c \
+ runtime/go-copy.c runtime/go-defer.c \
+ runtime/go-deferred-recover.c runtime/go-eface-compare.c \
+ runtime/go-eface-val-compare.c runtime/go-getgoroot.c \
+ runtime/go-go.c runtime/go-gomaxprocs.c \
runtime/go-int-array-to-string.c runtime/go-int-to-string.c \
runtime/go-interface-compare.c \
runtime/go-interface-eface-compare.c \
@@ -219,7 +219,7 @@ am__libgo_la_SOURCES_DIST = runtime/go-append.c runtime/go-assert.c \
am__objects_3 = go-append.lo go-assert.lo go-assert-interface.lo \
go-byte-array-to-string.lo go-breakpoint.lo go-caller.lo \
go-can-convert-interface.lo go-cgo.lo go-chan-cap.lo \
- go-chan-len.lo go-check-interface.lo go-close.lo go-closed.lo \
+ go-chan-len.lo go-check-interface.lo go-close.lo \
go-construct-map.lo go-convert-interface.lo go-copy.lo \
go-defer.lo go-deferred-recover.lo go-eface-compare.lo \
go-eface-val-compare.lo go-getgoroot.lo go-go.lo \
@@ -771,7 +771,6 @@ runtime_files = \
runtime/go-chan-len.c \
runtime/go-check-interface.c \
runtime/go-close.c \
- runtime/go-closed.c \
runtime/go-construct-map.c \
runtime/go-convert-interface.c \
runtime/go-copy.c \
@@ -2177,7 +2176,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-chan-len.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-check-interface.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-close.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-closed.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-construct-map.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-convert-interface.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-copy.Plo@am__quote@
@@ -2383,13 +2381,6 @@ go-close.lo: runtime/go-close.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o go-close.lo `test -f 'runtime/go-close.c' || echo '$(srcdir)/'`runtime/go-close.c
-go-closed.lo: runtime/go-closed.c
-@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT go-closed.lo -MD -MP -MF $(DEPDIR)/go-closed.Tpo -c -o go-closed.lo `test -f 'runtime/go-closed.c' || echo '$(srcdir)/'`runtime/go-closed.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/go-closed.Tpo $(DEPDIR)/go-closed.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='runtime/go-closed.c' object='go-closed.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o go-closed.lo `test -f 'runtime/go-closed.c' || echo '$(srcdir)/'`runtime/go-closed.c
-
go-construct-map.lo: runtime/go-construct-map.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT go-construct-map.lo -MD -MP -MF $(DEPDIR)/go-construct-map.Tpo -c -o go-construct-map.lo `test -f 'runtime/go-construct-map.c' || echo '$(srcdir)/'`runtime/go-construct-map.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/go-construct-map.Tpo $(DEPDIR)/go-construct-map.Plo
diff --git a/libgo/runtime/chan.goc b/libgo/runtime/chan.goc
index c9de71f8d5e..9326f2689ae 100644
--- a/libgo/runtime/chan.goc
+++ b/libgo/runtime/chan.goc
@@ -10,7 +10,7 @@ typedef _Bool bool;
typedef unsigned char byte;
typedef struct __go_channel chan;
-/* Do a nonblocking channel receive. */
+/* Do a channel receive with closed status. */
func chanrecv2(c *chan, val *byte) (received bool) {
if (c->element_size > 8) {
@@ -31,3 +31,25 @@ func chanrecv2(c *chan, val *byte) (received bool) {
return received;
}
}
+
+/* Do a channel receive with closed status for a select statement. */
+
+func chanrecv3(c *chan, val *byte) (received bool) {
+ if (c->element_size > 8) {
+ return __go_receive_big(c, val, 1);
+ } else {
+ union {
+ char b[8];
+ uint64_t v;
+ } u;
+
+ u.v = __go_receive_small_closed(c, 1, &received);
+#ifndef WORDS_BIGENDIAN
+ __builtin_memcpy(val, u.b, c->element_size);
+#else
+ __builtin_memcpy(val, u.b + 8 - c->element_size,
+ c->element_size);
+#endif
+ return received;
+ }
+}
diff --git a/libgo/runtime/channel.h b/libgo/runtime/channel.h
index 743af8bee9a..cd439bf4ccb 100644
--- a/libgo/runtime/channel.h
+++ b/libgo/runtime/channel.h
@@ -50,9 +50,6 @@ struct __go_channel
_Bool selected_for_receive;
/* True if this channel has been closed. */
_Bool is_closed;
- /* True if at least one null value has been read from a closed
- channel. */
- _Bool saw_close;
/* The list of select statements waiting to send on a synchronous
channel. */
struct __go_channel_select *select_send_queue;
diff --git a/libgo/runtime/go-closed.c b/libgo/runtime/go-closed.c
deleted file mode 100644
index bfa9cd6f9cc..00000000000
--- a/libgo/runtime/go-closed.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* go-closed.c -- the builtin closed function.
-
- Copyright 2009 The Go Authors. All rights reserved.
- Use of this source code is governed by a BSD-style
- license that can be found in the LICENSE file. */
-
-#include "go-assert.h"
-#include "channel.h"
-
-/* Return whether a channel is closed. We only return true after at
- least one nil value has been read from the channel. */
-
-_Bool
-__go_builtin_closed (struct __go_channel *channel)
-{
- int i;
- _Bool ret;
-
- i = pthread_mutex_lock (&channel->lock);
- __go_assert (i == 0);
-
- while (channel->selected_for_receive)
- {
- i = pthread_cond_wait (&channel->cond, &channel->lock);
- __go_assert (i == 0);
- }
-
- ret = channel->saw_close;
-
- i = pthread_mutex_unlock (&channel->lock);
- __go_assert (i == 0);
-
- return ret;
-}
diff --git a/libgo/runtime/go-new-channel.c b/libgo/runtime/go-new-channel.c
index d16bde62d75..3ddc205e05d 100644
--- a/libgo/runtime/go-new-channel.c
+++ b/libgo/runtime/go-new-channel.c
@@ -44,7 +44,6 @@ __go_new_channel (size_t element_size, size_t entries)
ret->selected_for_send = 0;
ret->selected_for_receive = 0;
ret->is_closed = 0;
- ret->saw_close = 0;
ret->select_send_queue = NULL;
ret->select_receive_queue = NULL;
ret->select_mutex = NULL;
diff --git a/libgo/runtime/go-rec-nb-small.c b/libgo/runtime/go-rec-nb-small.c
index d09901b0c88..29cad9af620 100644
--- a/libgo/runtime/go-rec-nb-small.c
+++ b/libgo/runtime/go-rec-nb-small.c
@@ -32,7 +32,6 @@ __go_receive_nonblocking_acquire (struct __go_channel *channel)
? channel->next_store == 0
: channel->next_fetch == channel->next_store))
{
- channel->saw_close = 1;
__go_unlock_and_notify_selects (channel);
return RECEIVE_NONBLOCKING_ACQUIRE_CLOSED;
}
diff --git a/libgo/runtime/go-rec-small.c b/libgo/runtime/go-rec-small.c
index ee85cde566b..019b20a456b 100644
--- a/libgo/runtime/go-rec-small.c
+++ b/libgo/runtime/go-rec-small.c
@@ -124,7 +124,6 @@ __go_receive_acquire (struct __go_channel *channel, _Bool for_select)
? channel->next_store == 0
: channel->next_fetch == channel->next_store))
{
- channel->saw_close = 1;
channel->selected_for_receive = 0;
__go_unlock_and_notify_selects (channel);
return 0;