void __go_send_small (struct __go_channel *channel, uint64_t val, _Bool for_select) { if (channel == NULL) __go_panic_msg ("send to nil channel"); __go_assert (channel->element_size <= sizeof (uint64_t)); __go_send_acquire (channel, for_select); channel->data[channel->next_store] = val; __go_send_release (channel); }
_Bool __go_send_nonblocking_small (struct __go_channel *channel, uint64_t val) { if (channel == NULL) return 0; __go_assert (channel->element_type->__size <= sizeof (uint64_t)); if (!__go_send_nonblocking_acquire (channel)) return 0; channel->data[channel->next_store] = val; __go_send_release (channel); return 1; }
void __go_send_small (struct __go_channel *channel, uint64_t val, _Bool for_select) { if (channel == NULL) { // Block forever. __go_select (0, 0, NULL, NULL); } __go_assert (channel->element_type->__size <= sizeof (uint64_t)); __go_send_acquire (channel, for_select); channel->data[channel->next_store] = val; __go_send_release (channel); }
void __go_send_big (struct __go_channel* channel, const void *val, _Bool for_select) { uintptr_t element_size; size_t alloc_size; size_t offset; if (channel == NULL) __go_panic_msg ("send to nil channel"); element_size = channel->element_type->__size; alloc_size = (element_size + sizeof (uint64_t) - 1) / sizeof (uint64_t); __go_send_acquire (channel, for_select); offset = channel->next_store * alloc_size; __builtin_memcpy (&channel->data[offset], val, element_size); __go_send_release (channel); }