Re: [PATCH][MSP430] Implement reduced code size printf and puts functions

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Apr 15 12:33, Jozef Lawrynowicz wrote:
> >From d4c48179ea3362b0dea483afba748728fdfa9310 Mon Sep 17 00:00:00 2001
> From: Jozef Lawrynowicz <[email protected]>
> Date: Fri, 12 Apr 2019 11:57:59 +0100
> Subject: [PATCH 1/2] [MSP430][1/2] Copy prerequisite file for "tiny" printf
>  implementation
> 
> Use newlib/libc/stdio/nano-vfprintf.c as baseline for tiny-printf.c
> [...]
> Subject: [PATCH 2/2] [MSP430][2/2] Implement reduced code size "tiny" printf
>  and puts
> 
> "tiny" printf is derived from _vfprintf_r in libc/stdio/nano-vfprintf.c.
> "tiny" puts has been implemented so that it just calls write, without
> any other processing.
> Support for buffering, reentrancy and streams has been removed from
> these functions to achieve reduced code size.
> 
> This reduced code size implementation of printf and puts can be enabled
> in an application by passing "--wrap printf" and "--wrap puts" to the
> GNU linker. This will replace references to "printf" and "puts" in user
> code with "__wrap_printf" and "__wrap_puts" respectively.
> If there is no implementation of these __wrap* functions in user code,
> these "tiny" printf and puts implementations will be linked into the
> final executable.
> 
> The wrapping mechanism is supposed to be invisible to the user:
> - A GCC wrapper option such as "-mtiny-printf" will be added to alias
>   these wrap commands.
> - If the user is unaware of the "tiny" implementation, and chooses to
>   implement their own __wrap_printf and __wrap_puts, their own
>   implementation will be automatically chosen over the "tiny" printf and
>   puts from the library.
> 
> Newlib must be configured with --enable-newlib-nano-formatted-io for 
> the "tiny" printf and puts functions to be built into the library.
> 
> Code size reduction examples:
> printf("Hello World\n")
>   baseline - msp430-elf-gcc gcc-8_3_0-release
>      text    data     bss
>    5638     214      26
>   "tiny" puts enabled
>     text    data     bss
>      714      90      20
> 
> printf("Hello %d\n", a)
>   baseline - msp430-elf-gcc gcc-8_3_0-release
>     text    data     bss
>    10916     614      28
> 
>   "tiny" printf enabled
>     text    data     bss
>     4632     280      20

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAly0eCkACgkQ9TYGna5E
T6CVJg/9EggEQoW6KO5rR9hUr/q4Q8zGkUnUrittDs13jHcRcch38uhG14om9BrM
KahcBPf8D8HgxDa850d/eQ+JtWojD5jvfZ+qB2MczOFRZvLOlA+mNkXa1p6VotQQ
vjUF67bKkPwQ6rf3wJAI05BNAnjbR0P3QLmuSAbJluFZUQhHVYfqG77lZZxoYKmo
BmBrnMz0QcHX9KZEOT/IKVJdyFiwD3Icu6HaGnRqhpcMdYQAmErFWCT4n8NnMW2p
DvOD/umvCkiS9nn3kIFoMj7HgB/Ir0dSymq7xEcCRuWdbrFH/rzpWVubdVRdLYcN
Q1seY/b3NhhovvI9xeefy9oI2Nv7jCpJlHmGs7TlbUq4P5na9PXPILAkMYeWed1F
omDwMy6WnxBNQoxc2mZQNVF6H1fc5SIgMpt8F+9pywGWQdaCkZ7eYBFD429J67Gl
hxSurpQfMQd59Z3L8TCecwJ2/SjhFhmtzH9hX0phEUCxROImscdkupt6+YJup7IW
0myV+XAGpUPexC6JSWqdj8LxLyEVvscfsjRmz5a/fwYeeOz2+Xs+xcuogQPd5xi5
N2GTM3bW5l07l+I40rZ3GTBWmTO+0xQ+/UeN9OtCJu4p5UUgZSs57Gtz08vg/U/i
aYJHoos465J1+Hv/HqHAc1/ousVhqzAoBTg+7X/vENdnbrPqdo4=
=8pcn
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.