]> sourceware.org Git - newlib-cygwin.git/commitdiff
* implement a new `struct _reent' that is significantly smaller. use this
authorMatthew Green <mrg@redhat.com>
Sun, 3 Feb 2002 09:24:18 +0000 (09:24 +0000)
committerMatthew Green <mrg@redhat.com>
Sun, 3 Feb 2002 09:24:18 +0000 (09:24 +0000)
if _REENT_SMALL is defined in config.h.  define this for xstormy16.

41 files changed:
newlib/ChangeLog
newlib/libc/include/math.h
newlib/libc/include/sys/config.h
newlib/libc/include/sys/reent.h
newlib/libc/reent/reent.c
newlib/libc/reent/reent.tex
newlib/libc/reent/signgam.c
newlib/libc/stdio/findfp.c
newlib/libc/stdio/getchar.c
newlib/libc/stdio/iprintf.c
newlib/libc/stdio/perror.c
newlib/libc/stdio/printf.c
newlib/libc/stdio/putchar.c
newlib/libc/stdio/puts.c
newlib/libc/stdio/scanf.c
newlib/libc/stdio/tmpnam.c
newlib/libc/stdio/vprintf.c
newlib/libc/stdio/vscanf.c
newlib/libc/stdlib/atexit.c
newlib/libc/stdlib/drand48.c
newlib/libc/stdlib/dtoa.c
newlib/libc/stdlib/exit.c
newlib/libc/stdlib/lcong48.c
newlib/libc/stdlib/ldtoa.c
newlib/libc/stdlib/lrand48.c
newlib/libc/stdlib/mallocr.c
newlib/libc/stdlib/mprec.c
newlib/libc/stdlib/mrand48.c
newlib/libc/stdlib/mstats.c
newlib/libc/stdlib/rand.c
newlib/libc/stdlib/rand48.c
newlib/libc/stdlib/rand48.h
newlib/libc/stdlib/seed48.c
newlib/libc/stdlib/srand48.c
newlib/libc/string/strtok.c
newlib/libc/time/asctime.c
newlib/libc/time/lcltime.c
newlib/libm/math/w_gamma.c
newlib/libm/math/w_lgamma.c
newlib/libm/math/wf_gamma.c
newlib/libm/math/wf_lgamma.c

index 4ded001a7b5fc7c523dac04406dacc467fb12ca1..3d33a4ca0f958f3ba95c31052c87c8065a7a3166 100644 (file)
@@ -1,3 +1,87 @@
+2002-02-02  matthew green  <mrg@redhat.com>
+
+       * libc/include/sys/config.h (_REENT_SMALL): Define for Xstormy16.
+
+       * libc/reent/reent.c (_reclaim_reent): Clean for _REENT_SMALL case.
+       * libc/reent/reent.tex: Add blurb about _REENT_SMALL.
+       * libc/include/sys/reent.h (struct _reent): Completely new version
+       for _REENT_SMALL.
+       (_REENT_INIT): New defines, different defintion depending on _REENT_SMALL.
+       (_REENT_CHECK, _REENT_CHECK_TM): Likewise.
+       (_REENT_CHECK_ASCTIME_BUF, _REENT_INIT_RAND48): Likewise.
+       (_REENT_CHECK_RAND48, _REENT_INIT_MP, _REENT_CHECK_MP): Likewise.
+       (_REENT_CHECK_EMERGENCY, _REENT_SIGNGAM, _REENT_RAND_NEXT): Likewise.
+       (_REENT_RAND48_SEED, _REENT_RAND48_MULT, _REENT_RAND48_ADD): Likewise.
+       (_REENT_MP_RESULT, _REENT_MP_RESULT_K, _REENT_MP_P5S): Likewise.
+       (_REENT_MP_FREELIST, _REENT_ASCTIME_BUF, _REENT_TM): Likewise.
+       (_REENT_EMERGENCY): Likewise.
+
+       * libc/include/sys/reent.h (struct __sFILE_fake): New struct, same as
+       the start of the real __sFILE, used for stdin, stdout and stderr until
+       they are setup properly.
+       (struct __sFILE): Move location of _data in _REENT_SMALL case.
+       * libc/stdio/findfp.c (__sinit): Rearrange for _REENT_SMALL case by
+       allocated stdin, stdout and stderr.
+       * libc/stdio/getchar.c (_getchar_r): Call _REENT_SMALL_CHECK_INIT().
+       * libc/stdio/iprintf.c (iprintf, _iprintf_r): Likewise.
+       * libc/stdio/perror.c (_perror_r): Likewise.
+       * libc/stdio/printf.c (printf, _printf_r): Likewise.
+       * libc/stdio/putchar.c (_putchar_r): Likewise.
+       * libc/stdio/puts.c (_puts_r): Likewise.
+       * libc/stdio/scanf.c (scanf, _scanf_r): Likewise.
+       * libc/stdio/vprintf.c (vprintf): Likewise.
+       * libc/stdio/vscanf.c (vscanf, _vscanf_r): Likewise.
+
+       * libc/stdio/tmpnam.c (_tmpnam_r): Use _REENT_EMERGENCY().
+
+       * libc/reent/reent.c (_wrapup_reent): Adjust for _REENT_SMALL atexit.
+       * libc/include/sys/reent.h (_atexit): Limit atexit() entries to 32
+       for _REENT_SMALL.
+       * libc/stdlib/atexit.c (atexit): Rearrange for _REENT_SMALL case.
+       * libc/stdlib/exit.c (exit): Rearrange for _REENT_SMALL case.
+
+       * libc/include/sys/reent.h (struct _rand48): Keep _rand_next if
+       _REENT_SMALL.
+       * libc/stdlib/drand48.c (_drand48_r): Call _REENT_CHECK_RAND48().
+       * libc/stdlib/lcong48.c (_lcong48_r): Likewise.
+       * libc/stdlib/lrand48.c (_lrand48_r): Likewise.
+       * libc/stdlib/mrand48.c (_mrand48_r): Likewise.
+       * libc/stdlib/rand48.c (__dorand48): Likewise.
+       * libc/stdlib/seed48.c (_seed48_r): Likewise.
+       * libc/stdlib/srand48.c (_srand48_r): Likewise.
+       * libc/stdlib/rand48.h (__rand48_seed, __rand48_mult, __rand48_add): Define
+       as _REENT_RAND48_SEED(), _REENT_RAND48_MULT() and _REENT_RAND48_ADD().
+       * libc/stdlib/dtoa.c (_dtoa_r): Call _REENT_CHECK_MP().  Use
+       _REENT_MP_RESULT() and _REENT_MP_RESULT_K().
+       * libc/stdlib/ldtoa.c (_ldtoa_r): Likewise.
+       * libc/stdlib/rand.c (srand): Use _REENT_RAND_NEXT().
+       * libc/stdlib/rand.c (rand): Likewise.
+
+       * libc/stdlib/mallocr.c (malloc_stats): Call _REENT_SMALL_CHECK_INIT().
+       * libc/stdlib/mstats.c (_mstats_r): Call _REENT_SMALL_CHECK_INIT().
+
+       * libc/stdlib/mprec.c (Balloc): Call _REENT_CHECK_MP.  Use
+       _REENT_MP_FREELIST() and _REENT_MP_P5S.
+       * libc/include/sys/reent.h (struct _mprec): New structure.
+
+       * libc/include/sys/reent.h (struct _reent): Rename _strtok_last to
+       _unused_strtok_last.
+       * libc/string/strtok.c (strtok): Use a local static variable.
+
+       * libc/include/sys/reent.h (_REENT_ASCTIME_SIZE): New define.
+       (_REENT_EMERGENCY_SIZE): Likewise.
+       * libc/time/asctime.c (asctime): Call _REENT_CHECK_ASCTIME_BUF().  Use
+       _REENT_ASCTIME_BUF().
+       * libc/time/lcltime.c (localtime): Call _REENT_CHECK_TM().  Use
+       _REENT_TM().
+
+       * libc/include/math.h (__singam_r): Use _REENT_SIGNGAM().
+       * libc/reent/signgam.c (__signgam): Use _REENT_SIGNGAM().
+       * libm/math/w_gamma.c (gamma): Use _REENT_SIGNGAM().
+       * libm/math/w_lgamma.c (lgamma): Use _REENT_SIGNGAM().
+       * libm/math/wf_gamma.c (gammaf): Use _REENT_SIGNGAM().
+       * libm/math/wf_lgamma.c (lgammaf): Use _REENT_SIGNGAM().
+
 2002-02-01  Geoffrey Keating  <geoffk@redhat.com>
 
        * configure.host (xstormy16): Don't use the generic malloc.
index e72d9ca218bdbf5aa80d5ed6dcfae5b8be07d4d5..0b9ef594e70fb95f2198b2c2c2b0be2816f510a8 100644 (file)
@@ -198,7 +198,7 @@ extern float dremf _PARAMS((float, float));
 extern int *__signgam _PARAMS((void));
 #endif /* ! defined (_REENT_ONLY) */
 
-#define __signgam_r(ptr) ((ptr)->_new._reent._gamma_signgam)
+#define __signgam_r(ptr) _REENT_SIGNGAM(ptr)
 
 /* The exception structure passed to the matherr routine.  */
 
index 8b13588936b26af5afb237396e7a09b7a6c468a5..a192745913cefffc8577f7b5ba94a6f31390744d 100644 (file)
 #define MALLOC_ALIGNMENT 8
 #define _POINTER_INT short
 #define __BUFSIZ__ 16
+#define _REENT_SMALL
 #endif
 
 #if INT_MAX == 32767
index 65417f83afdaa80699c2ca7bd5efb1dc7e5f49b3..7d1a47215912051ae87bb9b14ac70ba7ae33d840 100644 (file)
@@ -28,6 +28,11 @@ typedef unsigned __Long __ULong;
 typedef __uint32_t __ULong;
 #endif
 
+/*
+ * If _REENT_SMALL is defined, we make struct _reent as small as possible,
+ * by having nearly everything possible allocated at first use.
+ */
+
 struct _glue 
 {
   struct _glue *_next;
@@ -57,16 +62,23 @@ struct __tm
 };
 
 /*
- * atexit() support
+ * atexit() support.  For _REENT_SMALL, we limit to 32 max.
  */
 
 #define        _ATEXIT_SIZE 32 /* must be at least 32 to guarantee ANSI conformance */
 
+#ifndef _REENT_SMALL
 struct _atexit {
        struct  _atexit *_next;                 /* next in list */
        int     _ind;                           /* next index in this table */
        void    (*_fns[_ATEXIT_SIZE])(void);    /* the table itself */
 };
+#else
+struct _atexit {
+       int     _ind;                           /* next index in this table */
+       void    (*_fns[_ATEXIT_SIZE])(void);    /* the table itself */
+};
+#endif
 
 /*
  * Stdio buffers.
@@ -113,6 +125,29 @@ typedef long _fpos_t;              /* XXX must match off_t in <sys/types.h> */
  * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
  */
 
+#ifdef _REENT_SMALL
+/*
+ * struct __sFILE_fake is the start of a struct __sFILE, with only the
+ * minimal fields allocated.  In __sinit() we really allocate the 3
+ * standard streams, etc., and point away from this fake.
+ */
+struct __sFILE_fake {
+  unsigned char *_p;   /* current position in (some) buffer */
+  int  _r;             /* read space left for getc() */
+  int  _w;             /* write space left for putc() */
+  short        _flags;         /* flags, below; this FILE is free if 0 */
+  short        _file;          /* fileno, if Unix descriptor, else -1 */
+  struct __sbuf _bf;   /* the buffer (at least 1 byte, if !NULL) */
+  int  _lbfsize;       /* 0 or -_bf._size, for inline putc */
+
+  struct _reent *_data;
+};
+/* CHECK_INIT() comes from stdio/local.h; be sure to include that.  */
+# define _REENT_SMALL_CHECK_INIT(fp) CHECK_INIT(fp)
+#else
+# define _REENT_SMALL_CHECK_INIT(fp) /* nothing */
+#endif
+
 struct __sFILE {
   unsigned char *_p;   /* current position in (some) buffer */
   int  _r;             /* read space left for getc() */
@@ -122,6 +157,10 @@ struct __sFILE {
   struct __sbuf _bf;   /* the buffer (at least 1 byte, if !NULL) */
   int  _lbfsize;       /* 0 or -_bf._size, for inline putc */
 
+#ifdef _REENT_SMALL
+  struct _reent *_data;
+#endif
+
   /* operations */
   _PTR _cookie;        /* cookie passed to io functions */
 
@@ -147,7 +186,9 @@ struct __sFILE {
   int  _blksize;       /* stat.st_blksize (may be != _bf._size) */
   int  _offset;        /* current lseek offset */
 
-  struct _reent *_data;
+#ifndef _REENT_SMALL
+  struct _reent *_data;                /* Here for binary compatibility? Remove? */
+#endif
 };
 
 /*
@@ -175,8 +216,16 @@ struct _rand48 {
   unsigned short _seed[3];
   unsigned short _mult[3];
   unsigned short _add;
+#ifdef _REENT_SMALL
+  /* Put this in here as well, for good luck.  */
+  __extension__ unsigned long long _rand_next;
+#endif
 };
 
+/* How big the some arrays are.  */
+#define _REENT_EMERGENCY_SIZE 25
+#define _REENT_ASCTIME_SIZE 26
+
 /*
  * struct _reent
  *
@@ -185,10 +234,137 @@ struct _rand48 {
  * reentrant.  IE: All state information is contained here.
  */
 
+#ifdef _REENT_SMALL
+
+struct _mprec
+{
+  /* used by mprec routines */
+  struct _Bigint *_result;
+  int _result_k;
+  struct _Bigint *_p5s;
+  struct _Bigint **_freelist;
+};
+
+/* This version of _reent is layed our with "int"s in pairs, to help
+ * ports with 16-bit int's but 32-bit pointers, align nicely.  */
+struct _reent
+{
+
+  /* FILE is a big struct and may change over time.  To try to achieve binary
+     compatibility with future versions, put stdin,stdout,stderr here.
+     These are pointers into member __sf defined below.  */
+  struct __sFILE *_stdin, *_stdout, *_stderr;  /* XXX */
+
+  int _errno;                  /* local copy of errno */
+
+  int  _inc;                   /* used by tmpnam */
+
+  char *_emergency;
+  int __sdidinit;              /* 1 means stdio has been init'd */
+
+  int _current_category;       /* used by setlocale */
+  _CONST char *_current_locale;
+
+  struct _mprec *_mp;
+
+  void _EXFUN((*__cleanup),(struct _reent *));
+
+  int _gamma_signgam;
+
+  /* used by some fp conversion routines */
+  int _cvtlen;                 /* should be size_t */
+  char *_cvtbuf;
+
+  struct _rand48 *_r48;
+  struct __tm *_localtime_buf;
+  char *_asctime_buf;
+
+  /* signal info */
+  void (**(_sig_func))(int);
+
+  /* atexit stuff */
+  struct _atexit _atexit;
+
+  struct _glue __sglue;                        /* root of glue chain */
+  struct __sFILE *__sf;                        /* file descriptors */
+  struct __sFILE_fake __sf_fake;       /* fake initial stdin/out/err */
+};
+
+#define _REENT_INIT(var) \
+  { &var.__sf_fake, &var.__sf_fake, &var.__sf_fake, 0, 0, _NULL, 0, 0, \
+    "C", _NULL, _NULL, 0, 0, _NULL, _NULL, _NULL, _NULL, _NULL, \
+    { 0, _NULL }, { _NULL, 0, _NULL }, 0 }
+
+/* Only built the assert() calls if we are built with debugging.  */
+#if DEBUG 
+#include <assert.h>
+#else
+#define assert(x) ((void)0)
+#endif
+
+/* Generic _REENT check macro.  */
+#define _REENT_CHECK(var, what, type, size, init) do { \
+  struct _reent *_r = (var); \
+  if (_r->what == NULL) { \
+    _r->what = (type)malloc(size); \
+    assert(_r->what); \
+    init; \
+  } \
+} while (0)
+
+#define _REENT_CHECK_TM(var) \
+  _REENT_CHECK(var, _localtime_buf, struct __tm *, sizeof *((var)->_localtime_buf), \
+    /* nothing */)
+
+#define _REENT_CHECK_ASCTIME_BUF(var) \
+  _REENT_CHECK(var, _asctime_buf, char *, _REENT_ASCTIME_SIZE, \
+    memset((var)->_asctime_buf, 0, _REENT_ASCTIME_SIZE))
+
+/* Handle the dynamically allocated rand48 structure. */
+#define _REENT_INIT_RAND48(var) do { \
+  struct _reent *_r = (var); \
+  _r->_r48->_seed[0] = _RAND48_SEED_0; \
+  _r->_r48->_seed[1] = _RAND48_SEED_1; \
+  _r->_r48->_seed[2] = _RAND48_SEED_2; \
+  _r->_r48->_mult[0] = _RAND48_MULT_0; \
+  _r->_r48->_mult[1] = _RAND48_MULT_1; \
+  _r->_r48->_mult[2] = _RAND48_MULT_2; \
+  _r->_r48->_add = _RAND48_ADD; \
+} while (0)
+#define _REENT_CHECK_RAND48(var) \
+  _REENT_CHECK(var, _r48, struct _rand48 *, sizeof *((var)->_r48), _REENT_INIT_RAND48((var)))
+
+#define _REENT_INIT_MP(var) do { \
+  struct _reent *_r = (var); \
+  _r->_mp->_result_k = 0; \
+  _r->_mp->_result = _r->_mp->_p5s = _NULL; \
+  _r->_mp->_freelist = _NULL; \
+} while (0)
+#define _REENT_CHECK_MP(var) \
+  _REENT_CHECK(var, _mp, struct _mprec *, sizeof *((var)->_mp), _REENT_INIT_MP(var))
+
+#define _REENT_CHECK_EMERGENCY(var) \
+  _REENT_CHECK(var, _emergency, char *, sizeof *((var)->_emergency), /* nothing */)
+
+#define _REENT_SIGNGAM(ptr)    ((ptr)->_gamma_signgam)
+#define _REENT_RAND_NEXT(ptr)  ((ptr)->_r48->_rand_next)
+#define _REENT_RAND48_SEED(ptr)        ((ptr)->_r48->_seed)
+#define _REENT_RAND48_MULT(ptr)        ((ptr)->_r48->_mult)
+#define _REENT_RAND48_ADD(ptr) ((ptr)->_r48->_add)
+#define _REENT_MP_RESULT(ptr)  ((ptr)->_mp->_result)
+#define _REENT_MP_RESULT_K(ptr)        ((ptr)->_mp->_result_k)
+#define _REENT_MP_P5S(ptr)     ((ptr)->_mp->_p5s)
+#define _REENT_MP_FREELIST(ptr)        ((ptr)->_mp->_freelist)
+#define _REENT_ASCTIME_BUF(ptr)        ((ptr)->_asctime_buf)
+#define _REENT_TM(ptr)         ((ptr)->_localtime_buf)
+#define _REENT_EMERGENCY(ptr)  ((ptr)->_emergency)
+
+#else /* !_REENT_SMALL */
+
 struct _reent
 {
-  /* local copy of errno */
-  int _errno;
+  int _errno;                  /* local copy of errno */
 
   /* FILE is a big struct and may change over time.  To try to achieve binary
      compatibility with future versions, put stdin,stdout,stderr here.
@@ -196,7 +372,7 @@ struct _reent
   struct __sFILE *_stdin, *_stdout, *_stderr;
 
   int  _inc;                   /* used by tmpnam */
-  char _emergency[25];
+  char _emergency[_REENT_EMERGENCY_SIZE];
  
   int _current_category;       /* used by setlocale */
   _CONST char *_current_locale;
@@ -220,7 +396,7 @@ struct _reent
       struct
         {
           unsigned int _unused_rand;
-          char * _strtok_last;
+          char * _unused_strtok_last;
           char _asctime_buf[26];
           struct __tm _localtime_buf;
           int _gamma_signgam;
@@ -252,8 +428,6 @@ struct _reent
   struct __sFILE __sf[3];              /* first three file descriptors */
 };
 
-#define _NULL 0
-
 #define _REENT_INIT(var) \
   { 0, &var.__sf[0], &var.__sf[1], &var.__sf[2], 0, "", 0, "C", \
     0, _NULL, _NULL, 0, _NULL, _NULL, 0, _NULL, { {0, _NULL, "", \
@@ -261,6 +435,28 @@ struct _reent
     {{_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, \
      {_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, _RAND48_ADD}} } }
 
+#define _REENT_CHECK_RAND48(ptr)       /* nothing */
+#define _REENT_CHECK_MP(ptr)           /* nothing */
+#define _REENT_CHECK_TM(ptr)           /* nothing */
+#define _REENT_CHECK_ASCTIME_BUF(ptr)  /* nothing */
+
+#define _REENT_SIGNGAM(ptr)    ((ptr)->_new._reent._gamma_signgam)
+#define _REENT_RAND_NEXT(ptr)  ((ptr)->_new._reent._rand_next)
+#define _REENT_RAND48_SEED(ptr)        ((ptr)->_new._reent._r48._seed)
+#define _REENT_RAND48_MULT(ptr)        ((ptr)->_new._reent._r48._mult)
+#define _REENT_RAND48_ADD(ptr) ((ptr)->_new._reent._r48._add)
+#define _REENT_MP_RESULT(ptr)  ((ptr)->_result)
+#define _REENT_MP_RESULT_K(ptr)        ((ptr)->_result_k)
+#define _REENT_MP_P5S(ptr)     ((ptr)->_p5s)
+#define _REENT_MP_FREELIST(ptr)        ((ptr)->_freelist)
+#define _REENT_ASCTIME_BUF(ptr)        (&(ptr)->_new._reent._asctime_buf)
+#define _REENT_TM(ptr)         (&(ptr)->_new._reent._localtime_buf)
+#define _REENT_EMERGENCY(ptr)  ((ptr)->_emergency)
+
+#endif /* !_REENT_SMALL */
+
+#define _NULL 0
+
 /*
  * All references to struct _reent are via this pointer.
  * Internally, newlib routines that need to reference it should use _REENT.
index f35d95711b22b7b06223a37df8fd7051e5a9becb..192796908ba6278297e12a9de17adce9e7d35b1b 100644 (file)
@@ -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);
 }
index 71a0a0dcdc936a1a680970b1c44c5af355ba11bd..545624ca96181f931a5d7af7a28c58af551dff09 100644 (file)
@@ -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{<sys/config.h>}.
+
 @cindex global reentrancy structure
 @findex _impure_ptr
 Each function which uses the global reentrancy structure uses the global
index 905386686d6d4927fe74fc1dbf27b308af8d84fd..d3c17c9e50574aa82cfc55f4abe6b30beb65979e 100644 (file)
@@ -10,7 +10,7 @@
 int *
 __signgam ()
 {
-  return &_REENT->_new._reent._gamma_signgam;
+  return _REENT_SIGNGAM(_REENT);
 }
 
 #endif
index c6790c49123dc13e6050a11baeee81d04d10cda7..a42a69206209adccfce0f52bac24737c9354a913 100644 (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];
 }
index 475cd138bcaa7325f2cf09701ae807ef68db214a..34593266629431789e5ab3072fd182e6711b0962 100644 (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));
 }
 
index f054043023d4dc7a5207169b228c411e9b0ebb52..5f6a57dc460f7cf43c729baef99b210d0ad9ae0d 100644 (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);
index abb595ba934ff5be85379efd38a443636cc26e46..19354c11255bcd6f9092118d2cb8b75fc1f16889 100644 (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));
index 81fb8a2cb08855d7926cd00c5be07d48ccbf7d76..e8ec5b475eab5813ae3594dfe2cba2a9445d6c6e 100644 (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);
index 462393f8aab287dad56702e7bc69d160fa044e21..b725a496d4164016d943653b2024809ec1a68892 100644 (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));
 }
 
index 44f17cc919c5029c971c781df65d0f381e0154d6..e270199d21fa94759ec61a50d8df94a0bd363758 100644 (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');
 }
 
index 5dd14fde46a8cfb8338ba4566bfb3745a53005b6..92473ad8932f3bedd10e0814fc7841528afa6729 100644 (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
index 28b394f108b95f0dded3a3981af30ca5548935e1..ec346c8789325f6cd91a36d12ae4b72570a0ada9 100644 (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
     {
index f913bc097b673fb7b47528df73171c7ecc5c2ad5..e82306eaab519b91e89dd2cae669a4a846b1c21e 100644 (file)
 #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);
 }
index 59c63738aa02242303c13201ac7fd420f2dba064..e494aaf603e21098e60bee886c9775584aca8150 100644 (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);
 }
 
index 88cdd234cd8d9831fe2200a58c6f4ead3de9056b..77aab0c9819ec2e043935d1449a0fba70a42a948 100644 (file)
@@ -65,6 +65,8 @@ _DEFUN (atexit,
 {
   register struct _atexit *p;
 
+/* _REENT_SMALL atexit() doesn't allow more than the required 32 entries.  */
+#ifndef _REENT_SMALL
   if ((p = _REENT->_atexit) == NULL)
     _REENT->_atexit = p = &_REENT->_atexit0;
   if (p->_ind >= _ATEXIT_SIZE)
@@ -75,6 +77,11 @@ _DEFUN (atexit,
       p->_next = _REENT->_atexit;
       _REENT->_atexit = p;
     }
+#else
+  p = &_REENT->_atexit;
+  if (p->_ind >= _ATEXIT_SIZE)
+    return -1;
+#endif
   p->_fns[p->_ind++] = fn;
   return 0;
 }
index 8f9c4a26969aae21ca8abbe76271e55c29d1804f..89fe6af1d954607dc7beac3007afd5c77517e2e1 100644 (file)
@@ -17,6 +17,7 @@ double
 _DEFUN (_drand48_r, (r),
        struct _reent *r)
 {
+  _REENT_CHECK_RAND48(r);
   return _erand48_r(r, __rand48_seed);
 }
 
index 1ea1c5560b08b54cd5540ee1e2b4b69f11312a0b..c9be9ed510ff12f6fa81427d9e466381628ec2a3 100644 (file)
@@ -235,12 +235,13 @@ _DEFUN (_dtoa_r,
 
   d.d = _d;
 
-  if (ptr->_result)
+  _REENT_CHECK_MP(ptr);
+  if (_REENT_MP_RESULT(ptr))
     {
-      ptr->_result->_k = ptr->_result_k;
-      ptr->_result->_maxwds = 1 << ptr->_result_k;
-      Bfree (ptr, ptr->_result);
-      ptr->_result = 0;
+      _REENT_MP_RESULT(ptr)->_k = _REENT_MP_RESULT_K(ptr);
+      _REENT_MP_RESULT(ptr)->_maxwds = 1 << _REENT_MP_RESULT_K(ptr);
+      Bfree (ptr, _REENT_MP_RESULT(ptr));
+      _REENT_MP_RESULT(ptr) = 0;
     }
 
   if (word0 (d) & Sign_bit)
@@ -415,11 +416,11 @@ _DEFUN (_dtoa_r,
        i = 1;
     }
   j = sizeof (__ULong);
-  for (ptr->_result_k = 0; sizeof (_Bigint) - sizeof (__ULong) + j <= i;
+  for (_REENT_MP_RESULT_K(ptr) = 0; sizeof (_Bigint) - sizeof (__ULong) + j <= i;
        j <<= 1)
-    ptr->_result_k++;
-  ptr->_result = Balloc (ptr, ptr->_result_k);
-  s = s0 = (char *) ptr->_result;
+    _REENT_MP_RESULT_K(ptr)++;
+  _REENT_MP_RESULT(ptr) = Balloc (ptr, _REENT_MP_RESULT_K(ptr));
+  s = s0 = (char *) _REENT_MP_RESULT(ptr);
 
   if (ilim >= 0 && ilim <= Quick_max && try_quick)
     {
index 543bd0e303fecfe57b5e2c3c47b856764e1b23aa..fb7f73e7797e25a2416cfa8619d223166abd15e6 100644 (file)
@@ -62,9 +62,14 @@ _DEFUN (exit, (code),
   register struct _atexit *p;
   register int n;
 
+#ifdef _REENT_SMALL
+  for (p = &_REENT->_atexit, n = p->_ind; --n >= 0;)
+    (*p->_fns[n]) ();
+#else
   for (p = _REENT->_atexit; p; p = p->_next)
     for (n = p->_ind; --n >= 0;)
       (*p->_fns[n]) ();
+#endif
   if (_REENT->__cleanup)
     (*_REENT->__cleanup) (_REENT);
   _exit (code);
index 6dae4e90683fd4b34d02b0c95012d399075bdee7..548f32757cea7dbbef1360da549bc9c912a78fcc 100644 (file)
@@ -18,6 +18,7 @@ _DEFUN (_lcong48_r, (r, p),
        struct _reent *r _AND
        unsigned short p[7])
 {
+  _REENT_CHECK_RAND48(r);
   __rand48_seed[0] = p[0];
   __rand48_seed[1] = p[1];
   __rand48_seed[2] = p[2];
index b332d2a2e67188d40750cd3fd84c4becfc0c12a3..0a4c3230f93d07503d63a60962e639d9064dfe95 100644 (file)
@@ -2711,13 +2711,15 @@ char *outstr;
 rnd.rlast = -1;
 rnd.rndprc = NBITS;
 
+  _REENT_CHECK_MP(ptr);
+
 /* reentrancy addition to use mprec storage pool */
-if (ptr->_result)
+if (_REENT_MP_RESULT(ptr))
   {
-    ptr->_result->_k = ptr->_result_k;
-    ptr->_result->_maxwds = 1 << ptr->_result_k;
-    Bfree (ptr, ptr->_result);
-    ptr->_result = 0;
+    _REENT_MP_RESULT(ptr)->_k = _REENT_MP_RESULT_K(ptr);
+    _REENT_MP_RESULT(ptr)->_maxwds = 1 << _REENT_MP_RESULT_K(ptr);
+    Bfree (ptr, _REENT_MP_RESULT(ptr));
+    _REENT_MP_RESULT(ptr) = 0;
   }
 
 #if LDBL_MANT_DIG == 24
@@ -2748,9 +2750,9 @@ if( ndigits > NDEC )
         ndigits = NDEC;
 
 /* reentrancy addition to use mprec storage pool */
-ptr->_result = Balloc (ptr, 3);
-ptr->_result_k = 3;
-outstr = (char *)ptr->_result;
+_REENT_MP_RESULT(ptr) = Balloc (ptr, 3);
+_REENT_MP_RESULT_K(ptr) = 3;
+outstr = (char *)_REENT_MP_RESULT(ptr);
 
 etoasc( e, outstr, ndigits, mode, ldp );
 s =  outstr;
index 2e850f22459a8530754e0770b3a7f26b757d028c..bfc693b752b9f128e667cde088a6de3a164b879d 100644 (file)
@@ -17,6 +17,7 @@ long
 _DEFUN (_lrand48_r, (r),
        struct _reent *r)
 {
+  _REENT_CHECK_RAND48(r);
   __dorand48(r, __rand48_seed);
   return (long)((unsigned long) __rand48_seed[2] << 15) +
     ((unsigned long) __rand48_seed[1] >> 1);
index fb9b7d8b5fa6f38c3c86155062088368ea22423b..1e7120ab3dc6921baef187d4f3a305e4cea3d9bd 100644 (file)
@@ -3462,6 +3462,7 @@ void malloc_stats(RONEARG) RDECL
   MALLOC_UNLOCK;
 
 #ifdef INTERNAL_NEWLIB
+  _REENT_SMALL_CHECK_INIT(_stderr_r (reent_ptr));
   fp = _stderr_r(reent_ptr);
 #define fprintf fiprintf
 #else
index 8a2d404dc46919fbb89a747d1cbc28d2719087aa..0ef28c7454df0b486382547f420b5d96f5862172 100644 (file)
@@ -95,21 +95,22 @@ _DEFUN (Balloc, (ptr, k), struct _reent *ptr _AND int k)
   int x;
   _Bigint *rv ;
 
-  if (ptr->_freelist == NULL)
+  _REENT_CHECK_MP(ptr);
+  if (_REENT_MP_FREELIST(ptr) == NULL)
     {
       /* Allocate a list of pointers to the mprec objects */
-      ptr->_freelist = (struct _Bigint **) _calloc_r (ptr, 
+      _REENT_MP_FREELIST(ptr) = (struct _Bigint **) _calloc_r (ptr, 
                                                      sizeof (struct _Bigint *),
                                                      _Kmax + 1);
-      if (ptr->_freelist == NULL)
+      if (_REENT_MP_FREELIST(ptr) == NULL)
        {
          return NULL;
        }
     }
 
-  if ((rv = ptr->_freelist[k]) != 0)
+  if ((rv = _REENT_MP_FREELIST(ptr)[k]) != 0)
     {
-      ptr->_freelist[k] = rv->_next;
+      _REENT_MP_FREELIST(ptr)[k] = rv->_next;
     }
   else
     {
@@ -130,10 +131,11 @@ _DEFUN (Balloc, (ptr, k), struct _reent *ptr _AND int k)
 void
 _DEFUN (Bfree, (ptr, v), struct _reent *ptr _AND _Bigint * v)
 {
+  _REENT_CHECK_MP(ptr);
   if (v)
     {
-      v->_next = ptr->_freelist[v->_k];
-      ptr->_freelist[v->_k] = v;
+      v->_next = _REENT_MP_FREELIST(ptr)[v->_k];
+      _REENT_MP_FREELIST(ptr)[v->_k] = v;
     }
 }
 
@@ -425,10 +427,11 @@ _DEFUN (pow5mult,
 
   if (!(k >>= 2))
     return b;
-  if (!(p5 = ptr->_p5s))
+  _REENT_CHECK_MP(ptr);
+  if (!(p5 = _REENT_MP_P5S(ptr)))
     {
       /* first time */
-      p5 = ptr->_p5s = i2b (ptr, 625);
+      p5 = _REENT_MP_P5S(ptr) = i2b (ptr, 625);
       p5->_next = 0;
     }
   for (;;)
index d515b3a801f0411fc8a7273bcbedf0267dd78490..28f4f7d2b429d244aee75cd8aeaa1d53e193c189 100644 (file)
@@ -17,6 +17,7 @@ long
 _DEFUN (_mrand48_r, (r),
        struct _reent *r)
 {
+  _REENT_CHECK_RAND48(r);
   __dorand48(r, __rand48_seed);
   return ((long) __rand48_seed[2] << 16) + (long) __rand48_seed[1];
 }
index c1628957a54c3c9551973293f188c1eac63bb6e5..a2ae9592938372af8ac417ae721ac59ac95776e1 100644 (file)
@@ -135,6 +135,7 @@ _DEFUN (_mstats_r, (ptr, s),
        struct _reent *ptr _AND
        char *s)
 {
+  _REENT_SMALL_CHECK_INIT(_stderr_r (ptr));
   fiprintf (_stderr_r (ptr), "Memory allocation statistics %s\n", s);
   _malloc_stats_r (ptr);
 }
index a085ef37c301a3000a0ae11b2970c9245fd89072..4f5a607966aca55920269a7d23044d06ea793d9c 100644 (file)
@@ -72,7 +72,7 @@ on two different systems.
 void
 _DEFUN (srand, (seed), unsigned int seed)
 {
-        _REENT->_new._reent._rand_next = seed;
+        _REENT_RAND_NEXT(_REENT) = seed;
 }
 
 int
@@ -81,9 +81,10 @@ _DEFUN_VOID (rand)
   /* This multiplier was obtained from Knuth, D.E., "The Art of
      Computer Programming," Vol 2, Seminumerical Algorithms, Third
      Edition, Addison-Wesley, 1998, p. 106 (line 26) & p. 108 */
-  _REENT->_new._reent._rand_next = 
-     _REENT->_new._reent._rand_next * __extension__ 6364136223846793005LL + 1;
-  return (int)((_REENT->_new._reent._rand_next >> 32) & RAND_MAX);
+  _REENT_CHECK_RAND48(_REENT);
+  _REENT_RAND_NEXT(_REENT) = 
+     _REENT_RAND_NEXT(_REENT) * __extension__ 6364136223846793005LL + 1;
+  return (int)((_REENT_RAND_NEXT(_REENT) >> 32) & RAND_MAX);
 }
 
 #endif /* _REENT_ONLY */
index c65af12cdfbf650aa609cd9c42015c5a6b8d73ef..17fd04e928ca21f4e82ad9f808338fd8fff61796 100644 (file)
@@ -163,6 +163,7 @@ _DEFUN (__dorand48, (r, xseed),
   unsigned long accu;
   unsigned short temp[2];
 
+  _REENT_CHECK_RAND48(r);
   accu = (unsigned long) __rand48_mult[0] * (unsigned long) xseed[0] +
     (unsigned long) __rand48_add;
   temp[0] = (unsigned short) accu;     /* lower 16 bits */
index c1446d683333f116b1063accd72554b34c3c8afc..a6cb479ef6cc2190fb5b585f6a5bf189f3d4fa0f 100644 (file)
@@ -18,9 +18,9 @@
 #include <stdlib.h>
 
 extern void _EXFUN(__dorand48,(struct _reent *r, unsigned short[3]));
-#define __rand48_seed (r->_new._reent._r48._seed)
-#define __rand48_mult (r->_new._reent._r48._mult)
-#define __rand48_add (r->_new._reent._r48._add)
+#define __rand48_seed  _REENT_RAND48_SEED(r)
+#define __rand48_mult  _REENT_RAND48_MULT(r)
+#define __rand48_add   _REENT_RAND48_ADD(r)
 
 #if 0
 /* following values are defined in <sys/reent.h> */
index 3f2cb50612c3f3f07eaf30fb0af099f65361601d..43629cc40af452453f8be0b59a51f2ed75a8a1e3 100644 (file)
@@ -20,6 +20,7 @@ _DEFUN (_seed48_r, (r, xseed),
 {
   static unsigned short sseed[3];
 
+  _REENT_CHECK_RAND48(r);
   sseed[0] = __rand48_seed[0];
   sseed[1] = __rand48_seed[1];
   sseed[2] = __rand48_seed[2];
index 8850540e32cb30e01f016490044ac39764e890b6..69bdbfc3b345bc99afc68e57400f45800089b34c 100644 (file)
@@ -18,6 +18,7 @@ _DEFUN (_srand48_r, (r, seed),
        struct _reent *r _AND
        long seed)
 {
+  _REENT_CHECK_RAND48(r);
   __rand48_seed[0] = _RAND48_SEED_0;
   __rand48_seed[1] = (unsigned short) seed;
   __rand48_seed[2] = (unsigned short) ((unsigned long)seed >> 16);
index 7f250b45609d7ce00c4f03b17beee6433d3eed22..17228d223a64bdf9464ac645e7d5a392d5f76a04 100644 (file)
@@ -73,6 +73,7 @@ _DEFUN (strtok, (s, delim),
        register char *s _AND
        register const char *delim)
 {
-       return strtok_r (s, delim, &(_REENT->_new._reent._strtok_last));
+       static char *last;
+       return strtok_r (s, delim, &last);
 }
 #endif
index 4ad35e80641652ded2a152dd81e8b6cc642ed902..e4011856d73875e2d40c0b4ca667a0068d01ed72 100644 (file)
@@ -57,8 +57,8 @@ char *
 _DEFUN (asctime, (tim_p),
        _CONST struct tm *tim_p)
 {
-  char *buf = _REENT->_new._reent._asctime_buf;
-  return asctime_r (tim_p, buf);
+  _REENT_CHECK_ASCTIME_BUF(_REENT);
+  return asctime_r (tim_p, _REENT_ASCTIME_BUF(_REENT));
 }
 
 #endif
index e54a49d3722525c6fbd61f11fb294209e8d764f3..1cdc64fd0c7312dc7bdd292d42d93f4f7524bb50 100644 (file)
@@ -51,7 +51,8 @@ struct tm *
 _DEFUN (localtime, (tim_p),
        _CONST time_t * tim_p)
 {
-  return localtime_r (tim_p, (struct tm *)&(_REENT->_new._reent._localtime_buf));
+  _REENT_CHECK_TM(_REENT);
+  return localtime_r (tim_p, (struct tm *)_REENT_TM(_REENT));
 }
 
 #endif
index da0211555d2bf8123b670c21e54b0578a2f7d843..358a493df22261faeeb1235d5649d1389576b644 100644 (file)
@@ -145,11 +145,11 @@ Neither <<gamma>> nor <<gammaf>> is ANSI C.  */
 #endif
 {
 #ifdef _IEEE_LIBM
-       return __ieee754_gamma_r(x,&(_REENT->_new._reent._gamma_signgam));
+       return __ieee754_gamma_r(x,&(_REENT_SIGNGAM(_REENT)));
 #else
         double y;
        struct exception exc;
-        y = __ieee754_gamma_r(x,&(_REENT->_new._reent._gamma_signgam));
+        y = __ieee754_gamma_r(x,&(_REENT_SIGNGAM(_REENT)));
         if(_LIB_VERSION == _IEEE_) return y;
         if(!finite(y)&&finite(x)) {
 #ifndef HUGE_VAL 
index 1dc63994f54f6dada09b6c46a487aa3e83c2685a..e56e477673c9264f49641ac6eb06762e707dadcc 100644 (file)
 #endif
 {
 #ifdef _IEEE_LIBM
-       return __ieee754_lgamma_r(x,&(_REENT->_new._reent._gamma_signgam));
+       return __ieee754_lgamma_r(x,&(_REENT_SIGNGAM(_REENT)));
 #else
         double y;
        struct exception exc;
-        y = __ieee754_lgamma_r(x,&(_REENT->_new._reent._gamma_signgam));
+        y = __ieee754_lgamma_r(x,&(_REENT_SIGNGAM(_REENT)));
         if(_LIB_VERSION == _IEEE_) return y;
         if(!finite(y)&&finite(x)) {
 #ifndef HUGE_VAL 
index fbeb38af10e09375396a657d004626f59df70a0f..1204f39990362b3d052e1c6e316616ad7eab3ec4 100644 (file)
 #endif
 {
 #ifdef _IEEE_LIBM
-       return __ieee754_gammaf_r(x,&(_REENT->_new._reent._gamma_signgam));
+       return __ieee754_gammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
 #else
         float y;
        struct exception exc;
-        y = __ieee754_gammaf_r(x,&(_REENT->_new._reent._gamma_signgam));
+        y = __ieee754_gammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
         if(_LIB_VERSION == _IEEE_) return y;
         if(!finitef(y)&&finitef(x)) {
 #ifndef HUGE_VAL 
index e1765c4a0ad2dc4229bedab251fcc3bb067ed327..f1bf0c0193f7d749486d74858d01c42b5ae1c8c4 100644 (file)
 #endif
 {
 #ifdef _IEEE_LIBM
-       return __ieee754_lgammaf_r(x,&(_REENT->_new._reent._gamma_signgam));
+       return __ieee754_lgammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
 #else
         float y;
        struct exception exc;
-        y = __ieee754_lgammaf_r(x,&(_REENT->_new._reent._gamma_signgam));
+        y = __ieee754_lgammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
         if(_LIB_VERSION == _IEEE_) return y;
         if(!finitef(y)&&finitef(x)) {
 #ifndef HUGE_VAL 
This page took 0.096641 seconds and 5 git commands to generate.