linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: const versus __attribute__((const))
@ 2003-12-08 15:46 Arnd Bergmann
  2003-12-08 17:50 ` H. Peter Anvin
  0 siblings, 1 reply; 18+ messages in thread
From: Arnd Bergmann @ 2003-12-08 15:46 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: linux-kernel

H. Peter Anvin writes:
> I have made a patch against the current tree defining
> __attribute_const__ in <linux/compiler.h> and using it in the above
> cases; does anyone know any reason why I should *NOT* submit this to
> Linus?

I noticed before that gcc appearantly ignores __attribute__((const))
for inline functions, so both the original and your proposed code
is rather pointless as an optimization, except for extern declarations.

I'd rather remove the 'const' completely where it causes warnings for
inline functions.

	Arnd <><


^ permalink raw reply	[flat|nested] 18+ messages in thread
* const versus __attribute__((const))
@ 2003-12-08  1:19 H. Peter Anvin
  2003-12-08 12:32 ` Nikita Danilov
  0 siblings, 1 reply; 18+ messages in thread
From: H. Peter Anvin @ 2003-12-08  1:19 UTC (permalink / raw)
  To: linux-kernel

I have been chasing down a bunch of warnings that have been annoying
me, and I have observed that a bunch of the byteorder functions are
defined in ways similar to:

static __inline__ __const__ __u16 ___arch__swab16(__u16 value)

With -W -Wall at least gcc 3.2.2 will issue a warning:

warning: type qualifiers ignored on function return type

... which seems to imply the __const__ is ignored.  Reading the gcc
documentation it appears the correct syntax is
__attribute__((__const__)) rather than __const__.

I have made a patch against the current tree defining
__attribute_const__ in <linux/compiler.h> and using it in the above
cases; does anyone know any reason why I should *NOT* submit this to
Linus?

	-hpa
-- 
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
If you send me mail in HTML format I will assume it's spam.
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2003-12-09 20:19 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-08 15:46 const versus __attribute__((const)) Arnd Bergmann
2003-12-08 17:50 ` H. Peter Anvin
2003-12-08 18:27   ` Nikita Danilov
2003-12-08 18:31     ` H. Peter Anvin
2003-12-09  2:59       ` Jamie Lokier
2003-12-09  3:21         ` H. Peter Anvin
2003-12-09  3:49           ` Jamie Lokier
2003-12-09  5:37             ` H. Peter Anvin
2003-12-09  7:26               ` Linus Torvalds
2003-12-09  7:40                 ` H. Peter Anvin
2003-12-09 11:56                   ` Arnd Bergmann
2003-12-09 15:42                     ` H. Peter Anvin
2003-12-09 16:44                       ` Linus Torvalds
2003-12-09 16:51                         ` H. Peter Anvin
2003-12-09 19:15                           ` Jamie Lokier
2003-12-09  7:19             ` Linus Torvalds
  -- strict thread matches above, loose matches on Subject: below --
2003-12-08  1:19 H. Peter Anvin
2003-12-08 12:32 ` Nikita Danilov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).