Update stdio code in libc

Picolibc now requires to create stdin, stdout and stderr files
ourselves instead of __iob array. Thus changes and renaming
of iob.c to stdio.c

f320a0aa17
added option to select default printf format, so using
picolibc.specs or defining PRINTF_LEVEL is no longer needed.
This commit is contained in:
Michal Sieron 2021-08-23 11:16:08 +02:00
parent ef7b287248
commit 3d4a64e112
3 changed files with 11 additions and 9 deletions

View File

@ -52,11 +52,10 @@ INCLUDES = -I$(PICOLIBC_DIRECTORY)/newlib/libc/tinystdio \
-I$(BUILDINC_DIRECTORY) \
-I$(BUILDINC_DIRECTORY)/../libc \
-I$(CPU_DIRECTORY)
PICOLIBC_SPECS = --specs=$(BUILDINC_DIRECTORY)/../libc/picolibc.specs -DPICOLIBC_INTEGER_PRINTF_SCANF
COMMONFLAGS = $(DEPFLAGS) -Os $(CPUFLAGS) -g3 -fomit-frame-pointer -Wall -fno-builtin -fno-stack-protector -flto $(INCLUDES)
CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(SOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding
LDFLAGS = -nostdlib -nodefaultlibs -Wl,--no-dynamic-linker -Wl,--build-id=none $(CFLAGS) -L$(BUILDINC_DIRECTORY) $(PICOLIBC_SPECS)
LDFLAGS = -nostdlib -nodefaultlibs -Wl,--no-dynamic-linker -Wl,--build-id=none $(CFLAGS) -L$(BUILDINC_DIRECTORY)
define compilexx
$(CX) -c $(CXXFLAGS) $(1) $< -o $@

View File

@ -1,7 +1,7 @@
include ../include/generated/variables.mak
include $(SOC_DIRECTORY)/software/common.mak
all: libc.a iob.c.o missing.c.o
all: libc.a stdio.c.o missing.c.o
CPUFAMILY=
@ -53,6 +53,7 @@ libc.a: cross.txt
-Dpicocrt=false \
-Dthread-local-storage=false \
-Dio-long-long=true \
-Dformat-default=integer \
-Dincludedir=picolibc/$(TRIPLE)/include \
-Dlibdir=picolibc/$(TRIPLE)/lib \
--cross-file cross.txt
@ -60,7 +61,7 @@ libc.a: cross.txt
meson compile
cp newlib/libc.a libc.a
iob.c.o: $(LIBC_DIRECTORY)/iob.c
stdio.c.o: $(LIBC_DIRECTORY)/stdio.c
$(compile)
$(AR) csr libc.a $@

View File

@ -1,7 +1,7 @@
/* Most of the code here is ported from console.c
* with slightly changed function signatures and
* names. Picolibc requires providing __iob array
* which contains stdin, stdout and stderr files.
* names. It sets up for stdin, stdout and
* stderr files.
* To simpify things, we can create one file
* which can be both read from and written to,
* and assign it to all three of them.
@ -10,8 +10,8 @@
* provide stderr for example which could be non-
* blocking for example.
*
* For more information on __iob and how to create
* it look into picolibc/doc/os.md.
* For more information on usage and how to create
* those files look into picolibc/doc/os.md.
*/
#include <stdio.h>
@ -96,5 +96,7 @@ int readchar_nonblock(void)
static FILE __stdio = FDEV_SETUP_STREAM(dummy_putc, dummy_getc, NULL, _FDEV_SETUP_RW);
FILE *const __iob[3] = { &__stdio, &__stdio, &__stdio };
FILE *const stdout = &__stdio;
FILE *const stderr = &__stdio;
FILE *const stdin = &__stdio;