lkml.org 
[lkml]   [2000]   [Jan]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Constant byteorder macros.
Oliver Xymoron wrote:
>
> On Thu, 20 Jan 2000, H. Peter Anvin wrote:
>
> > > switch (status) {
> > > case cpu_to_le16(CONSTANT_XYZ):
> > >
> > > ... I need to define new macros __constant_cpu_to_le16(), etc.
> >
> > Given that gcc has a __builtin_constant_p(x), you ought to be able to
> > do:
> >
> > #define cpu_to_le16(x) ( __builtin_constant_p(x) ? __constant_cpu_to_le16(x) : __cpu_to_le16(x) )
>
> This is ugly and potentially means changing tons of macros. Couldn't you
> just do the appropriate byteswap on the switch variable instead? There
> aren't many (any?) other places in C aside from the preprocessor and array
> sizing that insist on constant expressions.
>

So you'd rather waste optimization?

The definition may be ugly, but it works just fine.

-hpa

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

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.117 / U:1.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site