gcc/libgo/runtime/chan.goc
Ian Lance Taylor 7a9389330e Add Go frontend, libgo library, and Go testsuite.
gcc/:
	* gcc.c (default_compilers): Add entry for ".go".
	* common.opt: Add -static-libgo as a driver option.
	* doc/install.texi (Configuration): Mention libgo as an option for
	--enable-shared.  Mention go as an option for --enable-languages.
	* doc/invoke.texi (Overall Options): Mention .go as a file name
	suffix.  Mention go as a -x option.
	* doc/frontends.texi (G++ and GCC): Mention Go as a supported
	language.
	* doc/sourcebuild.texi (Top Level): Mention libgo.
	* doc/standards.texi (Standards): Add section on Go language.
	Move references for other languages into their own section.
	* doc/contrib.texi (Contributors): Mention that I contributed the
	Go frontend.
gcc/testsuite/:
	* lib/go.exp: New file.
	* lib/go-dg.exp: New file.
	* lib/go-torture.exp: New file.
	* lib/target-supports.exp (check_compile): Match // Go.

From-SVN: r167407
2010-12-03 04:34:57 +00:00

40 lines
890 B
Plaintext

// 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;
}
}