[Picolibc] recent tinystdio changes
Keith Packard
keithp at keithp.com
Thu Jul 9 17:44:19 PDT 2020
I made a couple of tinystdio changes over the last few days:
* Used the linker instead of pre-processor to select between printf
variants
I finally figured out how to switch between printf variants using the
linker by using --defsym. *Plus* I figured out how to make this work
using the same command line option which defines a preprocessor
symbol by matching on that in picolibc.specs.
* Pulled the sprintf/sscanf support out of fgetc/fputc and into
separate functions.
String I/O now uses custom put/get functions. This saves a bunch of
space in fgetc/fputc and streamlines that code in the usual case.
* Made getc/ungetc re-entrant using atomic operations.
For systems without the necessary atomic support, there are functions
that applications can replace. This means that applications can use
tinystdio from multiple threads without needing external locks, and
without needing to add locking inside picolibc.
The POSIX interfaces, which include buffering on top of POSIX I/O
functions, are still non-reentrant. Those will require a locking
interface to be provided by the underlying O/S.
On rv32imac, the size of the printf.c example is smaller now:
text before text after
printf.elf 9284 8998
printf-float.elf 6540 6214
printf-int.elf 2336 2266
--
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://keithp.com/pipermail/picolibc/attachments/20200709/9b611185/attachment.sig>
More information about the Picolibc
mailing list