[PATCH] Check mac-address first in fsl_soc.c

Kumar Gala galak at kernel.crashing.org
Wed Feb 14 05:01:45 EST 2007


On Feb 13, 2007, at 11:45 AM, Timur Tabi wrote:

> Kumar Gala wrote:
>
>> How about something like comparing against a local null array  
>> instead.  Something like:
>>     u8 null_mac_addr[6] = { 0 };
>>     if (!mac_addr || (memcmp(mac_addr, null_mac_addr, 6) == 0)) {
>
> I believe this will cause the compiler to generate more code, not  
> less.  When you declare an initialized array as a local variable,  
> the compiler reserves space on the stack, and then it generates  
> code to copy the data from some global storage to the stack.

Actually it just does two stores in this case to the stack space, so  
we talking about 4 instructions:
* stack update
* load 0
* stw 0
* sth 0

vs

the static array that we never get ride of.

I'd prefer the instructions/local variable.

> If I inline a string instead, however, the compiler will just put  
> the string in global storage and reference it directly.  The  
> compiler should be able to detect multiple instances of the same  
> string, and store them as a single string.
>
> If you still want null_mac_addr[], you would need to do this:
>
> 	static const u8 null_mac_addr[6] = { 0 };

Let's drop the static const part.

- k






More information about the Linuxppc-dev mailing list