setvbuf()

Earl H. Kinmonth ked at garnet.berkeley.edu
Thu Feb 16 05:11:06 AEST 1989


In profiling a program using setvbuf(), I observed an unusually high
time usage by read and write. After hours of diddling, I found that
setvbuf() for SCO Xenix has a different calling sequence from the
setvbuf() in BSD UNIX and in the C libraries for Turbo C and other
Misery Dos compilers.

The common sequence is

setvbuf(stream,buffer,type,size)

The SCO sequence is

setvbuf(stream,type,buffer,size)

Since there is no function prototype in <stdio.h>, the parameter
mismatch will not show up unless you check the return value. (I
wasn't.) Even if you do, its not very informative.

If you have programs from Misery Dos or BSD UNIX that use setvbuf(),
you should probably check for this problem. It only produces slower io
since the next action on the stream will cause buffering, but ....

RHETORICAL QUESTION: Is there any good explanation for this useless
kind of difference, or was some programmer cranked up on weed when
he/she/it did the SCO version?

LESS RHETORICAL QUESTION: Why no prototype?



More information about the Comp.unix.xenix mailing list