[openbeos] Re: PPC versions

  • From: François Revol <revol@xxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Mon, 08 Apr 2002 21:31:14 +0200 (MEST)

You need to separate the use of underscore in some object formats (COFF or 
Amiga) which is mandatory, and the use of one or more underscores to avoid 
name collision. The later isn't a rule, just a convention, and it's also 
used in libraries as well. 
on Amiga for inst. the program real entry point is _main, which calls __main,
which in turn calls main(). But in fact there's always an underscore prepended.
So the chain is __main -> ___main -> _main :^)
Quite ugly :)

Even if we don't intend to use anything else than gcc (elf really, since gcc
can target nearly anything else like coff. an PEF backend would be nice
but there is a licence issue) this _EXPORT macro can be useful one day...
And if not, it's simpler to do a 
for fil in $(find . -name '*.[ch]') ; do
mv $fil $fil.bak
sed 's/_EXPORT //' <$fil.bak >$fil
rm $fil.bak
done

than adding them by hand again :-)

François.

En réponse à Marcus Overhagen <dos4gw@xxxxxx>:

> (send again, I used a wrong from last time)
> "Allen Brunson" <brunsona@xxxxxxxxxxx> wrote:
> 
> >Yes, exactly!  It's really ELF that is weird in this respect,
> exporting
> >every symbol by default, NOT other platforms like PPC.  I'm used to
> seeing
> >_EXPORT or something like it in every shared-library-like thing I've
> ever
> >worked on for decades.  If adding a few _EXPORTs here and there to
> the
> >source helps PPC people contribute and work on OpenBeOS, I don't see
> why
> >anybody should object.
> 
> I agree. Exporting every symbol is stupid, because you can easily have
> 
> name collisions. Thats why OS internel clases and symbols schould be 
> prefixed with a undescore ( _ ), as all symbols with underscore are
> reserved
> for the operationg system vendor (if I'm not wrong). Thats a
> workaround,
> and not exporting every symbol is nicer.
> 
> Another issue is the decision of the naming of all variables in a
> class.
> I think it was decided to prefix all with an f, thats not bad, as long
> as no one
> currently using BeOs also has the same variable name in a derived
> class.
> I think this risk is acceptable, but probably another prefix like _f
> would be
> better.
> 
> >You guys seem to be giving Nathan an extraordinarily hard time about
> this
> >awfully trivial thing (and other trivial things), so much so that it
> would
> Correct, I would be happy to add the _EXPORT to all exported symbols
> of the media kit, as I know that it is useful for compiling on other
> platforms.
> But I don't have much time to revise all the code already written.
> The same thing is with endianness issues. If you read an int32 from a
> file,
> and you know the file is written in little endian, you should
> read it using 
> in32 myint = B_LENDIAN_TO_HOST_INT32(the_int_to_be_read);
> This  way, your code is correct on both ppc and x86.
> All this is in ByteOrder.h, and should be used, for example when 
> writing a audio decoder, who reads header data from a WAV file,
> this needs to be done, as the data will be in little endian, and to
> properly read it on ppc which is big endian, you need to convert it.
> The macros do it properly for you.
> 
> regards
> Marcus  
> 
> 






Other related posts: