diff --git a/core/app_main.c b/core/app_main.c index 9c3918c..8b27f94 100644 --- a/core/app_main.c +++ b/core/app_main.c @@ -431,8 +431,6 @@ static __attribute__((noinline)) void user_start_phase2(void) { memcpy(&phy_info, &default_phy_info, sizeof(sdk_phy_info_t)); } - // Disable default buffering on stdout - setbuf(stdout, NULL); // Wait for UARTs to finish sending anything in their queues. uart_flush_txfifo(0); uart_flush_txfifo(1); diff --git a/libc/README.md b/libc/README.md index 4869531..e3c84cb 100644 --- a/libc/README.md +++ b/libc/README.md @@ -1,9 +1,9 @@ -Newlib from git://sourceware.org/git/newlib-cygwin.git with xtensa & locking patches see https://github.com/ourairquality/newlib and built from commit 7558d27f9dba58ba0e51e37a2aa3ea6be7214799 +Newlib from git://sourceware.org/git/newlib-cygwin.git with xtensa & locking patches see https://github.com/ourairquality/newlib and built from commit 984b749fb223daab954060c04720933290584f00 The build commands were: mkdir build cd build -../configure --with-newlib --enable-multilib --disable-newlib-io-c99-formats --enable-newlib-supplied-syscalls --enable-target-optspace --program-transform-name="s&^&xtensa-lx106-elf-&" --disable-option-checking --with-target-subdir=xtensa-lx106-elf --target=xtensa-lx106-elf --enable-newlib-nano-malloc --enable-newlib-nano-formatted-io --enable-newlib-reent-small --disable-newlib-mb --prefix=/tmp/libc +../configure --with-newlib --enable-multilib --disable-newlib-io-c99-formats --enable-newlib-supplied-syscalls --enable-target-optspace --program-transform-name="s&^&xtensa-lx106-elf-&" --disable-option-checking --with-target-subdir=xtensa-lx106-elf --target=xtensa-lx106-elf --enable-newlib-nano-malloc --enable-newlib-nano-formatted-io --enable-newlib-reent-small --disable-newlib-mb --enable-newlib-global-stdio-streams --prefix=/tmp/libc env CROSS_CFLAGS="-DSIGNAL_PROVIDED -DABORT_PROVIDED" make make install diff --git a/libc/xtensa-lx106-elf/include/malloc.h b/libc/xtensa-lx106-elf/include/malloc.h index e12a132..a9dc5bc 100644 --- a/libc/xtensa-lx106-elf/include/malloc.h +++ b/libc/xtensa-lx106-elf/include/malloc.h @@ -133,6 +133,10 @@ extern int malloc_trim (size_t); extern int _malloc_trim_r (struct _reent *, size_t); #endif +extern void __malloc_lock(struct _reent *); + +extern void __malloc_unlock(struct _reent *); + /* A compatibility routine for an earlier version of the allocator. */ extern void mstats (char *); diff --git a/libc/xtensa-lx106-elf/include/newlib.h b/libc/xtensa-lx106-elf/include/newlib.h index f4dd838..b947cbf 100644 --- a/libc/xtensa-lx106-elf/include/newlib.h +++ b/libc/xtensa-lx106-elf/include/newlib.h @@ -83,7 +83,7 @@ /* Define to move the stdio stream FILE objects out of struct _reent and make them global. The stdio stream pointers of struct _reent are initialized to point to the global stdio FILE stream objects. */ -/* #undef _WANT_REENT_GLOBAL_STDIO_STREAMS */ +#define _WANT_REENT_GLOBAL_STDIO_STREAMS 1 /* Define if small footprint nano-formatted-IO implementation used. */ #define _NANO_FORMATTED_IO 1 diff --git a/libc/xtensa-lx106-elf/include/sys/reent.h b/libc/xtensa-lx106-elf/include/sys/reent.h index 1ef2261..0f21c68 100644 --- a/libc/xtensa-lx106-elf/include/sys/reent.h +++ b/libc/xtensa-lx106-elf/include/sys/reent.h @@ -144,7 +144,7 @@ struct __sbuf { * _ub._base!=NULL) and _up and _ur save the current values of _p and _r. */ -#ifdef _REENT_SMALL +#if defined(_REENT_SMALL) && !defined(_REENT_GLOBAL_STDIO_STREAMS) /* * struct __sFILE_fake is the start of a struct __sFILE, with only the * minimal fields allocated. In __sinit() we really allocate the 3 @@ -418,6 +418,43 @@ struct _reent char *_signal_buf; /* strsignal */ }; +#ifdef _REENT_GLOBAL_STDIO_STREAMS +extern __FILE __sf[3]; + +# define _REENT_INIT(var) \ + { 0, \ + &__sf[0], \ + &__sf[1], \ + &__sf[2], \ + 0, \ + _NULL, \ + 0, \ + 0, \ + _NULL, \ + _NULL, \ + _NULL, \ + 0, \ + 0, \ + _NULL, \ + _NULL, \ + _NULL, \ + _NULL, \ + _NULL, \ + _REENT_INIT_ATEXIT \ + {_NULL, 0, _NULL}, \ + _NULL, \ + _NULL, \ + _NULL \ + } + +#define _REENT_INIT_PTR_ZEROED(var) \ + { (var)->_stdin = &__sf[0]; \ + (var)->_stdout = &__sf[1]; \ + (var)->_stderr = &__sf[2]; \ + } + +#else + extern const struct __sFILE_fake __sf_fake_stdin; extern const struct __sFILE_fake __sf_fake_stdout; extern const struct __sFILE_fake __sf_fake_stderr; @@ -454,6 +491,8 @@ extern const struct __sFILE_fake __sf_fake_stderr; (var)->_stderr = (__FILE *)&__sf_fake_stderr; \ } +#endif + /* Only add assert() calls if we are specified to debug. */ #ifdef _REENT_CHECK_DEBUG #include diff --git a/libc/xtensa-lx106-elf/lib/libc.a b/libc/xtensa-lx106-elf/lib/libc.a index 4dffe9f..457de25 100644 Binary files a/libc/xtensa-lx106-elf/lib/libc.a and b/libc/xtensa-lx106-elf/lib/libc.a differ diff --git a/libc/xtensa-lx106-elf/lib/libg.a b/libc/xtensa-lx106-elf/lib/libg.a index 4dffe9f..457de25 100644 Binary files a/libc/xtensa-lx106-elf/lib/libg.a and b/libc/xtensa-lx106-elf/lib/libg.a differ diff --git a/libc/xtensa-lx106-elf/lib/libm.a b/libc/xtensa-lx106-elf/lib/libm.a index 9978674..e7c0969 100644 Binary files a/libc/xtensa-lx106-elf/lib/libm.a and b/libc/xtensa-lx106-elf/lib/libm.a differ