Add global stdio streams support for reent small.
This commit is contained in:
parent
dc3928fc75
commit
b7520b14d5
|
@ -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
|
||||
|
@ -174,9 +174,9 @@ extern void __sinit (struct _reent *);
|
|||
__sinit (ptr); \
|
||||
} \
|
||||
while (0)
|
||||
#else
|
||||
#else /* _REENT_SMALL && !_REENT_GLOBAL_STDIO_STREAMS */
|
||||
# define _REENT_SMALL_CHECK_INIT(ptr) /* nothing */
|
||||
#endif
|
||||
#endif /* _REENT_SMALL && !_REENT_GLOBAL_STDIO_STREAMS */
|
||||
|
||||
struct __sFILE {
|
||||
unsigned char *_p; /* current position in (some) buffer */
|
||||
|
@ -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 /* _REENT_GLOBAL_STDIO_STREAMS */
|
||||
|
||||
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 /* _REENT_GLOBAL_STDIO_STREAMS */
|
||||
|
||||
/* Only add assert() calls if we are specified to debug. */
|
||||
#ifdef _REENT_CHECK_DEBUG
|
||||
#include <assert.h>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <sys/lock.h>
|
||||
#include "local.h"
|
||||
|
||||
#ifdef _REENT_SMALL
|
||||
#if defined(_REENT_SMALL) && !defined(_REENT_GLOBAL_STDIO_STREAMS)
|
||||
const struct __sFILE_fake __sf_fake_stdin =
|
||||
{_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL};
|
||||
const struct __sFILE_fake __sf_fake_stdout =
|
||||
|
@ -73,7 +73,7 @@ std (FILE *ptr,
|
|||
#else /* _STDIO_CLOSE_STD_STREAMS */
|
||||
ptr->_close = NULL;
|
||||
#endif /* _STDIO_CLOSE_STD_STREAMS */
|
||||
#if !defined(__SINGLE_THREAD__) && !defined(_REENT_SMALL)
|
||||
#if !defined(__SINGLE_THREAD__) && !(defined(_REENT_SMALL) && !defined(_REENT_GLOBAL_STDIO_STREAMS))
|
||||
__lock_init_recursive (ptr->_lock);
|
||||
/*
|
||||
* #else
|
||||
|
@ -260,7 +260,7 @@ __sinit (struct _reent *s)
|
|||
# ifndef _REENT_GLOBAL_STDIO_STREAMS
|
||||
s->__sglue._niobs = 3;
|
||||
s->__sglue._iobs = &s->__sf[0];
|
||||
# endif
|
||||
# endif /* _REENT_GLOBAL_STDIO_STREAMS */
|
||||
#else
|
||||
s->__sglue._niobs = 0;
|
||||
s->__sglue._iobs = NULL;
|
||||
|
@ -269,9 +269,15 @@ __sinit (struct _reent *s)
|
|||
__sinit if it's 0. */
|
||||
if (s == _GLOBAL_REENT)
|
||||
s->__sdidinit = 1;
|
||||
# ifndef _REENT_GLOBAL_STDIO_STREAMS
|
||||
s->_stdin = __sfp(s);
|
||||
s->_stdout = __sfp(s);
|
||||
s->_stderr = __sfp(s);
|
||||
# else /* _REENT_GLOBAL_STDIO_STREAMS */
|
||||
s->_stdin = &__sf[0];
|
||||
s->_stdout = &__sf[1];
|
||||
s->_stderr = &__sf[2];
|
||||
# endif /* _REENT_GLOBAL_STDIO_STREAMS */
|
||||
#endif
|
||||
|
||||
#ifdef _REENT_GLOBAL_STDIO_STREAMS
|
||||
|
@ -282,11 +288,11 @@ __sinit (struct _reent *s)
|
|||
stdout_init (&__sf[1]);
|
||||
stderr_init (&__sf[2]);
|
||||
}
|
||||
#else
|
||||
#else /* _REENT_GLOBAL_STDIO_STREAMS */
|
||||
stdin_init (s->_stdin);
|
||||
stdout_init (s->_stdout);
|
||||
stderr_init (s->_stderr);
|
||||
#endif
|
||||
#endif /* _REENT_GLOBAL_STDIO_STREAMS */
|
||||
|
||||
s->__sdidinit = 1;
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ extern _READ_WRITE_RETURN_TYPE __swrite64 (struct _reent *, void *,
|
|||
|
||||
/* Called by the main entry point fns to ensure stdio has been initialized. */
|
||||
|
||||
#ifdef _REENT_SMALL
|
||||
#if defined(_REENT_SMALL) && !defined(_REENT_GLOBAL_STDIO_STREAMS)
|
||||
#define CHECK_INIT(ptr, fp) \
|
||||
do \
|
||||
{ \
|
||||
|
@ -212,7 +212,7 @@ extern _READ_WRITE_RETURN_TYPE __swrite64 (struct _reent *, void *,
|
|||
(fp) = _stderr_r(_check_init_ptr); \
|
||||
} \
|
||||
while (0)
|
||||
#else /* !_REENT_SMALL */
|
||||
#else /* !_REENT_SMALL || _REENT_GLOBAL_STDIO_STREAMS */
|
||||
#define CHECK_INIT(ptr, fp) \
|
||||
do \
|
||||
{ \
|
||||
|
@ -221,7 +221,7 @@ extern _READ_WRITE_RETURN_TYPE __swrite64 (struct _reent *, void *,
|
|||
__sinit (_check_init_ptr); \
|
||||
} \
|
||||
while (0)
|
||||
#endif /* !_REENT_SMALL */
|
||||
#endif /* !_REENT_SMALL || _REENT_GLOBAL_STDIO_STREAMS */
|
||||
|
||||
#define CHECK_STD_INIT(ptr) \
|
||||
do \
|
||||
|
|
Loading…
Reference in New Issue