re PR lto/48086 (bootstrap-lto creates c-common.s with too many sections on x86_64...
[official-gcc.git] / libgo / runtime / go-rec-nb-big.c
blob53ffe48ab97d69d3023c4e7b1ef5962036ca75c9
1 /* go-rec-nb-big.c -- nonblocking receive of something big on a channel.
3 Copyright 2009 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
7 #include <stdint.h>
9 #include "channel.h"
11 _Bool
12 __go_receive_nonblocking_big (struct __go_channel* channel, void *val)
14 size_t alloc_size;
15 size_t offset;
17 alloc_size = ((channel->element_size + sizeof (uint64_t) - 1)
18 / sizeof (uint64_t));
20 int data = __go_receive_nonblocking_acquire (channel);
21 if (data != RECEIVE_NONBLOCKING_ACQUIRE_DATA)
23 __builtin_memset (val, 0, channel->element_size);
24 if (data == RECEIVE_NONBLOCKING_ACQUIRE_NODATA)
25 return 0;
26 else
28 /* Channel is closed. */
29 return 1;
33 offset = channel->next_fetch * alloc_size;
34 __builtin_memcpy (val, &channel->data[offset], channel->element_size);
36 __go_receive_release (channel);
38 return 1;