From 8195aff714f2ea5d680a5129a1d54af388e90355 Mon Sep 17 00:00:00 2001 From: Matthew Green Date: Sun, 3 Feb 2002 09:24:18 +0000 Subject: * implement a new `struct _reent' that is significantly smaller. use this if _REENT_SMALL is defined in config.h. define this for xstormy16. --- newlib/libc/reent/reent.c | 27 ++++++++++++++++++++++++--- newlib/libc/reent/reent.tex | 4 ++++ newlib/libc/reent/signgam.c | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-) (limited to 'newlib/libc/reent') diff --git a/newlib/libc/reent/reent.c b/newlib/libc/reent/reent.c index f35d95711..192796908 100644 --- a/newlib/libc/reent/reent.c +++ b/newlib/libc/reent/reent.c @@ -48,14 +48,17 @@ _reclaim_reent (ptr) if (ptr != _impure_ptr) { /* used by mprec routines. */ - if (ptr->_freelist) +#ifdef _REENT_SMALL + if (ptr->_mp) /* don't bother allocating it! */ +#endif + if (_REENT_MP_FREELIST(ptr)) { int i; for (i = 0; i < 15 /* _Kmax */; i++) { struct _Bigint *thisone, *nextone; - nextone = ptr->_freelist[i]; + nextone = _REENT_MP_FREELIST(ptr)[i]; while (nextone) { thisone = nextone; @@ -64,9 +67,21 @@ _reclaim_reent (ptr) } } - _free_r (ptr, ptr->_freelist); + _free_r (ptr, _REENT_MP_FREELIST(ptr)); } +#ifdef _REENT_SMALL + if (ptr->_emergency) + _free_r (ptr, ptr->_emergency); + if (ptr->_mp) + _free_r (ptr, ptr->_mp); + if (ptr->_r48) + _free_r (ptr, ptr->_r48); + if (ptr->_localtime_buf) + _free_r (ptr, ptr->_localtime_buf); + if (ptr->_asctime_buf) + _free_r (ptr, ptr->_asctime_buf); +#else /* atexit stuff */ if ((ptr->_atexit) && (ptr->_atexit != &ptr->_atexit0)) { @@ -78,6 +93,7 @@ _reclaim_reent (ptr) _free_r (ptr, q); } } +#endif if (ptr->_cvtbuf) _free_r (ptr, ptr->_cvtbuf); @@ -113,9 +129,14 @@ _wrapup_reent(struct _reent *ptr) if (ptr == 0) ptr = _REENT; +#ifdef _REENT_SMALL + for (p = &ptr->_atexit, n = p->_ind; --n >= 0;) + (*p->_fns[n]) (); +#else for (p = ptr->_atexit; p; p = p->_next) for (n = p->_ind; --n >= 0;) (*p->_fns[n]) (); +#endif if (ptr->__cleanup) (*ptr->__cleanup) (ptr); } diff --git a/newlib/libc/reent/reent.tex b/newlib/libc/reent/reent.tex index 71a0a0dcd..545624ca9 100644 --- a/newlib/libc/reent/reent.tex +++ b/newlib/libc/reent/reent.tex @@ -29,6 +29,10 @@ and @var{mode}, and uses the global reentrancy structure. The function pointer to an instance of the reentrancy structure, @var{file} and @var{mode}. +There are two versions of @samp{struct _reent}, a normal one and one +for small memory systems, controlled by the @code{_REENT_SMALL} +definition from the (automatically included) @file{}. + @cindex global reentrancy structure @findex _impure_ptr Each function which uses the global reentrancy structure uses the global diff --git a/newlib/libc/reent/signgam.c b/newlib/libc/reent/signgam.c index 905386686..d3c17c9e5 100644 --- a/newlib/libc/reent/signgam.c +++ b/newlib/libc/reent/signgam.c @@ -10,7 +10,7 @@ int * __signgam () { - return &_REENT->_new._reent._gamma_signgam; + return _REENT_SIGNGAM(_REENT); } #endif -- cgit v1.2.3