FreeBSD/sys/dev/hyperv/vmbus/hv_ring_buffer.c
/**
 * @brief Read without advancing the read index.
 */
@brief Read without advancing the read index.
@brief Read without advancing the read index .
int
hv_ring_buffer_peek(
	hv_vmbus_ring_buffer_info*	in_ring_info,
	void*				buffer,
	uint32_t			buffer_len)
{
	uint32_t bytesAvailToWrite;
	uint32_t bytesAvailToRead;
	uint32_t nextReadLocation = 0;
	mtx_lock_spin(&in_ring_info->ring_lock);
	get_ring_buffer_avail_bytes(in_ring_info, &bytesAvailToRead,
		&bytesAvailToWrite);
	if (bytesAvailToRead < buffer_len) {
	    mtx_unlock_spin(&in_ring_info->ring_lock);
	    return (EAGAIN);
	}
	nextReadLocation = get_next_read_location(in_ring_info);
	nextReadLocation = copy_from_ring_buffer(
		in_ring_info, (char *)buffer, buffer_len, nextReadLocation);
	mtx_unlock_spin(&in_ring_info->ring_lock);
	return (0);
}
int hv_ring_buffer_peek ( hv_vmbus_ring_buffer_info * in_ring_info , void * buffer , uint32_t buffer_len ) { uint32_t bytesAvailToWrite ; uint32_t bytesAvailToRead ; uint32_t nextReadLocation = 0 ; mtx_lock_spin ( & in_ring_info -> ring_lock ) ; get_ring_buffer_avail_bytes ( in_ring_info , & bytesAvailToRead , & bytesAvailToWrite ) ; if ( bytesAvailToRead < buffer_len ) { mtx_unlock_spin ( & in_ring_info -> ring_lock ) ; return ( EAGAIN ) ; } nextReadLocation = get_next_read_location ( in_ring_info ) ; nextReadLocation = copy_from_ring_buffer ( in_ring_info , ( char * ) buffer , buffer_len , nextReadLocation ) ; mtx_unlock_spin ( & in_ring_info -> ring_lock ) ; return ( 0 ) ; }
@brief Read without advancing the read index.
@brief Read without advancing the read index .
/*
	 * Make sure there is something to read
	 */ /*
	 * Convert to byte offset
	 */