diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libgo/runtime/chan.goc | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libgo/runtime/chan.goc')
-rw-r--r-- | libgo/runtime/chan.goc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/libgo/runtime/chan.goc b/libgo/runtime/chan.goc new file mode 100644 index 000000000..da0bbfccb --- /dev/null +++ b/libgo/runtime/chan.goc @@ -0,0 +1,39 @@ +// Copyright 2010 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. + +package runtime +#include "config.h" +#include "channel.h" + +typedef _Bool bool; +typedef unsigned char byte; +typedef struct __go_channel chan; + +/* Do a nonblocking channel receive. */ + +func chanrecv2(c *chan, val *byte) (pres bool) { + if (c->element_size > 8) { + return __go_receive_nonblocking_big(c, val); + } else { + struct __go_receive_nonblocking_small rs; + union { + char b[8]; + uint64_t v; + } u; + + rs = __go_receive_nonblocking_small (c); + if (!rs.__success) { + __builtin_memset(val, 0, c->element_size); + return 0; + } + u.v = rs.__val; +#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 1; + } +} |