Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Oct 2002 13:41:56 -0500 (EST)
From:      Daniel Eischen <eischen@pcnet1.pcnet.com>
To:        Archie Cobbs <archie@dellroad.org>
Cc:        John Polstra <jdp@polstra.com>, current@FreeBSD.ORG, dfr@nlsystems.com
Subject:   Re: gnome on current
Message-ID:  <Pine.GSO.4.10.10210291333001.18141-100000@pcnet1.pcnet.com>
In-Reply-To: <200210291800.g9TI036f008080@arch20m.dellroad.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 29 Oct 2002, Archie Cobbs wrote:

> John Polstra writes:
> > > > I think it would work if the symbol were defined strongly in libc_r.
> > > 
> > > I think so too. I was trying to work out why this wasn't how things were
> > > done already. FWIW, linux's libpthread appears to be defining the
> > > pthread_* symbols strongly.
> > 
> > I think the weak symbols have something to do with support for thread
> > cancellation.  I didn't pay much attention at the time, so I don't
> > know the details.  Here's the relevant commit message, I think (this
> > one taken from lib/libc_r/uthread/uthread_pause.c):
> > 
> >   date: 2001/01/24 13:03:34;  author: deischen;  state: Exp;  lines: +4 -4
> >   Add weak definitions for wrapped system calls.  In general:
> > 
> > 	  _foo - wrapped system call
> > 	  foo - weak definition to _foo
> > 
> >   and for cancellation points:
> > 
> > 	  _foo - wrapped system call
> > 	  __foo - enter cancellation point, call _foo(), leave
> > 		  cancellation point
> > 	  foo - weak definition to __foo
> 
> To me it appears that weak symbols are not related to thread cancellation
> other than by coincidence. All this commit is saying is that the functionality
> of the libc_r version of "foo()" is split into two functions, one of
> which is a public entry point (__foo()) and the other of which is for
> internal use by libc_r (_foo()). The public entry point just calls the
> internal version after satisfying the requirement that the function
> be a cancellation point.
> 
> In other words, weak symbol are used for non-cancellation point functions
> as well, and are not required for implemention cancellation points.
> 
> It might have been slightly clearer if the _foo and __foo names had been
> reversed, so that "foo" always weakly referenced "_foo" whether or not
> the function was a cancellation point. But that would have probably
> caused a lot of changes in existing code (?).

Non-cancellation points are always single underscores so that
the implementation of libc can always use _foo and not care
about whether to use _foo() or __foo().  Libc should never
call functions that are cancellation points so it makes it
easier to just know that you should use the underscore version
of the system calls.  The same holds true when libc wants
to use pthread_* routines; it should only use the underscore
variants so that libc_r can tell the difference between the
implementation's locks and the application's locks.

-- 
Dan Eischen


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10210291333001.18141-100000>