shithub: scc

ref: 19f4d62e77c2b66116a48c6605f2cc9f239e53b0
dir: /src/libc/stdio/fflush.c/

View raw version
#include <stdio.h>

#include "../libc.h"

#undef fflush

int
fflush(FILE *fp)
{
	int err;

	if (fp)
		return _flsbuf(fp);

	err = 0;
	for (fp = __iob; fp < &__iob[FOPEN_MAX]; ++fp) {
		if ((fp->flags & _IOWRITE) == 0 && _flsbuf(fp))
			err = EOF;
	}
	return err;
}