diff options
author | Matthew Green <mrg@redhat.com> | 2002-02-03 09:24:18 +0000 |
---|---|---|
committer | Matthew Green <mrg@redhat.com> | 2002-02-03 09:24:18 +0000 |
commit | 8195aff714f2ea5d680a5129a1d54af388e90355 (patch) | |
tree | 683ff47f4802385e669491dda42bf8050772dbdf /newlib/libc/stdio | |
parent | ad67ada2fc7cdb361643d506701e274a67d796f9 (diff) | |
download | newlib-8195aff714f2ea5d680a5129a1d54af388e90355.zip newlib-8195aff714f2ea5d680a5129a1d54af388e90355.tar.gz newlib-8195aff714f2ea5d680a5129a1d54af388e90355.tar.bz2 |
* implement a new `struct _reent' that is significantly smaller. use this
if _REENT_SMALL is defined in config.h. define this for xstormy16.
Diffstat (limited to 'newlib/libc/stdio')
-rw-r--r-- | newlib/libc/stdio/findfp.c | 23 | ||||
-rw-r--r-- | newlib/libc/stdio/getchar.c | 3 | ||||
-rw-r--r-- | newlib/libc/stdio/iprintf.c | 6 | ||||
-rw-r--r-- | newlib/libc/stdio/perror.c | 3 | ||||
-rw-r--r-- | newlib/libc/stdio/printf.c | 6 | ||||
-rw-r--r-- | newlib/libc/stdio/putchar.c | 3 | ||||
-rw-r--r-- | newlib/libc/stdio/puts.c | 3 | ||||
-rw-r--r-- | newlib/libc/stdio/scanf.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdio/tmpnam.c | 3 | ||||
-rw-r--r-- | newlib/libc/stdio/vprintf.c | 6 | ||||
-rw-r--r-- | newlib/libc/stdio/vscanf.c | 2 |
11 files changed, 51 insertions, 9 deletions
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index c6790c4..a42a692 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -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]; } diff --git a/newlib/libc/stdio/getchar.c b/newlib/libc/stdio/getchar.c index 475cd13..3459326 100644 --- a/newlib/libc/stdio/getchar.c +++ b/newlib/libc/stdio/getchar.c @@ -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)); } diff --git a/newlib/libc/stdio/iprintf.c b/newlib/libc/stdio/iprintf.c index f054043..5f6a57d 100644 --- a/newlib/libc/stdio/iprintf.c +++ b/newlib/libc/stdio/iprintf.c @@ -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); diff --git a/newlib/libc/stdio/perror.c b/newlib/libc/stdio/perror.c index abb595b..19354c1 100644 --- a/newlib/libc/stdio/perror.c +++ b/newlib/libc/stdio/perror.c @@ -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)); diff --git a/newlib/libc/stdio/printf.c b/newlib/libc/stdio/printf.c index 81fb8a2..e8ec5b4 100644 --- a/newlib/libc/stdio/printf.c +++ b/newlib/libc/stdio/printf.c @@ -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); diff --git a/newlib/libc/stdio/putchar.c b/newlib/libc/stdio/putchar.c index 462393f..b725a49 100644 --- a/newlib/libc/stdio/putchar.c +++ b/newlib/libc/stdio/putchar.c @@ -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)); } diff --git a/newlib/libc/stdio/puts.c b/newlib/libc/stdio/puts.c index 44f17cc..e270199 100644 --- a/newlib/libc/stdio/puts.c +++ b/newlib/libc/stdio/puts.c @@ -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'); } diff --git a/newlib/libc/stdio/scanf.c b/newlib/libc/stdio/scanf.c index 5dd14fd..92473ad 100644 --- a/newlib/libc/stdio/scanf.c +++ b/newlib/libc/stdio/scanf.c @@ -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 diff --git a/newlib/libc/stdio/tmpnam.c b/newlib/libc/stdio/tmpnam.c index 28b394f..ec346c8 100644 --- a/newlib/libc/stdio/tmpnam.c +++ b/newlib/libc/stdio/tmpnam.c @@ -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 { diff --git a/newlib/libc/stdio/vprintf.c b/newlib/libc/stdio/vprintf.c index f913bc0..e82306e 100644 --- a/newlib/libc/stdio/vprintf.c +++ b/newlib/libc/stdio/vprintf.c @@ -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); } diff --git a/newlib/libc/stdio/vscanf.c b/newlib/libc/stdio/vscanf.c index 59c6373..e494aaf 100644 --- a/newlib/libc/stdio/vscanf.c +++ b/newlib/libc/stdio/vscanf.c @@ -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); } |