1 #include <inttypes.h> 2 #include <u.h> 3 #include <libc.h> 4 #include "fmtdef.h" 5 6 /* 7 * generic routine for flushing a formatting buffer 8 * to a file descriptor 9 */ 10 int __fmtFdFlush(Fmt * f)11__fmtFdFlush(Fmt *f) 12 { 13 int n; 14 15 n = (char*)f->to - (char*)f->start; 16 if(n && write((uintptr_t)f->farg, f->start, n) != n) 17 return 0; 18 f->to = f->start; 19 return 1; 20 } 21