/** * Get the amount of buffer space available and enable notifications if needed. */ static inline int fast_get_data_ready(struct libxenvchan *ctrl, size_t request) { int ready = rd_prod(ctrl) - rd_cons(ctrl); if (ready >= request) return ready; /* We plan to consume all data; please tell us if you send more */ request_notify(ctrl, VCHAN_NOTIFY_WRITE); /* * If the writer moved rd_prod after our read but before request, we * will not get notified even though the actual amount of data ready is * above request. Reread rd_prod to cover this case. */ return rd_prod(ctrl) - rd_cons(ctrl); }
int libxenvchan_data_ready(struct libxenvchan *ctrl) { /* Since this value is being used outside libxenvchan, request notification * when it changes */ request_notify(ctrl, VCHAN_NOTIFY_WRITE); return rd_prod(ctrl) - rd_cons(ctrl); }
/* * Get the amount of buffer space available, and do nothing about * notifications. */ static inline int raw_get_data_ready(struct libxenvchan *ctrl) { uint32_t ready = rd_prod(ctrl) - rd_cons(ctrl); if (ready >= rd_ring_size(ctrl)) /* We have no way to return errors. Locking up the ring is * better than the alternatives. */ return 0; return ready; }
int libvchan_data_ready(struct libvchan *ctrl) { return rd_prod(ctrl) - rd_cons(ctrl); }