* implement a new `struct _reent' that is significantly smaller. use this

if _REENT_SMALL is defined in config.h.  define this for xstormy16.
This commit is contained in:
Matthew Green
2002-02-03 09:24:18 +00:00
parent ad67ada2fc
commit 8195aff714
41 changed files with 445 additions and 67 deletions

View File

@ -151,20 +151,29 @@ __sinit (s)
s->__cleanup = _cleanup_r; /* conservative */
s->__sdidinit = 1;
std (s->__sf + 0, __SRD, 0, s);
s->__sglue._next = NULL;
#ifndef _REENT_SMALL
s->__sglue._niobs = 3;
s->__sglue._iobs = &s->__sf[0];
#else
s->__sglue._niobs = 0;
s->__sglue._iobs = NULL;
s->_stdin = __sfp(s);
s->_stdout = __sfp(s);
s->_stderr = __sfp(s);
#endif
std (s->_stdin, __SRD, 0, s);
/* on platforms that have true file system I/O, we can verify whether stdout
is an interactive terminal or not. For all other platforms, we will
default to line buffered mode here. */
#ifdef HAVE_FCNTL
std (s->__sf + 1, __SWR, 1, s);
std (s->_stdout, __SWR, 1, s);
#else
std (s->__sf + 1, __SWR | __SLBF, 1, s);
std (s->_stdout, __SWR | __SLBF, 1, s);
#endif
std (s->__sf + 2, __SWR | __SNBF, 2, s);
std (s->_stderr, __SWR | __SNBF, 2, s);
s->__sglue._next = NULL;
s->__sglue._niobs = 3;
s->__sglue._iobs = &s->__sf[0];
}

View File

@ -74,12 +74,15 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <stdio.h>
#include <reent.h>
#include "local.h"
#undef getchar
int
_getchar_r (f)
struct _reent *f;
{
_REENT_SMALL_CHECK_INIT(_stdin_r (f));
return getc (_stdin_r (f));
}

View File

@ -38,6 +38,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <_ansi.h>
#include <stdio.h>
#include "local.h"
#ifndef _REENT_ONLY
#ifdef _HAVE_STDC
@ -50,6 +52,7 @@ iprintf (const char *fmt,...)
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (_REENT));
va_start (ap, fmt);
_stdout_r (_REENT)->_data = _REENT;
ret = vfiprintf (stdout, fmt, ap);
@ -69,6 +72,7 @@ iprintf (fmt, va_alist)
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (_REENT));
va_start (ap);
_stdout_r (_REENT)->_data = _REENT;
ret = vfiprintf (stdout, fmt, ap);
@ -89,6 +93,7 @@ _iprintf_r (struct _reent *ptr, const char *fmt, ...)
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (ptr));
va_start (ap, fmt);
ret = vfiprintf (_stdout_r (ptr), fmt, ap);
va_end (ap);
@ -109,6 +114,7 @@ _iprintf_r (data, fmt, va_alist)
struct _reent *ptr = data;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (ptr));
va_start (ap);
ret = vfiprintf (_stdout_r (ptr), fmt, ap);
va_end (ap);

View File

@ -49,6 +49,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <stdio.h>
#include <string.h>
#include "local.h"
void
_DEFUN (_perror_r, (ptr, s),
struct _reent *ptr _AND
@ -56,6 +58,7 @@ _DEFUN (_perror_r, (ptr, s),
{
char *error;
_REENT_SMALL_CHECK_INIT(_stderr_r (ptr));
if (s != NULL && *s != '\0')
{
fputs (s, _stderr_r (ptr));

View File

@ -2,6 +2,8 @@
#include <_ansi.h>
#include <stdio.h>
#include "local.h"
#ifdef _HAVE_STDC
#include <stdarg.h>
@ -12,6 +14,7 @@ _printf_r (struct _reent *ptr, const char *fmt, ...)
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (ptr));
va_start (ap, fmt);
ret = _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap);
va_end (ap);
@ -31,6 +34,7 @@ _printf_r (ptr, fmt, va_alist)
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (ptr));
va_start (ap);
ret = _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap);
va_end (ap);
@ -52,6 +56,7 @@ printf (const char *fmt, ...)
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (_REENT));
va_start (ap, fmt);
_stdout_r (_REENT)->_data = _REENT;
ret = vfprintf (_stdout_r (_REENT), fmt, ap);
@ -71,6 +76,7 @@ printf (fmt, va_alist)
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdout_r (_REENT));
va_start (ap);
_stdout_r (_REENT)->_data = _REENT;
ret = vfprintf (_stdout_r (_REENT), fmt, ap);

View File

@ -70,6 +70,8 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <stdio.h>
#include "local.h"
#undef putchar
int
@ -77,6 +79,7 @@ _putchar_r (ptr, c)
struct _reent *ptr;
int c;
{
_REENT_SMALL_CHECK_INIT(_stdout_r (ptr));
return __sputc (c, _stdout_r (ptr));
}

View File

@ -63,7 +63,9 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <stdio.h>
#include <string.h>
#include "fvwrite.h"
#include "local.h"
/*
* Write the given string to stdout, appending a newline.
@ -86,6 +88,7 @@ _DEFUN (_puts_r, (ptr, s),
uio.uio_iov = &iov[0];
uio.uio_iovcnt = 2;
_REENT_SMALL_CHECK_INIT(_stdout_r (ptr));
return (__sfvwrite (_stdout_r (ptr), &uio) ? EOF : '\n');
}

View File

@ -41,6 +41,7 @@ scanf (fmt, va_alist)
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdin_r (_REENT));
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
@ -66,6 +67,7 @@ _scanf_r (ptr, fmt, va_alist)
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT(_stdin_r (ptr));
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else

View File

@ -146,7 +146,8 @@ _DEFUN (_tmpnam_r, (p, s),
if (s == NULL)
{
/* ANSI states we must use an internal static buffer if s is NULL */
result = p->_emergency;
_REENT_CHECK_EMERGENCY(p);
result = _REENT_EMERGENCY(p);
}
else
{

View File

@ -26,12 +26,15 @@
#include <varargs.h>
#endif
#include "local.h"
int
_DEFUN (vprintf, (fmt, ap),
_CONST char *fmt _AND
va_list ap)
{
return vfprintf (stdout, fmt, ap);
_REENT_SMALL_CHECK_INIT(_stdout_r (_REENT));
return vfprintf (_stdout_r (_REENT), fmt, ap);
}
int
@ -40,5 +43,6 @@ _DEFUN (_vprintf_r, (ptr, fmt, ap),
_CONST char *fmt _AND
va_list ap)
{
_REENT_SMALL_CHECK_INIT(_stdout_r (ptr));
return _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap);
}

View File

@ -38,6 +38,7 @@ _DEFUN (vscanf, (fmt, ap),
_CONST char *fmt _AND
va_list ap)
{
_REENT_SMALL_CHECK_INIT(_stdin_r (_REENT));
return __svfscanf_r (_REENT, _stdin_r (_REENT), fmt, ap);
}
@ -49,6 +50,7 @@ _DEFUN (_vscanf_r, (ptr, fmt, ap),
_CONST char *fmt _AND
va_list ap)
{
_REENT_SMALL_CHECK_INIT(_stdin_r (ptr));
return __svfscanf_r (ptr, _stdin_r (ptr), fmt, ap);
}