This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Fwd: Got any 'fileno_unlocked'?
Rick Hanson wrote:
> Thanks for the tip. I already tried knocking off the '_unlocked'
> suffix. Although it does compile, I wonder what kind of runtime
> trouble I'm going to get into, since I did notice, by scanning the
> code, that the programmer locks his own file, then appeals to
> 'fileno_unlocked'. Also, there is no configure script to help.
I think you are misunderstanding the purpose of these functions.
It has nothing to do with file locking, but rather locking in the sense
of thread-safety. A programmer can call the _unlocked version of a
number of functions when he is sure that the application only has one
thread, and avoid a very slight penalty of having to set a mutex before
modifying the data structures.
Therefore, calling the standard version instead of the _unlocked version
is just skipping this optimization and should work in all cases. In
fact, if anything should be considered unsafe it is the _unlocked
function, which if used improperly will certainly cause harm, unlike the
standard functions.
Furthermore, these _unlocked functions are *not* standardized functions,
they are GNU extensions, and this means the programmer has made his code
unportable by assuming they exist without the aid of a configure test.
This is a bad thing to do.
Brian
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/