Date: Tue, 13 Jul 2004 13:40:27 -0400 From: David Muse Subject: [nanogui] reduced memory/storage patch Hello all, To reduce the amount of memory and storage required by microwindows, I have made several modifications to my copy of microwindows-0.90. A patch is attached. There are several classes of modifications that I made: * Made some things static. If a symbol in a library is static, it is local and thus strippable, making the library smaller on disk/flash. * Made some things const. If a symbol is const, then it can be put into the text section of the library and can be shared across processes. * Made some local variables non-static. If a buffer is local to a function, but is declared to be static, then it is allocated when the process starts rather than on the stack when the function is called. Making buffers static can speed up execution though. Sometimes code depends on buffers being static, I was careful of that. * Made some arrays of pointers to strings into const 2d arrays. This makes the code slightly larger, but makes it possible to put the arrays in the text rather than data section, even when using -fPIC. * Removed unused code. If some compile time options are set, then some code will never be called, I put ifdef's around that. To figure out what code to modify, I compiled microwindows and wrote a script to use the "size" program to check each object file for a data or bss section larger than 0, and for each of those to run "nm" on them and case-insensitively grep for " b " (variables in bss section) and " d " (variables in data section). Then I went looking through the code for each of the variables and decided what to do about them on a case-by-case basis. I did this to all the code that I use on my platform and ended up saving about 100k of flash and a few hundred K of ram overall. I don't know exactly how much was saved by the modifications to microwindows alone. Someone should probably double-check my analysis and my work. Let me know if I did something silly. Some of these concepts are new to me. Thanks, David Muse dmuse@4accesscommunications.com filename="microwindows.4ac.patch"