This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Add ifunc attribute


On Fri, Jun 19, 2009 at 03:00:04PM -0700, H.J. Lu wrote:
> > Yeah. ?I would have proposed that
> >
> > void *foo (void) __attribute__((__ifunc__))
> > {
> > ?return zero;
> > }
> >
> > would simply generate foo with indirect function type.
> >
> > This of course causes a problem if you have a declaration for
> > the real foo available - but then you should better not have that,
> > as the compiler will then derive wrong properties for the real foo
> > from the ifunc wrapper body.
> >
> > That would at least not introduce the confusion with the extra name ...
> >
> 
> Here is the updated patch. I extended the ifunc attribute to
> static functions and added testcases to show that we need
> argument for ifunc attribute:

I agree with Richard here, ifunc attribute shouldn't have any arguments
and should just mean the function has gnu_indirect_function type instead
of function, nothing else.  That way users can combine it with other
extensions to get the behavior they want, rather than having weird
unexpected effects (in your case foo_ifunc is for some surprisingly
not defined at all).

If you don't have foo's prorotype in the current translation unit, you can
just use ifunc attribute alone, if you do have the prototype, it is not
much harder, e.g.

__typeof (foo) *foo_ifunc (void) __asm ("foo") __attribute__((ifunc))
{
  return foo_impl1;
}

will work just fine.  In this case you don't need to teach GCC about special
properties of ifunc attribute, foo for GCC isn't defined in the current
translation unit (it doesn't look at DECL_ASSEMBLER_NAME for inlining and
similar purposes).

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]