scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

fflush.c (265B)


      1 #include <stdio.h>
      2 
      3 #include "../libc.h"
      4 
      5 #undef fflush
      6 
      7 int
      8 fflush(FILE *fp)
      9 {
     10 	int err;
     11 
     12 	if (fp)
     13 		return _flsbuf(fp);
     14 
     15 	err = 0;
     16 	for (fp = __iob; fp < &__iob[FOPEN_MAX]; ++fp) {
     17 		if ((fp->flags & _IOWRITE) == 0 && _flsbuf(fp))
     18 			err = EOF;
     19 	}
     20 	return err;
     21 }