* question oh macros and gcc's intelligence
@ 2011-03-17 7:48 Oliver Neukum
2011-03-17 9:06 ` Al Viro
0 siblings, 1 reply; 2+ messages in thread
From: Oliver Neukum @ 2011-03-17 7:48 UTC (permalink / raw)
To: linux-kernel
Hi,
if I write:
if (le16_to_cpu(p) == CONST) a();
is gcc smart enough to convert CONST to le16 and do
a simple comparison?
Regards
Oliver
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: question oh macros and gcc's intelligence
2011-03-17 7:48 question oh macros and gcc's intelligence Oliver Neukum
@ 2011-03-17 9:06 ` Al Viro
0 siblings, 0 replies; 2+ messages in thread
From: Al Viro @ 2011-03-17 9:06 UTC (permalink / raw)
To: Oliver Neukum; +Cc: linux-kernel
On Thu, Mar 17, 2011 at 08:48:57AM +0100, Oliver Neukum wrote:
> Hi,
>
> if I write:
>
> if (le16_to_cpu(p) == CONST) a();
>
> is gcc smart enough to convert CONST to le16 and do
> a simple comparison?
On little-endian - certainly, on big-endian - forget it.
if (p == cpu_to_le16(CONST))
would obviously work on any architecture and yes, it would be a comparison
with compile-time constant.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-17 9:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-17 7:48 question oh macros and gcc's intelligence Oliver Neukum
2011-03-17 9:06 ` Al Viro
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).