[haiku-commits] Re: r37323 - in haiku/trunk: build/jam headers/os/locale src/kits/locale src/preferences/locale

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 02 Jul 2010 02:02:56 +0200

On 2010-07-01 at 15:58:37 [+0200], PulkoMandy <pulkomandy@xxxxxxxxxxxxxxxxx> 
wrote:
> 2010/7/1 Ingo Weinhold <ingo_weinhold@xxxxxx>
> 
> > Why the extra class? The GetCatalog() method could just as well be member
> > of
> > BLocaleRoster, which would also allow to make the conceptually private
> > BLocaleRoster::GetCatalog(BCatalog*, vint32*) actually private. I would
> > rather just make sCatalog a static variable in the source file (i.e. not a
> > member) -- no need for anyone to see it.
> >
> 
> The goal was to have a shared object-local storage, and for that I need to
> link this class statically into every shared object needing localization. It
> is built as a separate library named liblocalestub.a and linked in each
> shared object. Is there another way to do that ?

Well, the class is not needed. Just put the method and variables in a 
separate source file and build the static library from it.

> Having the catalog and the
> InitOnce flag living outside of any class is possible, but I don't see what
> more it gives us.

It makes the symbols for the variables invisible without any additional magic.

> > And finally, the GetCatalog() method should have hidden visibility, so 
> > that
> > it is not possible to accidentally forget to link against the static
> > library.
> > Unfortunately gcc 2 doesn't support the visibility function attribute, so
> > this has to be done via inline assembly. Have a look at the
> > HIDDEN_FUNCTION()
> > macro in src/libs/posix_error_mapper/posix_error_mapper.h. Must be given
> > the
> > mangle function name.
> 
> I don't know much about assembly tricks :)
> However, if the lib is missing the binaries will not link already, because
> every call to B_TRANSLATE will try to call this GetCatalog method and find
> that it's missing.

The thing is that the static library will be linked into libbe. If you don't 
hide the GetCatalog() symbol, any library that links against libbe will link 
just fine, even when you forget to link against the static library. It will 
just use the symbol from libbe (and thus the wrong catalog).

CU, Ingo

Other related posts: