[lug] C++ inline asm on g++
D. Stimits
stimits at idcomm.com
Thu Jan 10 22:53:10 MST 2002
Kelly Brock wrote:
>
> Hi,
>
> > > Just a thought, what would happen with the following?
> > >
> > > namespace something
> > > {
> > > extern void function(void);
> > > };
Just for fun, try this first:
namespace something
{
extern "C++" void function(void);
}
This assumes the function is compiled with g++ and not gcc, as C++ code.
Without that, the "C++" would probably cause mangling to be expected
where there is none. Just the opposite of extern "C", force it as C++
linkage and mangling (although you could do it with C linkage, I think
you are interested in the benefits of having it C++ from the start).
D. Stimits, stimits at idcomm.com
> > >
> > > Is name mangling still an issue and/or will the
> > function be imported into
> > > the namespace? Hmm, don't think I've ever tried this one,
> > I'll dig out the
> > > bible and see..
> >
> > I believe this should work just fine. So long as it can find the void
> > function itself (meaning the namespace can add proper mangling around
> > it, provided "it" can be found in the first place).
>
> Well.... If it's a C style name and the extern "imports" it to the
> namespace, everything seems like it would be fine. Unfortunately I don't
> think that's what would happen. Unfortunately I don't believe that it would
> make "something::function" resolve correctly the the C implementation. I
> don't even think that it would make something::function resolve at all
> within external references..
>
> > As for particular
> > registers and such that have to be preserved or restored, I
> > don't think
> > *that* part changes with version of g++, I think that 2.91 of
> > redhat 6.2
> > and 2.96 of RH 7.x, or even g++ versions 3.x+ should all have the same
> > requirements on registers to save and restore. Someone here no doubt
> > knows more about this and can verify it, only mangling schemes should
> > change between those versions. I definitely need someone at BLUG that
> > can say this is right or wrong.
>
> Registers don't really matter.. I can always have a GCC version of the
> function which saves *everything* including CPU processor flags if required.
> Register knowledge is only required for optimization, you can always just
> save everything if you don't know.... (Obviously it would be a waste, but
> it *would* work.)
>
> Regards,
>
> KB
>
> _______________________________________________
> Web Page: http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
More information about the LUG
mailing list