[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] fflush() implementation

From: Philipp Schafft
Subject: Re: [avr-libc-dev] fflush() implementation
Date: Sat, 25 Aug 2012 20:30:03 +0200


On Fri, 2012-08-24 at 21:55 +0200, Daniel Otte wrote:
> Hi,
> the current state of fflush() according to stdio.h is:
>    Flush \c stream.
>    This is a null operation provided for source-code compatibility
>    only, as the standard IO implementation currently does not perform
>    any buffering.
> This is ok for the stream implementation itself if it is not buffering, but if
> the device driver which forms the base of the stream performs buffering it may
> be would like to be informed if fflush() is called to flush its own buffers.

Please note that fflush() doesn't do that on any system. It only flushes
the buffers within the FILE* object.

For example from fflush(3) (note the *3* here) of my system:
        Note  that  fflush()  only  flushes the user space buffers
        provided by the C library.  To ensure that the data is
        physically stored on disk the kernel buffers must be flushed
        too, e.g. with sync(2) or fsync(2).

If the stdio support (the 'user space' part in the text above) does not
buffer fflush() should just do nothing.

Still it could be considered adding a new function similar to fsync() or
fdatasync() to allow flushing data in the driver.

Note: I very welcome that the function exists as noop which helps

Wish a nice weekend!

 (Rah of PH2)

Attachment: signature.asc
Description: This is a digitally signed message part

reply via email to

[Prev in Thread] Current Thread [Next in Thread]