Artem B. Bityuckiy
Tue Apr 6 16:42:00 GMT 2004

Hello Newlib people!

Please, see newlib/libc/include/sys/reent.h.

The following is fragment from this file:
#else /* !_REENT_SMALL */

struct _reent
   int _errno;                   /* local copy of errno */

   /* FILE is a big struct and may change over time.  To try to achieve 
      compatibility with future versions, put stdin,stdout,stderr here.
      These are pointers into member __sf defined below.  */
   __FILE *_stdin, *_stdout, *_stderr;

   int  _inc;                    /* used by tmpnam */
   char _emergency[_REENT_EMERGENCY_SIZE];

   int _current_category;        /* used by setlocale */
   _CONST char *_current_locale;

   int __sdidinit;               /* 1 means stdio has been init'd */

   void _EXFUN((*__cleanup),(struct _reent *));

   /* used by mprec routines */
   struct _Bigint *_result;
   int _result_k;
   struct _Bigint *_p5s;
   struct _Bigint **_freelist;

   /* used by some fp conversion routines */
   int _cvtlen;                  /* should be size_t */
   char *_cvtbuf;

           unsigned int _unused_rand;
           char * _strtok_last;
           char _asctime_buf[_REENT_ASCTIME_SIZE];
           struct __tm _localtime_buf;
           int _gamma_signgam;
           __extension__ unsigned long long _rand_next;
           struct _rand48 _r48;
           _mbstate_t _mblen_state;
           _mbstate_t _mbtowc_state;
           _mbstate_t _wctomb_state;
           char _l64a_buf[8];
           char _signal_buf[_REENT_SIGNAL_SIZE];
           int _getdate_err;
           _mbstate_t _mbrlen_state;
           _mbstate_t _mbrtowc_state;
           _mbstate_t _mbsrtowcs_state;
           _mbstate_t _wcrtomb_state;
           _mbstate_t _wcsrtombs_state;
         } _reent;
   /* Two next two fields were once used by malloc.  They are no longer
      used. They are used to preserve the space used before so as to
      allow addition of new reent fields and keep binary compatibility.   */
#define _N_LISTS 30
           unsigned char * _nextf[_N_LISTS];
           unsigned int _nmalloc[_N_LISTS];
         } _unused;
     } _new;

   /* atexit stuff */
   struct _atexit *_atexit;      /* points to head of LIFO stack */
   struct _atexit _atexit0;      /* one guaranteed table, required by 

   /* signal info */
   void (**(_sig_func))(int);


I'm interesting in "Two next two fields were once used by malloc. They 
are no ..." comment.

1. Does Newlib really take care about binary compatibility?
2. I want to add new fields to struct _reent. Do I need to add these 
fields to _reent field of _new union to support binary compatibility? 
May I not to care about binary compatibility and have no problems during 
future contributions to Newlib?
3. In case of REENT_SMALL defined there is no reserved space in struct 
_reent. Should I use struct misc_reent * ?

Best Regards,
Artem B. Bityuckiy,
St.-Petersburg, Russia.

More information about the Newlib mailing list