shithub: riscv

ref: 6d4261baabfece44dea8033b9d5a9d90978f8477
dir: /sys/src/libbio/bbuffered.c/

View raw version
#include	<u.h>
#include	<libc.h>
#include	<bio.h>

int
Bbuffered(Biobufhdr *bp)
{
	switch(bp->state) {
	case Bracteof:
	case Bractive:
		return -bp->icount;

	case Bwactive:
		return bp->bsize + bp->ocount;

	case Binactive:
		return 0;
	}
	fprint(2, "Bbuffered: unknown state %d\n", bp->state);
	return 0;
}