thread safety level of fwide
Alexandre Oliva
aoliva@redhat.com
Fri Nov 21 14:05:00 GMT 2014
On Nov 21, 2014, Rich Felker <dalias@libc.org> wrote:
> As a function that operates on a FILE, fwide is required by POSIX to
> behave as if it acquires the internal recursive mutex on the target
> file.
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/flockfile.html
Interesting... This indeed appears to rule out the optimization of
testing for safe values instead of taking a lock. It's not like we can
just assume unordered access is acceptable: flockfile/funlockfile does
force a global total order, and (as you said) they bring memory acquire
and release with them.
This means we have a bug in at least fwide and fileno.
I wonder if addmntent is also covered by this requirement: with the
current implementation, it takes and releases the stream's lock twice.
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
More information about the Libc-alpha
mailing list