lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] [bug #20254] Initializing static/global variables


From: Jonathan Larmour
Subject: Re: [lwip-devel] [bug #20254] Initializing static/global variables
Date: Mon, 30 Jul 2007 21:59:28 +0100
User-agent: Thunderbird 1.5.0.12 (X11/20070530)

Goldschmidt Simon wrote:
So what about removing all the extra
xxxx = 0;
xxxx = NULL;

for all globals and static variables, if there are any?

These should be taken care of the the compiler clearing the BSS on startup, well all the compilers I use work this way.

Should not make the code any larger

Also change static tables to const tables (sockets.c) moves data that is only read into the rom data section, no more wasted ram

I think that's a good idea. And that is why I'd like to leave the bug
open, not because of the buggy compiler.

This bug was then closed, and I don't see a replacement about this. Did I miss it? Shall I open a new bug for this different issue - removing unnecessary zero initialisation of statics/globals, and making sure constant data is marked const?

Although I don't see what there is in sockets.c or anywhere else that can be const.

Note that many pieces of embedded software that are supposed to be
ultra-portable provide compile switches whether to initialize the data
or not. I'll try to search for some C definition if the initialization
to zero is mandatory or not.

It is mandatory.

It is also faster for the loader to initialise a large memory region (the bss section) to 0 all at once - it can write to memory at full speed, and it usually happens in assembler. And of course it definitely takes less code than initialising bits and pieces around the place. I can't envisage any circumstance where debugging bits individually would reduce memory use, and of course for many systems it would definitely be superfluous.

Jifl
--
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["The best things in life aren't things."]------      Opinions==mine




reply via email to

[Prev in Thread] Current Thread [Next in Thread]