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. */
12 __go_receive_nonblocking_big (struct __go_channel
* channel
, void *val
)
17 alloc_size
= ((channel
->element_size
+ sizeof (uint64_t) - 1)
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
)
28 /* Channel is closed. */
33 offset
= channel
->next_fetch
* alloc_size
;
34 __builtin_memcpy (val
, &channel
->data
[offset
], channel
->element_size
);
36 __go_receive_release (channel
);