lkml.org 
[lkml]   [2003]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Why is get_current() not const function?
Is it possible to use __attribute__((const) with inline functions?
I tried that, but it seems that gcc ignores __attribute__((const) and
looks at the contents of the function instead.

I've tried the attached test app: With gcc-3.2.1 (gcc -O3), and
"inlconst" was called 10 times, constfnc only once.

--
Manfred
#include <stdio.h>
#include <stdlib.h>

static int constfnc(int x) __attribute__((const));

static inline int inlconst(int x) __attribute__((const));

static void dummy(int i);

static inline int inlconst(int x)
{
printf("in inlconst.\n");
return 2;
}

int main(void)
{
int i;
for(i=0;i<10;i++) {
dummy(constfnc(0));
}
for (i=0;i<10;i++) {
dummy(inlconst(0));
}
}

int constfnc(int x)
{
printf("in const.\n");
return 1;
}


void dummy(int i)
{
}

\
 
 \ /
  Last update: 2005-03-22 13:34    [W:0.024 / U:3.372 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site