Пример #1
0
/*
 * ptr_ring API provides no way for producer to find out whether a given
 * buffer was consumed.  Our tests merely require that a successful get_buf
 * implies that add_inbuf succeed in the past, and that add_inbuf will succeed,
 * fake it accordingly.
 */
void *get_buf(unsigned *lenp, void **bufp)
{
	void *datap;

	if (tailcnt == headcnt || __ptr_ring_full(&array))
		datap = NULL;
	else {
		datap = "Buffer\n";
		++tailcnt;
	}

	return datap;
}
Пример #2
0
void poll_used(void)
{
	void *b;

	do {
		if (tailcnt == headcnt || __ptr_ring_full(&array)) {
			b = NULL;
			barrier();
		} else {
			b = "Buffer\n";
		}
	} while (!b);
}
Пример #3
0
bool used_empty()
{
	return (tailcnt == headcnt || __ptr_ring_full(&array));
}