Re: [PATCH 2.4.31 7/9] gcc4: fix const function warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Willy Tarreau wrote:
Hi Mikael,

But I don't see how it can be useful in asm code like below, since the
compiler cannot evaluate it at compile time :


-static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
+static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
{
#ifdef CONFIG_X86_BSWAP
	__asm__("bswap %0" : "=r" (x) : "0" (x));


Am I missing something, or could we simply remove the __const__ every
time the function only uses asm ?


const functions are those that don't have side effects and depend
only on their argument list. So such functions can be CSE'ed or
reordered.

If it makes sense to use on any inline function, then I think it
makes sense if they're only using asm. Actually I would have thought
it would *only* help inline functions using asm, because gcc may
not know that such asm is 'const'.

But that's not to say they should be removed just because they
can't help gcc - it may be instructive to the programmer, or more
robust when making modifications to the code (eg. uninlining).

Send instant messages to your online friends http://au.messenger.yahoo.com -
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux