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

From: Willy Tarreau
Date: Sun Jun 12 2005 - 06:51:58 EST


Hi Mikael,

Just out of curiosity, I understand why we can have a const on an inline
function to help the compiler optimize the code at compile time in cases
such as below :

> -static inline const unsigned char dehex(char c) {
> +static inline __attribute_const__ unsigned char dehex(char c) {
> if ((c>='0')&&(c<='9')) {
> return c-'0';
> }

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 ?

Regards,
Willy

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/