Example #1
0
File: io.c Project: CPFL/gxen
/**
 * Get the amount of buffer space available and enable notifications if needed.
 */
static inline int fast_get_buffer_space(struct libxenvchan *ctrl, size_t request)
{
	int ready = wr_ring_size(ctrl) - (wr_prod(ctrl) - wr_cons(ctrl));
	if (ready >= request)
		return ready;
	/* We plan to fill the buffer; please tell us when you've read it */
	request_notify(ctrl, VCHAN_NOTIFY_READ);
	/*
	 * If the reader moved wr_cons after our read but before request, we
	 * will not get notified even though the actual amount of buffer space
	 * is above request. Reread wr_cons to cover this case.
	 */
	return wr_ring_size(ctrl) - (wr_prod(ctrl) - wr_cons(ctrl));
}
Example #2
0
File: io.c Project: CPFL/gxen
int libxenvchan_buffer_space(struct libxenvchan *ctrl)
{
	/* Since this value is being used outside libxenvchan, request notification
	 * when it changes
	 */
	request_notify(ctrl, VCHAN_NOTIFY_READ);
	return wr_ring_size(ctrl) - (wr_prod(ctrl) - wr_cons(ctrl));
}
Example #3
0
/**
 * Get the amount of buffer space available, and do nothing
 * about notifications
 */
static inline int raw_get_buffer_space(struct libxenvchan *ctrl)
{
	uint32_t ready = wr_ring_size(ctrl) - (wr_prod(ctrl) - wr_cons(ctrl));
	if (ready > wr_ring_size(ctrl))
		/* We have no way to return errors.  Locking up the ring is
		 * better than the alternatives. */
		return 0;
	return ready;
}
Example #4
0
int libvchan_buffer_space(struct libvchan *ctrl)
{
    return wr_ring_size(ctrl) - (wr_prod(ctrl) - wr_cons(ctrl));
}