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 Wed, Jun 24, 2009 at 2:59 AM, Richard
Guenther<richard.guenther@gmail.com> wrote:
> On Tue, Jun 23, 2009 at 7:19 PM, H.J. Lu<hjl.tools@gmail.com> wrote:
>> Hi,
>>
>> I opened a bug report:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40528
>>
>> with the third proposal:
>>
>> 3. Ifunc attribute with prototype, but without argument:
>>
>> int
>> __attribute__ ((ifunc))
>> foo (...)
>> {
>> ?<return address of foo_{1,2,3}>
>> }
>>
>> We can call foo in the same file. Gcc checks the return value for
>> foo.
>>
>> Any comments?
>
> I don't understand this third proposal.
>
> Richard.
>

We can have

---
static int
foo1 (int x)
{
  return x;
}

int
__attribute__ ((ifunc))
foo (int)
{
  return foo1;
}

int
bar (int i)
{
  return foo (i);
}
---

In the body of an ifunc function, return type is changed to pointer
to function prototype with

/* Get the function return type inside function body.  Return a pointer
   to the function for IFUNC function.  */

static inline tree
function_return_type (const_tree decl)
{
  if (TREE_IFUNC_NAME (DECL_NAME (decl)))
    return build_pointer_type (TREE_TYPE (decl));
  else
    return TREE_TYPE (TREE_TYPE (decl));
}



-- 
H.J.


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