delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/05/12/15:49:44

X-Spam-Check-By: sourceware.org
Message-ID: <4464E6D0.1C835CBC@dessent.net>
Date: Fri, 12 May 2006 12:49:36 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Fwd: Got any 'fileno_unlocked'?
References: <dff7d7110605120914s1f4229d6w77f8057ce7e2173f AT mail DOT gmail DOT com> <dff7d7110605120915p1fe3e0e6m5287dc30a13633a4 AT mail DOT gmail DOT com> <dff7d7110605121239y58fd3cfble9d3dcbcb589c45f AT mail DOT gmail DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019