Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sun, 25 Sep 2016 01:49:38 +0200
From: Denys Vlasenko <>
To: musl <>
Subject: Re: Re: [PATCH] make fflush_unlocked(NULL) work

On Sun, Sep 18, 2016 at 10:36 PM, Rich Felker <> wrote:
> This patch introduces significant code duplication and complexity for
> the sake of saving something like 10 cycles in an operation that makes
> syscalls (i.e. takes thousands if not tens of thousands of cycles).

fflush(NULL) does not _always_ perform syscalls.
It may well find that none of the streams need any work.

In fact, in some applications it may end it not doing any writes
most of the times it is called: for example, I call it before (v)fork()
(unless I know that I for sure do not have any buffered writes).

Sometimes I call it before vfork out of sheer paranoia,
even if it "looks like it's not needed":
having stdio buffering in vfork-shared mm is huge PITA
and a source of nasty bugs. Been there.

> As
> mentioned on the bb list, the right fix is just making fflush_unlocked
> an alias for fflush. Then __fflush_unlocked can be eliminated
> completely and the file simplified rather than increased in
> complexity.

Your call.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.