2005-03-09 17:46:00

by Bagalkote, Sreenivas

[permalink] [raw]
Subject: RE: [ANNOUNCE][PATCH 2.6.11 2/3] megaraid_sas: Announcing new mod ule for LSI Logic's SAS based MegaRAID controllers

>> >
>> >> . And since this is compile time
>> >> system-wide property, I kept it as driver global.
>> >
>> >that step I don't understand... why is it a global
>*VARIABLE* if it's
>> >compile time system-wide property...
>> >
>>
>> I see your point! Are you saying I should use
>if(sizeof(dma_addr_t)==8)
>> instead of the shortcut if(is_dma64)?
>yep
>well you can use a preprocessor define of something to make it slightly
>more readable (eg shortcut) if you want, but that's what I mean yeah..
>
>gcc will optimize the entire unused code away this way, including the
>actual conditional jump, so for performance and bloat-ness
>point of view
>it's nice.... and of course generic design beauty ;)
>

Great. Thanks! I will change it. If I understand you correctly, I should
#define IS_DMA64 (sizeof(dma_addr_t)==8).

Is this better than declaring is_dma64 global variable const? (Excuse the
oxymoron).


2005-03-09 18:20:03

by Arjan van de Ven

[permalink] [raw]
Subject: RE: [ANNOUNCE][PATCH 2.6.11 2/3] megaraid_sas: Announcing new mod ule for LSI Logic's SAS based MegaRAID controllers

On Wed, 2005-03-09 at 12:44 -0500, Bagalkote, Sreenivas wrote:
> >> >
> >> >> . And since this is compile time
> >> >> system-wide property, I kept it as driver global.
> >> >
> >> >that step I don't understand... why is it a global
> >*VARIABLE* if it's
> >> >compile time system-wide property...
> >> >
> >>
> >> I see your point! Are you saying I should use
> >if(sizeof(dma_addr_t)==8)
> >> instead of the shortcut if(is_dma64)?
> >yep
> >well you can use a preprocessor define of something to make it slightly
> >more readable (eg shortcut) if you want, but that's what I mean yeah..
> >
> >gcc will optimize the entire unused code away this way, including the
> >actual conditional jump, so for performance and bloat-ness
> >point of view
> >it's nice.... and of course generic design beauty ;)
> >
>
> Great. Thanks! I will change it. If I understand you correctly, I should
> #define IS_DMA64 (sizeof(dma_addr_t)==8).

that's one way to do it yeah.
>
> Is this better than declaring is_dma64 global variable const? (Excuse the
> oxymoron).

in C yes; in C "const" doesn't quite mean what you want it to mean with
this and as a result gcc I think can't optimize this the way it can with
the define.