Re: Mark bitrevX() functions as const

From: David Howells
Date: Mon Dec 11 2006 - 08:15:17 EST


Jeff Garzik <jeff@xxxxxxxxxx> wrote:

> * overall, I agree with this type of change. several Linux lib functions
> could use this sort of annotation.

Yes. I just happened to notice bitrev.c at the end of my git pull and wondered
if it was what it sounded like...

> * I question its usefulness on static [inline] functions, because the compiler
> should be able to figure out side effects. have you examined before-and-after
> asm to see if the code generation changes for the inlined area?

It doesn't actually make any difference, but I think such functions should be
so marked anyway: it gives both the code writer and the compiler more
information (though they're both free to ignore it if they like).

> * naked __attribute__ is ugly. define something short and memorable in
> include/linux/compiler.h.

I'm not sure that's a good idea. You have to be careful not to cause confusion
with ordinary "const".

> * another annotation to consider is C99 keyword 'restrict'.

Indeed, though I presume you don't mean in this particular case...

David
-
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/