[PATCH] Reduce RAM usage of floating point conversion functions
Federico Terraneo
fede.tft@hotmail.it
Mon Jun 10 10:08:00 GMT 2013
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 06/10/2013 11:29 AM, Freddie Chopin wrote:
> W dniu 2013-06-10 11:12, Federico Terraneo pisze:
>> I did think about that, but this moves 256 bytes of .bss to 256
>> bytes of .rodata, i.e. it would take up that amount of FLASH on
>> a microcontroller, and the table is mostly filled with zeros,
>> which still seems a waste. Here is a patch that goes in that
>> direction: if PREFER_SIZE_OVER_SPEED, __OPTIMIZE_SIZE__ or
>> _SMALL_HEXDIG are defined, the table is still replaced with a
>> function, otherwise the table is made const (but not static,
>> since it's used also in another file). In this way in both cases
>> 256 bytes of RAM are saved, and in the former also 256 bytes of
>> FLASH.
>
> Great!
>
> But one thing - is the patch correct? You define a macro
> __check_hexdig(), and in the code you use __get_hexdig(), which I
> cannot find.
Thank you for noticing it. At one point I changed the function name,
thought I've changed the name everywhere but tried to compile the
individual files for errors to be double sure, relying on the compiler
to check for such errors. However I forgot that in C you can call a
function without having first declared it (I mostly write in C++), so
that slipped through anyway.
New patch attached.
>
> BTW - could you check what's the size of the new function you
> introduced (__hexdig_fun())? If it's not smaller than this 256B
> array than this is not a size optimization (;
I've tested it compiling for the thumb2 intruction set (Cortex-M3) and
it's 52 bytes, while for the ARM instruction set is 64 bytes.
>
> 4\/3!!
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJRtaWQAAoJECkLFtN5Xr9f05oH/3zTFTsJWAhCp1+h9fCh/8YP
OSFqPbFk1eIA+AVFHcihyg0XlNyO7xfWAwh8jcU8FwZfGmMYDWjHnvspSxawAmOf
+MEBgaARLAsHCPX2/H0mrQ+JXnkxgcNM9QeTQbKn6JHcqaYfh9UkyzM28y2ljhC5
k7suR08K+++7yQGj38Hkb4TV594vF403VJkxlF7HU+D+9nuAUH41UYW5OlnSiGtt
NskUG3U71WUD9NHlGK4e1gkxklOI2/RRjxAv7rUqrjQcfnibnFgIHyjNTqMvYpuU
MaeBUB0/p47ZTNnxsHcHENsjlh52YAcCJdEp6+fGoxHceHS0egPZaSHdBkOfKRg=
=OTBe
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: float-conversion2.patch
Type: text/x-patch
Size: 17553 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20130610/af49abb1/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: float-conversion2.patch.sig
Type: application/octet-stream
Size: 287 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20130610/af49abb1/attachment.obj>
More information about the Newlib
mailing list