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
|
@ -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 *);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <assert.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue