newlib: rebuild with the global stdio streams enabled.
This change means that there is only one set of global stdin, stdout, and stderr FILE streams shared by all the threads. This reduces memory usage and avoids having to close these streams before threads exit. These streams still have a lock to synchronise access.
This commit is contained in:
parent
ed1a6cc6f3
commit
f9ae521710
8 changed files with 47 additions and 6 deletions
|
@ -431,8 +431,6 @@ static __attribute__((noinline)) void user_start_phase2(void) {
|
||||||
memcpy(&phy_info, &default_phy_info, sizeof(sdk_phy_info_t));
|
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.
|
// Wait for UARTs to finish sending anything in their queues.
|
||||||
uart_flush_txfifo(0);
|
uart_flush_txfifo(0);
|
||||||
uart_flush_txfifo(1);
|
uart_flush_txfifo(1);
|
||||||
|
|
|
@ -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:
|
The build commands were:
|
||||||
|
|
||||||
mkdir build
|
mkdir build
|
||||||
cd 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
|
env CROSS_CFLAGS="-DSIGNAL_PROVIDED -DABORT_PROVIDED" make
|
||||||
make install
|
make install
|
||||||
|
|
|
@ -133,6 +133,10 @@ extern int malloc_trim (size_t);
|
||||||
extern int _malloc_trim_r (struct _reent *, size_t);
|
extern int _malloc_trim_r (struct _reent *, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern void __malloc_lock(struct _reent *);
|
||||||
|
|
||||||
|
extern void __malloc_unlock(struct _reent *);
|
||||||
|
|
||||||
/* A compatibility routine for an earlier version of the allocator. */
|
/* A compatibility routine for an earlier version of the allocator. */
|
||||||
|
|
||||||
extern void mstats (char *);
|
extern void mstats (char *);
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
/* Define to move the stdio stream FILE objects out of struct _reent and make
|
/* 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
|
them global. The stdio stream pointers of struct _reent are initialized to
|
||||||
point to the global stdio FILE stream objects. */
|
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 if small footprint nano-formatted-IO implementation used. */
|
||||||
#define _NANO_FORMATTED_IO 1
|
#define _NANO_FORMATTED_IO 1
|
||||||
|
|
|
@ -144,7 +144,7 @@ struct __sbuf {
|
||||||
* _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
|
* _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
|
* struct __sFILE_fake is the start of a struct __sFILE, with only the
|
||||||
* minimal fields allocated. In __sinit() we really allocate the 3
|
* minimal fields allocated. In __sinit() we really allocate the 3
|
||||||
|
@ -418,6 +418,43 @@ struct _reent
|
||||||
char *_signal_buf; /* strsignal */
|
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_stdin;
|
||||||
extern const struct __sFILE_fake __sf_fake_stdout;
|
extern const struct __sFILE_fake __sf_fake_stdout;
|
||||||
extern const struct __sFILE_fake __sf_fake_stderr;
|
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; \
|
(var)->_stderr = (__FILE *)&__sf_fake_stderr; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Only add assert() calls if we are specified to debug. */
|
/* Only add assert() calls if we are specified to debug. */
|
||||||
#ifdef _REENT_CHECK_DEBUG
|
#ifdef _REENT_CHECK_DEBUG
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue