FreeBSD/sys/dev/hyperv/vmbus/hv_ring_buffer.c
/**
 * @brief Helper routine to copy from source to ring buffer.
 *
 * Assume there is enough room. Handles wrap-around in dest case only!
 */
@brief Helper routine to copy from source to ring buffer.
Assume there is enough room. Handles wrap-around in dest case only!
@brief Helper routine to copy from source to ring buffer . Assume there is enough room . Handles wrap - around in dest case only!
uint32_t
copy_to_ring_buffer(
	hv_vmbus_ring_buffer_info*	ring_info,
	uint32_t 			start_write_offset,
	char*				src,
	uint32_t			src_len)
{
	char *ring_buffer = get_ring_buffer(ring_info);
	uint32_t ring_buffer_size = get_ring_buffer_size(ring_info);
	uint32_t fragLen;
	if (src_len > ring_buffer_size - start_write_offset)  {
	    fragLen = ring_buffer_size - start_write_offset;
	    memcpy(ring_buffer + start_write_offset, src, fragLen);
	    memcpy(ring_buffer, src + fragLen, src_len - fragLen);
	} else {
	    memcpy(ring_buffer + start_write_offset, src, src_len);
	}
	start_write_offset += src_len;
	start_write_offset %= ring_buffer_size;
	return (start_write_offset);
}
uint32_t copy_to_ring_buffer ( hv_vmbus_ring_buffer_info * ring_info , uint32_t start_write_offset , char * src , uint32_t src_len ) { char * ring_buffer = get_ring_buffer ( ring_info ) ; uint32_t ring_buffer_size = get_ring_buffer_size ( ring_info ) ; uint32_t fragLen ; if ( src_len > ring_buffer_size - start_write_offset ) { fragLen = ring_buffer_size - start_write_offset ; memcpy ( ring_buffer + start_write_offset , src , fragLen ) ; memcpy ( ring_buffer , src + fragLen , src_len - fragLen ) ; } else { memcpy ( ring_buffer + start_write_offset , src , src_len ) ; } start_write_offset += src_len ; start_write_offset %= ring_buffer_size ; return ( start_write_offset ) ; }
@brief Helper routine to copy from source to ring buffer.
@brief Helper routine to copy from source to ring buffer .
/* wrap-around detected! */