OSDN Git Service

5303ed3ddc1161488aa627883e72a37204695d1c
[pf3gnuchains/sourceware.git] / newlib / libc / include / sys / reent.h
1 /* This header file provides the reentrancy.  */
2
3 /* WARNING: All identifiers here must begin with an underscore.  This file is
4    included by stdio.h and others and we therefore must only use identifiers
5    in the namespace allotted to us.  */
6
7 #ifndef _SYS_REENT_H_
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 #define _SYS_REENT_H_
12
13 #include <_ansi.h>
14 #include <sys/_types.h>
15
16 #ifndef __Long
17 #if __LONG_MAX__ == 2147483647L
18 #define __Long long
19 typedef unsigned __Long __ULong;
20 #elif __INT_MAX__ == 2147483647
21 #define __Long int
22 typedef unsigned __Long __ULong;
23 #endif
24 #endif
25
26 #ifndef __Long
27 #define __Long __int32_t
28 typedef __uint32_t __ULong;
29 #endif
30
31 /*
32  * If _REENT_SMALL is defined, we make struct _reent as small as possible,
33  * by having nearly everything possible allocated at first use.
34  */
35
36 struct _glue 
37 {
38   struct _glue *_next;
39   int _niobs;
40   struct __sFILE *_iobs;
41 };
42
43 struct _Bigint 
44 {
45   struct _Bigint *_next;
46   int _k, _maxwds, _sign, _wds;
47   __ULong _x[1];
48 };
49
50 /* needed by reentrant structure */
51 struct __tm
52 {
53   int   __tm_sec;
54   int   __tm_min;
55   int   __tm_hour;
56   int   __tm_mday;
57   int   __tm_mon;
58   int   __tm_year;
59   int   __tm_wday;
60   int   __tm_yday;
61   int   __tm_isdst;
62 };
63
64 /*
65  * atexit() support.  For _REENT_SMALL, we limit to 32 max.
66  */
67
68 #define _ATEXIT_SIZE 32 /* must be at least 32 to guarantee ANSI conformance */
69
70 #ifndef _REENT_SMALL
71 struct _atexit {
72         struct  _atexit *_next;                 /* next in list */
73         int     _ind;                           /* next index in this table */
74         void    (*_fns[_ATEXIT_SIZE])(void);    /* the table itself */
75         void    *_fnargs[_ATEXIT_SIZE];         /* fn args for on_exit */
76         __uint32_t _fntypes;                    /* type of exit routine */
77 };
78 #else
79 struct _atexit {
80         int     _ind;                           /* next index in this table */
81         void    (*_fns[_ATEXIT_SIZE])(void);    /* the table itself */
82         void    *_fnargs[_ATEXIT_SIZE];         /* fn args for on_exit */
83         __uint32_t _fntypes;                    /* type of exit routine */
84 };
85 #endif
86
87 /*
88  * Stdio buffers.
89  *
90  * This and __sFILE are defined here because we need them for struct _reent,
91  * but we don't want stdio.h included when stdlib.h is.
92  */
93
94 struct __sbuf {
95         unsigned char *_base;
96         int     _size;
97 };
98
99 /*
100  * We need fpos_t for the following, but it doesn't have a leading "_",
101  * so we use _fpos_t instead.
102  */
103
104 typedef long _fpos_t;           /* XXX must match off_t in <sys/types.h> */
105                                 /* (and must be `long' for now) */
106
107 /*
108  * Stdio state variables.
109  *
110  * The following always hold:
111  *
112  *      if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
113  *              _lbfsize is -_bf._size, else _lbfsize is 0
114  *      if _flags&__SRD, _w is 0
115  *      if _flags&__SWR, _r is 0
116  *
117  * This ensures that the getc and putc macros (or inline functions) never
118  * try to write or read from a file that is in `read' or `write' mode.
119  * (Moreover, they can, and do, automatically switch from read mode to
120  * write mode, and back, on "r+" and "w+" files.)
121  *
122  * _lbfsize is used only to make the inline line-buffered output stream
123  * code as compact as possible.
124  *
125  * _ub, _up, and _ur are used when ungetc() pushes back more characters
126  * than fit in the current _bf, or when ungetc() pushes back a character
127  * that does not match the previous one in _bf.  When this happens,
128  * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
129  * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
130  */
131
132 #ifdef _REENT_SMALL
133 /*
134  * struct __sFILE_fake is the start of a struct __sFILE, with only the
135  * minimal fields allocated.  In __sinit() we really allocate the 3
136  * standard streams, etc., and point away from this fake.
137  */
138 struct __sFILE_fake {
139   unsigned char *_p;    /* current position in (some) buffer */
140   int   _r;             /* read space left for getc() */
141   int   _w;             /* write space left for putc() */
142   short _flags;         /* flags, below; this FILE is free if 0 */
143   short _file;          /* fileno, if Unix descriptor, else -1 */
144   struct __sbuf _bf;    /* the buffer (at least 1 byte, if !NULL) */
145   int   _lbfsize;       /* 0 or -_bf._size, for inline putc */
146
147   struct _reent *_data;
148 };
149 /* CHECK_INIT() comes from stdio/local.h; be sure to include that.  */
150 # define _REENT_SMALL_CHECK_INIT(fp) CHECK_INIT(fp)
151 #else
152 # define _REENT_SMALL_CHECK_INIT(fp) /* nothing */
153 #endif
154
155 struct __sFILE {
156   unsigned char *_p;    /* current position in (some) buffer */
157   int   _r;             /* read space left for getc() */
158   int   _w;             /* write space left for putc() */
159   short _flags;         /* flags, below; this FILE is free if 0 */
160   short _file;          /* fileno, if Unix descriptor, else -1 */
161   struct __sbuf _bf;    /* the buffer (at least 1 byte, if !NULL) */
162   int   _lbfsize;       /* 0 or -_bf._size, for inline putc */
163
164 #ifdef _REENT_SMALL
165   struct _reent *_data;
166 #endif
167
168   /* operations */
169   _PTR  _cookie;        /* cookie passed to io functions */
170
171   _READ_WRITE_RETURN_TYPE _EXFUN((*_read),(_PTR _cookie, char *_buf, int _n));
172   _READ_WRITE_RETURN_TYPE _EXFUN((*_write),(_PTR _cookie, const char *_buf,
173                                             int _n));
174   _fpos_t _EXFUN((*_seek),(_PTR _cookie, _fpos_t _offset, int _whence));
175   int   _EXFUN((*_close),(_PTR _cookie));
176
177   /* separate buffer for long sequences of ungetc() */
178   struct __sbuf _ub;    /* ungetc buffer */
179   unsigned char *_up;   /* saved _p when _p is doing ungetc data */
180   int   _ur;            /* saved _r when _r is counting ungetc data */
181
182   /* tricks to meet minimum requirements even when malloc() fails */
183   unsigned char _ubuf[3];       /* guarantee an ungetc() buffer */
184   unsigned char _nbuf[1];       /* guarantee a getc() buffer */
185
186   /* separate buffer for fgetline() when line crosses buffer boundary */
187   struct __sbuf _lb;    /* buffer for fgetline() */
188
189   /* Unix stdio files get aligned to block boundaries on fseek() */
190   int   _blksize;       /* stat.st_blksize (may be != _bf._size) */
191   int   _offset;        /* current lseek offset */
192
193 #ifndef _REENT_SMALL
194   struct _reent *_data;         /* Here for binary compatibility? Remove? */
195 #endif
196 };
197
198 /*
199  * rand48 family support
200  *
201  * Copyright (c) 1993 Martin Birgmeier
202  * All rights reserved.
203  *
204  * You may redistribute unmodified or modified versions of this source
205  * code provided that the above copyright notice and this and the
206  * following conditions are retained.
207  *
208  * This software is provided ``as is'', and comes with no warranties
209  * of any kind. I shall in no event be liable for anything that happens
210  * to anyone/anything when using this software.
211  */
212 #define        _RAND48_SEED_0  (0x330e)
213 #define        _RAND48_SEED_1  (0xabcd)
214 #define        _RAND48_SEED_2  (0x1234)
215 #define        _RAND48_MULT_0  (0xe66d)
216 #define        _RAND48_MULT_1  (0xdeec)
217 #define        _RAND48_MULT_2  (0x0005)
218 #define        _RAND48_ADD     (0x000b)
219 struct _rand48 {
220   unsigned short _seed[3];
221   unsigned short _mult[3];
222   unsigned short _add;
223 #ifdef _REENT_SMALL
224   /* Put this in here as well, for good luck.  */
225   __extension__ unsigned long long _rand_next;
226 #endif
227 };
228
229 /* How big the some arrays are.  */
230 #define _REENT_EMERGENCY_SIZE 25
231 #define _REENT_ASCTIME_SIZE 26
232
233 /*
234  * struct _reent
235  *
236  * This structure contains *all* globals needed by the library.
237  * It's raison d'etre is to facilitate threads by making all library routines
238  * reentrant.  IE: All state information is contained here.
239  */
240
241 #ifdef _REENT_SMALL
242
243 struct _mprec
244 {
245   /* used by mprec routines */
246   struct _Bigint *_result;
247   int _result_k;
248   struct _Bigint *_p5s;
249   struct _Bigint **_freelist;
250 };
251
252
253 struct _misc_reent
254 {
255   /* miscellaneous reentrant data */
256   char *_strtok_last;
257   int _mblen_state;
258   int _wctomb_state;
259   int _mbtowc_state;
260   char _l64a_buf[8];
261 };
262
263 /* This version of _reent is layed our with "int"s in pairs, to help
264  * ports with 16-bit int's but 32-bit pointers, align nicely.  */
265 struct _reent
266 {
267
268   /* FILE is a big struct and may change over time.  To try to achieve binary
269      compatibility with future versions, put stdin,stdout,stderr here.
270      These are pointers into member __sf defined below.  */
271   struct __sFILE *_stdin, *_stdout, *_stderr;   /* XXX */
272
273   int _errno;                   /* local copy of errno */
274
275   int  _inc;                    /* used by tmpnam */
276
277   char *_emergency;
278  
279   int __sdidinit;               /* 1 means stdio has been init'd */
280
281   int _current_category;        /* used by setlocale */
282   _CONST char *_current_locale;
283
284   struct _mprec *_mp;
285
286   void _EXFUN((*__cleanup),(struct _reent *));
287
288   int _gamma_signgam;
289
290   /* used by some fp conversion routines */
291   int _cvtlen;                  /* should be size_t */
292   char *_cvtbuf;
293
294   struct _rand48 *_r48;
295   struct __tm *_localtime_buf;
296   char *_asctime_buf;
297
298   /* signal info */
299   void (**(_sig_func))(int);
300
301   /* atexit stuff */
302   struct _atexit _atexit;
303
304   struct _glue __sglue;                 /* root of glue chain */
305   struct __sFILE *__sf;                 /* file descriptors */
306   struct __sFILE_fake __sf_fake;        /* fake initial stdin/out/err */
307   struct _misc_reent *_misc;            /* strtok, multibyte states */
308 };
309
310 #define _REENT_INIT(var) \
311   { (struct __sFILE *)&var.__sf_fake, (struct __sFILE *)&var.__sf_fake, \
312     (struct __sFILE *)&var.__sf_fake, 0, 0, _NULL, 0, 0, \
313     "C", _NULL, _NULL, 0, 0, _NULL, _NULL, _NULL, _NULL, _NULL, \
314     { 0, _NULL, _NULL, 0 }, { _NULL, 0, _NULL }, _NULL, 0, _NULL }
315
316 #define _REENT_INIT_PTR(var) \
317   { var->_stdin = (struct __sFILE *)&var->__sf_fake; \
318     var->_stdout = (struct __sFILE *)&var->__sf_fake; \
319     var->_stderr = (struct __sFILE *)&var->__sf_fake; \
320     var->_errno = 0; \
321     var->_inc = 0; \
322     var->_emergency = _NULL; \
323     var->__sdidinit = 0; \
324     var->_current_category = 0; \
325     var->_current_locale = "C"; \
326     var->_mp = _NULL; \
327     var->__cleanup = _NULL; \
328     var->_gamma_signgam = 0; \
329     var->_cvtlen = 0; \
330     var->_cvtbuf = _NULL; \
331     var->_r48 = _NULL; \
332     var->_localtime_buf = _NULL; \
333     var->_asctime_buf = _NULL; \
334     var->_sig_func = _NULL; \
335     var->_atexit._ind = 0; \
336     var->_atexit._fns[0] = _NULL; \
337     var->_atexit._fnargs[0] = _NULL; \
338     var->_atexit._fntypes = 0; \
339     var->__sglue._next = _NULL; \
340     var->__sglue._niobs = 0; \
341     var->__sglue._iobs = _NULL; \
342     var->__sf = 0; \
343     var->_misc = _NULL; \
344     var->__sf_fake._p = _NULL; \
345     var->__sf_fake._r = 0; \
346     var->__sf_fake._w = 0; \
347     var->__sf_fake._flags = 0; \
348     var->__sf_fake._file = 0; \
349     var->__sf_fake._lbfsize = 0; \
350     var->__sf_fake._data = _NULL; \
351   }
352
353   /* signal info */
354   void (**(_sig_func))(int);
355 /* Only built the assert() calls if we are built with debugging.  */
356 #if DEBUG 
357 #include <assert.h>
358 #else
359 #define assert(x) ((void)0)
360 #endif
361
362 /* Generic _REENT check macro.  */
363 #define _REENT_CHECK(var, what, type, size, init) do { \
364   struct _reent *_r = (var); \
365   if (_r->what == NULL) { \
366     _r->what = (type)malloc(size); \
367     assert(_r->what); \
368     init; \
369   } \
370 } while (0)
371
372 #define _REENT_CHECK_TM(var) \
373   _REENT_CHECK(var, _localtime_buf, struct __tm *, sizeof *((var)->_localtime_buf), \
374     /* nothing */)
375
376 #define _REENT_CHECK_ASCTIME_BUF(var) \
377   _REENT_CHECK(var, _asctime_buf, char *, _REENT_ASCTIME_SIZE, \
378     memset((var)->_asctime_buf, 0, _REENT_ASCTIME_SIZE))
379
380 /* Handle the dynamically allocated rand48 structure. */
381 #define _REENT_INIT_RAND48(var) do { \
382   struct _reent *_r = (var); \
383   _r->_r48->_seed[0] = _RAND48_SEED_0; \
384   _r->_r48->_seed[1] = _RAND48_SEED_1; \
385   _r->_r48->_seed[2] = _RAND48_SEED_2; \
386   _r->_r48->_mult[0] = _RAND48_MULT_0; \
387   _r->_r48->_mult[1] = _RAND48_MULT_1; \
388   _r->_r48->_mult[2] = _RAND48_MULT_2; \
389   _r->_r48->_add = _RAND48_ADD; \
390 } while (0)
391 #define _REENT_CHECK_RAND48(var) \
392   _REENT_CHECK(var, _r48, struct _rand48 *, sizeof *((var)->_r48), _REENT_INIT_RAND48((var)))
393
394 #define _REENT_INIT_MP(var) do { \
395   struct _reent *_r = (var); \
396   _r->_mp->_result_k = 0; \
397   _r->_mp->_result = _r->_mp->_p5s = _NULL; \
398   _r->_mp->_freelist = _NULL; \
399 } while (0)
400 #define _REENT_CHECK_MP(var) \
401   _REENT_CHECK(var, _mp, struct _mprec *, sizeof *((var)->_mp), _REENT_INIT_MP(var))
402
403 #define _REENT_CHECK_EMERGENCY(var) \
404   _REENT_CHECK(var, _emergency, char *, _REENT_EMERGENCY_SIZE, /* nothing */)
405
406 #define _REENT_INIT_MISC(var) do { \
407   struct _reent *_r = (var); \
408   _r->_misc->_strtok_last = _NULL; \
409   _r->_misc->_mblen_state = 0; \
410   _r->_misc->_wctomb_state = 0; \
411   _r->_misc->_mbtowc_state = 0; \
412   _r->_misc->_l64a_buf[0] = '\0'; \
413 } while (0)
414 #define _REENT_CHECK_MISC(var) \
415   _REENT_CHECK(var, _misc, struct _misc_reent *, sizeof *((var)->_misc), _REENT_INIT_MISC(var))
416
417 #define _REENT_SIGNGAM(ptr)     ((ptr)->_gamma_signgam)
418 #define _REENT_RAND_NEXT(ptr)   ((ptr)->_r48->_rand_next)
419 #define _REENT_RAND48_SEED(ptr) ((ptr)->_r48->_seed)
420 #define _REENT_RAND48_MULT(ptr) ((ptr)->_r48->_mult)
421 #define _REENT_RAND48_ADD(ptr)  ((ptr)->_r48->_add)
422 #define _REENT_MP_RESULT(ptr)   ((ptr)->_mp->_result)
423 #define _REENT_MP_RESULT_K(ptr) ((ptr)->_mp->_result_k)
424 #define _REENT_MP_P5S(ptr)      ((ptr)->_mp->_p5s)
425 #define _REENT_MP_FREELIST(ptr) ((ptr)->_mp->_freelist)
426 #define _REENT_ASCTIME_BUF(ptr) ((ptr)->_asctime_buf)
427 #define _REENT_TM(ptr)          ((ptr)->_localtime_buf)
428 #define _REENT_EMERGENCY(ptr)   ((ptr)->_emergency)
429 #define _REENT_STRTOK_LAST(ptr) ((ptr)->_misc->_strtok_last)
430 #define _REENT_MBLEN_STATE(ptr) ((ptr)->_misc->_mblen_state)
431 #define _REENT_MBTOWC_STATE(ptr)((ptr)->_misc->_mbtowc_state)
432 #define _REENT_WCTOMB_STATE(ptr)((ptr)->_misc->_wctomb_state)
433 #define _REENT_L64A_BUF(ptr)    ((ptr)->_misc->_l64a_buf)
434
435 #else /* !_REENT_SMALL */
436
437 struct _reent
438 {
439   int _errno;                   /* local copy of errno */
440
441   /* FILE is a big struct and may change over time.  To try to achieve binary
442      compatibility with future versions, put stdin,stdout,stderr here.
443      These are pointers into member __sf defined below.  */
444   struct __sFILE *_stdin, *_stdout, *_stderr;
445
446   int  _inc;                    /* used by tmpnam */
447   char _emergency[_REENT_EMERGENCY_SIZE];
448  
449   int _current_category;        /* used by setlocale */
450   _CONST char *_current_locale;
451
452   int __sdidinit;               /* 1 means stdio has been init'd */
453
454   void _EXFUN((*__cleanup),(struct _reent *));
455
456   /* used by mprec routines */
457   struct _Bigint *_result;
458   int _result_k;
459   struct _Bigint *_p5s;
460   struct _Bigint **_freelist;
461
462   /* used by some fp conversion routines */
463   int _cvtlen;                  /* should be size_t */
464   char *_cvtbuf;
465
466   union
467     {
468       struct
469         {
470           unsigned int _unused_rand;
471           char * _strtok_last;
472           char _asctime_buf[26];
473           struct __tm _localtime_buf;
474           int _gamma_signgam;
475           __extension__ unsigned long long _rand_next;
476           struct _rand48 _r48;
477           int _mblen_state;
478           int _mbtowc_state;
479           int _wctomb_state;
480           char _l64a_buf[8];
481         } _reent;
482   /* Two next two fields were once used by malloc.  They are no longer
483      used. They are used to preserve the space used before so as to
484      allow addition of new reent fields and keep binary compatibility.   */ 
485       struct
486         {
487 #define _N_LISTS 30
488           unsigned char * _nextf[_N_LISTS];
489           unsigned int _nmalloc[_N_LISTS];
490         } _unused;
491     } _new;
492
493   /* atexit stuff */
494   struct _atexit *_atexit;      /* points to head of LIFO stack */
495   struct _atexit _atexit0;      /* one guaranteed table, required by ANSI */
496
497   /* signal info */
498   void (**(_sig_func))(int);
499
500   /* These are here last so that __sFILE can grow without changing the offsets
501      of the above members (on the off chance that future binary compatibility
502      would be broken otherwise).  */
503   struct _glue __sglue;                 /* root of glue chain */
504   struct __sFILE __sf[3];               /* first three file descriptors */
505 };
506
507 #define _REENT_INIT(var) \
508   { 0, &var.__sf[0], &var.__sf[1], &var.__sf[2], 0, "", 0, "C", \
509     0, _NULL, _NULL, 0, _NULL, _NULL, 0, _NULL, { {0, _NULL, "", \
510     { 0,0,0,0,0,0,0,0}, 0, 1, \
511     {{_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, \
512      {_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, _RAND48_ADD}, \
513     0, 0, 0, ""} } }
514
515 #define _REENT_INIT_PTR(var) \
516   { int i; \
517     char *tmp_ptr; \
518     var->_errno = 0; \
519     var->_stdin = &var->__sf[0]; \
520     var->_stdout = &var->__sf[1]; \
521     var->_stderr = &var->__sf[2]; \
522     var->_inc = 0; \
523     for (i = 0; i < _REENT_EMERGENCY_SIZE; ++i) \
524       var->_emergency[i] = 0; \
525     var->_current_category = 0; \
526     var->_current_locale = "C"; \
527     var->__sdidinit = 0; \
528     var->__cleanup = _NULL; \
529     var->_result = _NULL; \
530     var->_result_k = 0; \
531     var->_p5s = _NULL; \
532     var->_freelist = _NULL; \
533     var->_cvtlen = 0; \
534     var->_cvtbuf = _NULL; \
535     var->_new._reent._unused_rand = 0; \
536     var->_new._reent._strtok_last = _NULL; \
537     var->_new._reent._asctime_buf[0] = 0; \
538     tmp_ptr = (char *)&var->_new._reent._localtime_buf; \
539     for (i = 0; i < sizeof(struct __tm); ++i) \
540       tmp_ptr[i] = 0; \
541     var->_new._reent._gamma_signgam = 0; \
542     var->_new._reent._rand_next = 1; \
543     var->_new._reent._r48._seed[0] = _RAND48_SEED_0; \
544     var->_new._reent._r48._seed[1] = _RAND48_SEED_1; \
545     var->_new._reent._r48._seed[2] = _RAND48_SEED_2; \
546     var->_new._reent._r48._mult[0] = _RAND48_MULT_0; \
547     var->_new._reent._r48._mult[1] = _RAND48_MULT_1; \
548     var->_new._reent._r48._mult[2] = _RAND48_MULT_2; \
549     var->_new._reent._r48._add = _RAND48_ADD; \
550     var->_new._reent._mblen_state = 0; \
551     var->_new._reent._mbtowc_state = 0; \
552     var->_new._reent._wctomb_state = 0; \
553     var->_new._reent._l64a_buf[0] = '\0'; \
554     var->_atexit = _NULL; \
555     var->_atexit0._ind = 0; \
556     var->_atexit0._fns[0] = _NULL; \
557     var->_atexit0._fntypes = 0; \
558     var->_sig_func = _NULL; \
559     var->__sglue._next = _NULL; \
560     var->__sglue._niobs = 0; \
561     var->__sglue._iobs = _NULL; \
562     memset(var->__sf,0,sizeof(var->__sf)); \
563   }
564
565 #define _REENT_CHECK_RAND48(ptr)        /* nothing */
566 #define _REENT_CHECK_MP(ptr)            /* nothing */
567 #define _REENT_CHECK_TM(ptr)            /* nothing */
568 #define _REENT_CHECK_ASCTIME_BUF(ptr)   /* nothing */
569 #define _REENT_CHECK_EMERGENCY(ptr)     /* nothing */
570 #define _REENT_CHECK_MISC(ptr)          /* nothing */
571
572 #define _REENT_SIGNGAM(ptr)     ((ptr)->_new._reent._gamma_signgam)
573 #define _REENT_RAND_NEXT(ptr)   ((ptr)->_new._reent._rand_next)
574 #define _REENT_RAND48_SEED(ptr) ((ptr)->_new._reent._r48._seed)
575 #define _REENT_RAND48_MULT(ptr) ((ptr)->_new._reent._r48._mult)
576 #define _REENT_RAND48_ADD(ptr)  ((ptr)->_new._reent._r48._add)
577 #define _REENT_MP_RESULT(ptr)   ((ptr)->_result)
578 #define _REENT_MP_RESULT_K(ptr) ((ptr)->_result_k)
579 #define _REENT_MP_P5S(ptr)      ((ptr)->_p5s)
580 #define _REENT_MP_FREELIST(ptr) ((ptr)->_freelist)
581 #define _REENT_ASCTIME_BUF(ptr) (&(ptr)->_new._reent._asctime_buf)
582 #define _REENT_TM(ptr)          (&(ptr)->_new._reent._localtime_buf)
583 #define _REENT_EMERGENCY(ptr)   ((ptr)->_emergency)
584 #define _REENT_STRTOK_LAST(ptr) ((ptr)->_new._reent._strtok_last)
585 #define _REENT_MBLEN_STATE(ptr) ((ptr)->_new._reent._mblen_state)
586 #define _REENT_MBTOWC_STATE(ptr)((ptr)->_new._reent._mbtowc_state)
587 #define _REENT_WCTOMB_STATE(ptr)((ptr)->_new._reent._wctomb_state)
588 #define _REENT_L64A_BUF(ptr)    ((ptr)->_new._reent._l64a_buf)
589
590 #endif /* !_REENT_SMALL */
591
592 #define _NULL 0
593
594 /*
595  * All references to struct _reent are via this pointer.
596  * Internally, newlib routines that need to reference it should use _REENT.
597  */
598
599 #ifndef __ATTRIBUTE_IMPURE_PTR__
600 #define __ATTRIBUTE_IMPURE_PTR__
601 #endif
602
603 extern struct _reent *_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
604
605 void _reclaim_reent _PARAMS ((struct _reent *));
606
607 /* #define _REENT_ONLY define this to get only reentrant routines */
608
609 #ifndef _REENT_ONLY
610 #define _REENT _impure_ptr
611 #endif /* !_REENT_ONLY */
612
613 #ifdef __cplusplus
614 }
615 #endif
616 #endif /* _SYS_REENT_H_ */