1 |
207 |
jeremybenn |
/* 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 |
|
|
#define _NULL 0
|
17 |
|
|
|
18 |
|
|
#ifndef __Long
|
19 |
|
|
#if __LONG_MAX__ == 2147483647L
|
20 |
|
|
#define __Long long
|
21 |
|
|
typedef unsigned __Long __ULong;
|
22 |
|
|
#elif __INT_MAX__ == 2147483647
|
23 |
|
|
#define __Long int
|
24 |
|
|
typedef unsigned __Long __ULong;
|
25 |
|
|
#endif
|
26 |
|
|
#endif
|
27 |
|
|
|
28 |
|
|
#if !defined( __Long)
|
29 |
|
|
#include <sys/types.h>
|
30 |
|
|
#endif
|
31 |
|
|
|
32 |
|
|
#ifndef __Long
|
33 |
|
|
#define __Long __int32_t
|
34 |
|
|
typedef __uint32_t __ULong;
|
35 |
|
|
#endif
|
36 |
|
|
|
37 |
|
|
struct _reent;
|
38 |
|
|
|
39 |
|
|
/*
|
40 |
|
|
* If _REENT_SMALL is defined, we make struct _reent as small as possible,
|
41 |
|
|
* by having nearly everything possible allocated at first use.
|
42 |
|
|
*/
|
43 |
|
|
|
44 |
|
|
struct _Bigint
|
45 |
|
|
{
|
46 |
|
|
struct _Bigint *_next;
|
47 |
|
|
int _k, _maxwds, _sign, _wds;
|
48 |
|
|
__ULong _x[1];
|
49 |
|
|
};
|
50 |
|
|
|
51 |
|
|
/* needed by reentrant structure */
|
52 |
|
|
struct __tm
|
53 |
|
|
{
|
54 |
|
|
int __tm_sec;
|
55 |
|
|
int __tm_min;
|
56 |
|
|
int __tm_hour;
|
57 |
|
|
int __tm_mday;
|
58 |
|
|
int __tm_mon;
|
59 |
|
|
int __tm_year;
|
60 |
|
|
int __tm_wday;
|
61 |
|
|
int __tm_yday;
|
62 |
|
|
int __tm_isdst;
|
63 |
|
|
};
|
64 |
|
|
|
65 |
|
|
/*
|
66 |
|
|
* atexit() support.
|
67 |
|
|
*/
|
68 |
|
|
|
69 |
|
|
#define _ATEXIT_SIZE 32 /* must be at least 32 to guarantee ANSI conformance */
|
70 |
|
|
|
71 |
|
|
struct _on_exit_args {
|
72 |
|
|
void * _fnargs[_ATEXIT_SIZE]; /* user fn args */
|
73 |
|
|
void * _dso_handle[_ATEXIT_SIZE];
|
74 |
|
|
/* Bitmask is set if user function takes arguments. */
|
75 |
|
|
__ULong _fntypes; /* type of exit routine -
|
76 |
|
|
Must have at least _ATEXIT_SIZE bits */
|
77 |
|
|
/* Bitmask is set if function was registered via __cxa_atexit. */
|
78 |
|
|
__ULong _is_cxa;
|
79 |
|
|
};
|
80 |
|
|
|
81 |
|
|
#ifdef _REENT_SMALL
|
82 |
|
|
struct _atexit {
|
83 |
|
|
struct _atexit *_next; /* next in list */
|
84 |
|
|
int _ind; /* next index in this table */
|
85 |
|
|
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */
|
86 |
|
|
struct _on_exit_args * _on_exit_args_ptr;
|
87 |
|
|
};
|
88 |
|
|
#else
|
89 |
|
|
struct _atexit {
|
90 |
|
|
struct _atexit *_next; /* next in list */
|
91 |
|
|
int _ind; /* next index in this table */
|
92 |
|
|
/* Some entries may already have been called, and will be NULL. */
|
93 |
|
|
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */
|
94 |
|
|
struct _on_exit_args _on_exit_args;
|
95 |
|
|
};
|
96 |
|
|
#endif
|
97 |
|
|
|
98 |
|
|
/*
|
99 |
|
|
* Stdio buffers.
|
100 |
|
|
*
|
101 |
|
|
* This and __FILE are defined here because we need them for struct _reent,
|
102 |
|
|
* but we don't want stdio.h included when stdlib.h is.
|
103 |
|
|
*/
|
104 |
|
|
|
105 |
|
|
struct __sbuf {
|
106 |
|
|
unsigned char *_base;
|
107 |
|
|
int _size;
|
108 |
|
|
};
|
109 |
|
|
|
110 |
|
|
/*
|
111 |
|
|
* Stdio state variables.
|
112 |
|
|
*
|
113 |
|
|
* The following always hold:
|
114 |
|
|
*
|
115 |
|
|
* if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
|
116 |
|
|
* _lbfsize is -_bf._size, else _lbfsize is 0
|
117 |
|
|
* if _flags&__SRD, _w is 0
|
118 |
|
|
* if _flags&__SWR, _r is 0
|
119 |
|
|
*
|
120 |
|
|
* This ensures that the getc and putc macros (or inline functions) never
|
121 |
|
|
* try to write or read from a file that is in `read' or `write' mode.
|
122 |
|
|
* (Moreover, they can, and do, automatically switch from read mode to
|
123 |
|
|
* write mode, and back, on "r+" and "w+" files.)
|
124 |
|
|
*
|
125 |
|
|
* _lbfsize is used only to make the inline line-buffered output stream
|
126 |
|
|
* code as compact as possible.
|
127 |
|
|
*
|
128 |
|
|
* _ub, _up, and _ur are used when ungetc() pushes back more characters
|
129 |
|
|
* than fit in the current _bf, or when ungetc() pushes back a character
|
130 |
|
|
* that does not match the previous one in _bf. When this happens,
|
131 |
|
|
* _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
|
132 |
|
|
* _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
|
133 |
|
|
*/
|
134 |
|
|
|
135 |
|
|
#ifdef _REENT_SMALL
|
136 |
|
|
/*
|
137 |
|
|
* struct __sFILE_fake is the start of a struct __sFILE, with only the
|
138 |
|
|
* minimal fields allocated. In __sinit() we really allocate the 3
|
139 |
|
|
* standard streams, etc., and point away from this fake.
|
140 |
|
|
*/
|
141 |
|
|
struct __sFILE_fake {
|
142 |
|
|
unsigned char *_p; /* current position in (some) buffer */
|
143 |
|
|
int _r; /* read space left for getc() */
|
144 |
|
|
int _w; /* write space left for putc() */
|
145 |
|
|
short _flags; /* flags, below; this FILE is free if 0 */
|
146 |
|
|
short _file; /* fileno, if Unix descriptor, else -1 */
|
147 |
|
|
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
|
148 |
|
|
int _lbfsize; /* 0 or -_bf._size, for inline putc */
|
149 |
|
|
|
150 |
|
|
struct _reent *_data;
|
151 |
|
|
};
|
152 |
|
|
|
153 |
|
|
/* Following is needed both in libc/stdio and libc/stdlib so we put it
|
154 |
|
|
* here instead of libc/stdio/local.h where it was previously. */
|
155 |
|
|
|
156 |
|
|
extern _VOID _EXFUN(__sinit,(struct _reent *));
|
157 |
|
|
|
158 |
|
|
# define _REENT_SMALL_CHECK_INIT(ptr) \
|
159 |
|
|
do \
|
160 |
|
|
{ \
|
161 |
|
|
if ((ptr) && !(ptr)->__sdidinit) \
|
162 |
|
|
__sinit (ptr); \
|
163 |
|
|
} \
|
164 |
|
|
while (0)
|
165 |
|
|
#else
|
166 |
|
|
# define _REENT_SMALL_CHECK_INIT(ptr) /* nothing */
|
167 |
|
|
#endif
|
168 |
|
|
|
169 |
|
|
struct __sFILE {
|
170 |
|
|
unsigned char *_p; /* current position in (some) buffer */
|
171 |
|
|
int _r; /* read space left for getc() */
|
172 |
|
|
int _w; /* write space left for putc() */
|
173 |
|
|
short _flags; /* flags, below; this FILE is free if 0 */
|
174 |
|
|
short _file; /* fileno, if Unix descriptor, else -1 */
|
175 |
|
|
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
|
176 |
|
|
int _lbfsize; /* 0 or -_bf._size, for inline putc */
|
177 |
|
|
|
178 |
|
|
#ifdef _REENT_SMALL
|
179 |
|
|
struct _reent *_data;
|
180 |
|
|
#endif
|
181 |
|
|
|
182 |
|
|
/* operations */
|
183 |
|
|
_PTR _cookie; /* cookie passed to io functions */
|
184 |
|
|
|
185 |
|
|
_READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR,
|
186 |
|
|
char *, int));
|
187 |
|
|
_READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR,
|
188 |
|
|
const char *, int));
|
189 |
|
|
_fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int));
|
190 |
|
|
int _EXFNPTR(_close, (struct _reent *, _PTR));
|
191 |
|
|
|
192 |
|
|
/* separate buffer for long sequences of ungetc() */
|
193 |
|
|
struct __sbuf _ub; /* ungetc buffer */
|
194 |
|
|
unsigned char *_up; /* saved _p when _p is doing ungetc data */
|
195 |
|
|
int _ur; /* saved _r when _r is counting ungetc data */
|
196 |
|
|
|
197 |
|
|
/* tricks to meet minimum requirements even when malloc() fails */
|
198 |
|
|
unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
|
199 |
|
|
unsigned char _nbuf[1]; /* guarantee a getc() buffer */
|
200 |
|
|
|
201 |
|
|
/* separate buffer for fgetline() when line crosses buffer boundary */
|
202 |
|
|
struct __sbuf _lb; /* buffer for fgetline() */
|
203 |
|
|
|
204 |
|
|
/* Unix stdio files get aligned to block boundaries on fseek() */
|
205 |
|
|
int _blksize; /* stat.st_blksize (may be != _bf._size) */
|
206 |
|
|
int _offset; /* current lseek offset */
|
207 |
|
|
|
208 |
|
|
#ifndef _REENT_SMALL
|
209 |
|
|
struct _reent *_data; /* Here for binary compatibility? Remove? */
|
210 |
|
|
#endif
|
211 |
|
|
|
212 |
|
|
#ifndef __SINGLE_THREAD__
|
213 |
|
|
_flock_t _lock; /* for thread-safety locking */
|
214 |
|
|
#endif
|
215 |
|
|
_mbstate_t _mbstate; /* for wide char stdio functions. */
|
216 |
|
|
int _flags2; /* for future use */
|
217 |
|
|
};
|
218 |
|
|
|
219 |
|
|
#ifdef __CUSTOM_FILE_IO__
|
220 |
|
|
|
221 |
|
|
/* Get custom _FILE definition. */
|
222 |
|
|
#include <sys/custom_file.h>
|
223 |
|
|
|
224 |
|
|
#else /* !__CUSTOM_FILE_IO__ */
|
225 |
|
|
#ifdef __LARGE64_FILES
|
226 |
|
|
struct __sFILE64 {
|
227 |
|
|
unsigned char *_p; /* current position in (some) buffer */
|
228 |
|
|
int _r; /* read space left for getc() */
|
229 |
|
|
int _w; /* write space left for putc() */
|
230 |
|
|
short _flags; /* flags, below; this FILE is free if 0 */
|
231 |
|
|
short _file; /* fileno, if Unix descriptor, else -1 */
|
232 |
|
|
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
|
233 |
|
|
int _lbfsize; /* 0 or -_bf._size, for inline putc */
|
234 |
|
|
|
235 |
|
|
struct _reent *_data;
|
236 |
|
|
|
237 |
|
|
/* operations */
|
238 |
|
|
_PTR _cookie; /* cookie passed to io functions */
|
239 |
|
|
|
240 |
|
|
_READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR,
|
241 |
|
|
char *, int));
|
242 |
|
|
_READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR,
|
243 |
|
|
const char *, int));
|
244 |
|
|
_fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int));
|
245 |
|
|
int _EXFNPTR(_close, (struct _reent *, _PTR));
|
246 |
|
|
|
247 |
|
|
/* separate buffer for long sequences of ungetc() */
|
248 |
|
|
struct __sbuf _ub; /* ungetc buffer */
|
249 |
|
|
unsigned char *_up; /* saved _p when _p is doing ungetc data */
|
250 |
|
|
int _ur; /* saved _r when _r is counting ungetc data */
|
251 |
|
|
|
252 |
|
|
/* tricks to meet minimum requirements even when malloc() fails */
|
253 |
|
|
unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
|
254 |
|
|
unsigned char _nbuf[1]; /* guarantee a getc() buffer */
|
255 |
|
|
|
256 |
|
|
/* separate buffer for fgetline() when line crosses buffer boundary */
|
257 |
|
|
struct __sbuf _lb; /* buffer for fgetline() */
|
258 |
|
|
|
259 |
|
|
/* Unix stdio files get aligned to block boundaries on fseek() */
|
260 |
|
|
int _blksize; /* stat.st_blksize (may be != _bf._size) */
|
261 |
|
|
int _flags2; /* for future use */
|
262 |
|
|
|
263 |
|
|
_off64_t _offset; /* current lseek offset */
|
264 |
|
|
_fpos64_t _EXFNPTR(_seek64, (struct _reent *, _PTR, _fpos64_t, int));
|
265 |
|
|
|
266 |
|
|
#ifndef __SINGLE_THREAD__
|
267 |
|
|
_flock_t _lock; /* for thread-safety locking */
|
268 |
|
|
#endif
|
269 |
|
|
_mbstate_t _mbstate; /* for wide char stdio functions. */
|
270 |
|
|
};
|
271 |
|
|
typedef struct __sFILE64 __FILE;
|
272 |
|
|
#else
|
273 |
|
|
typedef struct __sFILE __FILE;
|
274 |
|
|
#endif /* __LARGE64_FILES */
|
275 |
|
|
#endif /* !__CUSTOM_FILE_IO__ */
|
276 |
|
|
|
277 |
|
|
struct _glue
|
278 |
|
|
{
|
279 |
|
|
struct _glue *_next;
|
280 |
|
|
int _niobs;
|
281 |
|
|
__FILE *_iobs;
|
282 |
|
|
};
|
283 |
|
|
|
284 |
|
|
/*
|
285 |
|
|
* rand48 family support
|
286 |
|
|
*
|
287 |
|
|
* Copyright (c) 1993 Martin Birgmeier
|
288 |
|
|
* All rights reserved.
|
289 |
|
|
*
|
290 |
|
|
* You may redistribute unmodified or modified versions of this source
|
291 |
|
|
* code provided that the above copyright notice and this and the
|
292 |
|
|
* following conditions are retained.
|
293 |
|
|
*
|
294 |
|
|
* This software is provided ``as is'', and comes with no warranties
|
295 |
|
|
* of any kind. I shall in no event be liable for anything that happens
|
296 |
|
|
* to anyone/anything when using this software.
|
297 |
|
|
*/
|
298 |
|
|
#define _RAND48_SEED_0 (0x330e)
|
299 |
|
|
#define _RAND48_SEED_1 (0xabcd)
|
300 |
|
|
#define _RAND48_SEED_2 (0x1234)
|
301 |
|
|
#define _RAND48_MULT_0 (0xe66d)
|
302 |
|
|
#define _RAND48_MULT_1 (0xdeec)
|
303 |
|
|
#define _RAND48_MULT_2 (0x0005)
|
304 |
|
|
#define _RAND48_ADD (0x000b)
|
305 |
|
|
struct _rand48 {
|
306 |
|
|
unsigned short _seed[3];
|
307 |
|
|
unsigned short _mult[3];
|
308 |
|
|
unsigned short _add;
|
309 |
|
|
#ifdef _REENT_SMALL
|
310 |
|
|
/* Put this in here as well, for good luck. */
|
311 |
|
|
__extension__ unsigned long long _rand_next;
|
312 |
|
|
#endif
|
313 |
|
|
};
|
314 |
|
|
|
315 |
|
|
/* How big the some arrays are. */
|
316 |
|
|
#define _REENT_EMERGENCY_SIZE 25
|
317 |
|
|
#define _REENT_ASCTIME_SIZE 26
|
318 |
|
|
#define _REENT_SIGNAL_SIZE 24
|
319 |
|
|
|
320 |
|
|
/*
|
321 |
|
|
* struct _reent
|
322 |
|
|
*
|
323 |
|
|
* This structure contains *all* globals needed by the library.
|
324 |
|
|
* It's raison d'etre is to facilitate threads by making all library routines
|
325 |
|
|
* reentrant. IE: All state information is contained here.
|
326 |
|
|
*/
|
327 |
|
|
|
328 |
|
|
#ifdef _REENT_SMALL
|
329 |
|
|
|
330 |
|
|
struct _mprec
|
331 |
|
|
{
|
332 |
|
|
/* used by mprec routines */
|
333 |
|
|
struct _Bigint *_result;
|
334 |
|
|
int _result_k;
|
335 |
|
|
struct _Bigint *_p5s;
|
336 |
|
|
struct _Bigint **_freelist;
|
337 |
|
|
};
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
struct _misc_reent
|
341 |
|
|
{
|
342 |
|
|
/* miscellaneous reentrant data */
|
343 |
|
|
char *_strtok_last;
|
344 |
|
|
_mbstate_t _mblen_state;
|
345 |
|
|
_mbstate_t _wctomb_state;
|
346 |
|
|
_mbstate_t _mbtowc_state;
|
347 |
|
|
char _l64a_buf[8];
|
348 |
|
|
int _getdate_err;
|
349 |
|
|
_mbstate_t _mbrlen_state;
|
350 |
|
|
_mbstate_t _mbrtowc_state;
|
351 |
|
|
_mbstate_t _mbsrtowcs_state;
|
352 |
|
|
_mbstate_t _wcrtomb_state;
|
353 |
|
|
_mbstate_t _wcsrtombs_state;
|
354 |
|
|
};
|
355 |
|
|
|
356 |
|
|
/* This version of _reent is layed our with "int"s in pairs, to help
|
357 |
|
|
* ports with 16-bit int's but 32-bit pointers, align nicely. */
|
358 |
|
|
struct _reent
|
359 |
|
|
{
|
360 |
|
|
|
361 |
|
|
/* FILE is a big struct and may change over time. To try to achieve binary
|
362 |
|
|
compatibility with future versions, put stdin,stdout,stderr here.
|
363 |
|
|
These are pointers into member __sf defined below. */
|
364 |
|
|
__FILE *_stdin, *_stdout, *_stderr; /* XXX */
|
365 |
|
|
|
366 |
|
|
int _errno; /* local copy of errno */
|
367 |
|
|
|
368 |
|
|
int _inc; /* used by tmpnam */
|
369 |
|
|
|
370 |
|
|
char *_emergency;
|
371 |
|
|
|
372 |
|
|
int __sdidinit; /* 1 means stdio has been init'd */
|
373 |
|
|
|
374 |
|
|
int _current_category; /* unused */
|
375 |
|
|
_CONST char *_current_locale; /* unused */
|
376 |
|
|
|
377 |
|
|
struct _mprec *_mp;
|
378 |
|
|
|
379 |
|
|
void _EXFNPTR(__cleanup, (struct _reent *));
|
380 |
|
|
|
381 |
|
|
int _gamma_signgam;
|
382 |
|
|
|
383 |
|
|
/* used by some fp conversion routines */
|
384 |
|
|
int _cvtlen; /* should be size_t */
|
385 |
|
|
char *_cvtbuf;
|
386 |
|
|
|
387 |
|
|
struct _rand48 *_r48;
|
388 |
|
|
struct __tm *_localtime_buf;
|
389 |
|
|
char *_asctime_buf;
|
390 |
|
|
|
391 |
|
|
/* signal info */
|
392 |
|
|
void (**(_sig_func))(int);
|
393 |
|
|
|
394 |
|
|
/* atexit stuff */
|
395 |
|
|
struct _atexit *_atexit;
|
396 |
|
|
struct _atexit _atexit0;
|
397 |
|
|
|
398 |
|
|
struct _glue __sglue; /* root of glue chain */
|
399 |
|
|
__FILE *__sf; /* file descriptors */
|
400 |
|
|
struct _misc_reent *_misc; /* strtok, multibyte states */
|
401 |
|
|
char *_signal_buf; /* strsignal */
|
402 |
|
|
};
|
403 |
|
|
|
404 |
|
|
extern const struct __sFILE_fake __sf_fake_stdin;
|
405 |
|
|
extern const struct __sFILE_fake __sf_fake_stdout;
|
406 |
|
|
extern const struct __sFILE_fake __sf_fake_stderr;
|
407 |
|
|
|
408 |
|
|
#define _REENT_INIT(var) \
|
409 |
|
|
{ (__FILE *)&__sf_fake_stdin, \
|
410 |
|
|
(__FILE *)&__sf_fake_stdout, \
|
411 |
|
|
(__FILE *)&__sf_fake_stderr, \
|
412 |
|
|
0, \
|
413 |
|
|
0, \
|
414 |
|
|
_NULL, \
|
415 |
|
|
0, \
|
416 |
|
|
0, \
|
417 |
|
|
"C", \
|
418 |
|
|
_NULL, \
|
419 |
|
|
_NULL, \
|
420 |
|
|
0, \
|
421 |
|
|
0, \
|
422 |
|
|
_NULL, \
|
423 |
|
|
_NULL, \
|
424 |
|
|
_NULL, \
|
425 |
|
|
_NULL, \
|
426 |
|
|
_NULL, \
|
427 |
|
|
_NULL, \
|
428 |
|
|
{_NULL, 0, {_NULL}, _NULL}, \
|
429 |
|
|
{_NULL, 0, _NULL}, \
|
430 |
|
|
_NULL, \
|
431 |
|
|
_NULL, \
|
432 |
|
|
_NULL \
|
433 |
|
|
}
|
434 |
|
|
|
435 |
|
|
#define _REENT_INIT_PTR(var) \
|
436 |
|
|
{ (var)->_stdin = (__FILE *)&__sf_fake_stdin; \
|
437 |
|
|
(var)->_stdout = (__FILE *)&__sf_fake_stdout; \
|
438 |
|
|
(var)->_stderr = (__FILE *)&__sf_fake_stderr; \
|
439 |
|
|
(var)->_errno = 0; \
|
440 |
|
|
(var)->_inc = 0; \
|
441 |
|
|
(var)->_emergency = _NULL; \
|
442 |
|
|
(var)->__sdidinit = 0; \
|
443 |
|
|
(var)->_current_category = 0; \
|
444 |
|
|
(var)->_current_locale = "C"; \
|
445 |
|
|
(var)->_mp = _NULL; \
|
446 |
|
|
(var)->__cleanup = _NULL; \
|
447 |
|
|
(var)->_gamma_signgam = 0; \
|
448 |
|
|
(var)->_cvtlen = 0; \
|
449 |
|
|
(var)->_cvtbuf = _NULL; \
|
450 |
|
|
(var)->_r48 = _NULL; \
|
451 |
|
|
(var)->_localtime_buf = _NULL; \
|
452 |
|
|
(var)->_asctime_buf = _NULL; \
|
453 |
|
|
(var)->_sig_func = _NULL; \
|
454 |
|
|
(var)->_atexit = _NULL; \
|
455 |
|
|
(var)->_atexit0._next = _NULL; \
|
456 |
|
|
(var)->_atexit0._ind = 0; \
|
457 |
|
|
(var)->_atexit0._fns[0] = _NULL; \
|
458 |
|
|
(var)->_atexit0._on_exit_args_ptr = _NULL; \
|
459 |
|
|
(var)->__sglue._next = _NULL; \
|
460 |
|
|
(var)->__sglue._niobs = 0; \
|
461 |
|
|
(var)->__sglue._iobs = _NULL; \
|
462 |
|
|
(var)->__sf = 0; \
|
463 |
|
|
(var)->_misc = _NULL; \
|
464 |
|
|
(var)->_signal_buf = _NULL; \
|
465 |
|
|
}
|
466 |
|
|
|
467 |
|
|
/* Only built the assert() calls if we are built with debugging. */
|
468 |
|
|
#if DEBUG
|
469 |
|
|
#include <assert.h>
|
470 |
|
|
#define __reent_assert(x) assert(x)
|
471 |
|
|
#else
|
472 |
|
|
#define __reent_assert(x) ((void)0)
|
473 |
|
|
#endif
|
474 |
|
|
|
475 |
|
|
#ifdef __CUSTOM_FILE_IO__
|
476 |
|
|
#error Custom FILE I/O and _REENT_SMALL not currently supported.
|
477 |
|
|
#endif
|
478 |
|
|
|
479 |
|
|
/* Generic _REENT check macro. */
|
480 |
|
|
#define _REENT_CHECK(var, what, type, size, init) do { \
|
481 |
|
|
struct _reent *_r = (var); \
|
482 |
|
|
if (_r->what == NULL) { \
|
483 |
|
|
_r->what = (type)malloc(size); \
|
484 |
|
|
__reent_assert(_r->what); \
|
485 |
|
|
init; \
|
486 |
|
|
} \
|
487 |
|
|
} while (0)
|
488 |
|
|
|
489 |
|
|
#define _REENT_CHECK_TM(var) \
|
490 |
|
|
_REENT_CHECK(var, _localtime_buf, struct __tm *, sizeof *((var)->_localtime_buf), \
|
491 |
|
|
/* nothing */)
|
492 |
|
|
|
493 |
|
|
#define _REENT_CHECK_ASCTIME_BUF(var) \
|
494 |
|
|
_REENT_CHECK(var, _asctime_buf, char *, _REENT_ASCTIME_SIZE, \
|
495 |
|
|
memset((var)->_asctime_buf, 0, _REENT_ASCTIME_SIZE))
|
496 |
|
|
|
497 |
|
|
/* Handle the dynamically allocated rand48 structure. */
|
498 |
|
|
#define _REENT_INIT_RAND48(var) do { \
|
499 |
|
|
struct _reent *_r = (var); \
|
500 |
|
|
_r->_r48->_seed[0] = _RAND48_SEED_0; \
|
501 |
|
|
_r->_r48->_seed[1] = _RAND48_SEED_1; \
|
502 |
|
|
_r->_r48->_seed[2] = _RAND48_SEED_2; \
|
503 |
|
|
_r->_r48->_mult[0] = _RAND48_MULT_0; \
|
504 |
|
|
_r->_r48->_mult[1] = _RAND48_MULT_1; \
|
505 |
|
|
_r->_r48->_mult[2] = _RAND48_MULT_2; \
|
506 |
|
|
_r->_r48->_add = _RAND48_ADD; \
|
507 |
|
|
_r->_r48->_rand_next = 1; \
|
508 |
|
|
} while (0)
|
509 |
|
|
#define _REENT_CHECK_RAND48(var) \
|
510 |
|
|
_REENT_CHECK(var, _r48, struct _rand48 *, sizeof *((var)->_r48), _REENT_INIT_RAND48((var)))
|
511 |
|
|
|
512 |
|
|
#define _REENT_INIT_MP(var) do { \
|
513 |
|
|
struct _reent *_r = (var); \
|
514 |
|
|
_r->_mp->_result_k = 0; \
|
515 |
|
|
_r->_mp->_result = _r->_mp->_p5s = _NULL; \
|
516 |
|
|
_r->_mp->_freelist = _NULL; \
|
517 |
|
|
} while (0)
|
518 |
|
|
#define _REENT_CHECK_MP(var) \
|
519 |
|
|
_REENT_CHECK(var, _mp, struct _mprec *, sizeof *((var)->_mp), _REENT_INIT_MP(var))
|
520 |
|
|
|
521 |
|
|
#define _REENT_CHECK_EMERGENCY(var) \
|
522 |
|
|
_REENT_CHECK(var, _emergency, char *, _REENT_EMERGENCY_SIZE, /* nothing */)
|
523 |
|
|
|
524 |
|
|
#define _REENT_INIT_MISC(var) do { \
|
525 |
|
|
struct _reent *_r = (var); \
|
526 |
|
|
_r->_misc->_strtok_last = _NULL; \
|
527 |
|
|
_r->_misc->_mblen_state.__count = 0; \
|
528 |
|
|
_r->_misc->_mblen_state.__value.__wch = 0; \
|
529 |
|
|
_r->_misc->_wctomb_state.__count = 0; \
|
530 |
|
|
_r->_misc->_wctomb_state.__value.__wch = 0; \
|
531 |
|
|
_r->_misc->_mbtowc_state.__count = 0; \
|
532 |
|
|
_r->_misc->_mbtowc_state.__value.__wch = 0; \
|
533 |
|
|
_r->_misc->_mbrlen_state.__count = 0; \
|
534 |
|
|
_r->_misc->_mbrlen_state.__value.__wch = 0; \
|
535 |
|
|
_r->_misc->_mbrtowc_state.__count = 0; \
|
536 |
|
|
_r->_misc->_mbrtowc_state.__value.__wch = 0; \
|
537 |
|
|
_r->_misc->_mbsrtowcs_state.__count = 0; \
|
538 |
|
|
_r->_misc->_mbsrtowcs_state.__value.__wch = 0; \
|
539 |
|
|
_r->_misc->_wcrtomb_state.__count = 0; \
|
540 |
|
|
_r->_misc->_wcrtomb_state.__value.__wch = 0; \
|
541 |
|
|
_r->_misc->_wcsrtombs_state.__count = 0; \
|
542 |
|
|
_r->_misc->_wcsrtombs_state.__value.__wch = 0; \
|
543 |
|
|
_r->_misc->_l64a_buf[0] = '\0'; \
|
544 |
|
|
_r->_misc->_getdate_err = 0; \
|
545 |
|
|
} while (0)
|
546 |
|
|
#define _REENT_CHECK_MISC(var) \
|
547 |
|
|
_REENT_CHECK(var, _misc, struct _misc_reent *, sizeof *((var)->_misc), _REENT_INIT_MISC(var))
|
548 |
|
|
|
549 |
|
|
#define _REENT_CHECK_SIGNAL_BUF(var) \
|
550 |
|
|
_REENT_CHECK(var, _signal_buf, char *, _REENT_SIGNAL_SIZE, /* nothing */)
|
551 |
|
|
|
552 |
|
|
#define _REENT_SIGNGAM(ptr) ((ptr)->_gamma_signgam)
|
553 |
|
|
#define _REENT_RAND_NEXT(ptr) ((ptr)->_r48->_rand_next)
|
554 |
|
|
#define _REENT_RAND48_SEED(ptr) ((ptr)->_r48->_seed)
|
555 |
|
|
#define _REENT_RAND48_MULT(ptr) ((ptr)->_r48->_mult)
|
556 |
|
|
#define _REENT_RAND48_ADD(ptr) ((ptr)->_r48->_add)
|
557 |
|
|
#define _REENT_MP_RESULT(ptr) ((ptr)->_mp->_result)
|
558 |
|
|
#define _REENT_MP_RESULT_K(ptr) ((ptr)->_mp->_result_k)
|
559 |
|
|
#define _REENT_MP_P5S(ptr) ((ptr)->_mp->_p5s)
|
560 |
|
|
#define _REENT_MP_FREELIST(ptr) ((ptr)->_mp->_freelist)
|
561 |
|
|
#define _REENT_ASCTIME_BUF(ptr) ((ptr)->_asctime_buf)
|
562 |
|
|
#define _REENT_TM(ptr) ((ptr)->_localtime_buf)
|
563 |
|
|
#define _REENT_EMERGENCY(ptr) ((ptr)->_emergency)
|
564 |
|
|
#define _REENT_STRTOK_LAST(ptr) ((ptr)->_misc->_strtok_last)
|
565 |
|
|
#define _REENT_MBLEN_STATE(ptr) ((ptr)->_misc->_mblen_state)
|
566 |
|
|
#define _REENT_MBTOWC_STATE(ptr)((ptr)->_misc->_mbtowc_state)
|
567 |
|
|
#define _REENT_WCTOMB_STATE(ptr)((ptr)->_misc->_wctomb_state)
|
568 |
|
|
#define _REENT_MBRLEN_STATE(ptr) ((ptr)->_misc->_mbrlen_state)
|
569 |
|
|
#define _REENT_MBRTOWC_STATE(ptr) ((ptr)->_misc->_mbrtowc_state)
|
570 |
|
|
#define _REENT_MBSRTOWCS_STATE(ptr) ((ptr)->_misc->_mbsrtowcs_state)
|
571 |
|
|
#define _REENT_WCRTOMB_STATE(ptr) ((ptr)->_misc->_wcrtomb_state)
|
572 |
|
|
#define _REENT_WCSRTOMBS_STATE(ptr) ((ptr)->_misc->_wcsrtombs_state)
|
573 |
|
|
#define _REENT_L64A_BUF(ptr) ((ptr)->_misc->_l64a_buf)
|
574 |
|
|
#define _REENT_GETDATE_ERR_P(ptr) (&((ptr)->_misc->_getdate_err))
|
575 |
|
|
#define _REENT_SIGNAL_BUF(ptr) ((ptr)->_signal_buf)
|
576 |
|
|
|
577 |
|
|
#else /* !_REENT_SMALL */
|
578 |
|
|
|
579 |
|
|
struct _reent
|
580 |
|
|
{
|
581 |
|
|
int _errno; /* local copy of errno */
|
582 |
|
|
|
583 |
|
|
/* FILE is a big struct and may change over time. To try to achieve binary
|
584 |
|
|
compatibility with future versions, put stdin,stdout,stderr here.
|
585 |
|
|
These are pointers into member __sf defined below. */
|
586 |
|
|
__FILE *_stdin, *_stdout, *_stderr;
|
587 |
|
|
|
588 |
|
|
int _inc; /* used by tmpnam */
|
589 |
|
|
char _emergency[_REENT_EMERGENCY_SIZE];
|
590 |
|
|
|
591 |
|
|
int _current_category; /* used by setlocale */
|
592 |
|
|
_CONST char *_current_locale;
|
593 |
|
|
|
594 |
|
|
int __sdidinit; /* 1 means stdio has been init'd */
|
595 |
|
|
|
596 |
|
|
void _EXFNPTR(__cleanup, (struct _reent *));
|
597 |
|
|
|
598 |
|
|
/* used by mprec routines */
|
599 |
|
|
struct _Bigint *_result;
|
600 |
|
|
int _result_k;
|
601 |
|
|
struct _Bigint *_p5s;
|
602 |
|
|
struct _Bigint **_freelist;
|
603 |
|
|
|
604 |
|
|
/* used by some fp conversion routines */
|
605 |
|
|
int _cvtlen; /* should be size_t */
|
606 |
|
|
char *_cvtbuf;
|
607 |
|
|
|
608 |
|
|
union
|
609 |
|
|
{
|
610 |
|
|
struct
|
611 |
|
|
{
|
612 |
|
|
unsigned int _unused_rand;
|
613 |
|
|
char * _strtok_last;
|
614 |
|
|
char _asctime_buf[_REENT_ASCTIME_SIZE];
|
615 |
|
|
struct __tm _localtime_buf;
|
616 |
|
|
int _gamma_signgam;
|
617 |
|
|
__extension__ unsigned long long _rand_next;
|
618 |
|
|
struct _rand48 _r48;
|
619 |
|
|
_mbstate_t _mblen_state;
|
620 |
|
|
_mbstate_t _mbtowc_state;
|
621 |
|
|
_mbstate_t _wctomb_state;
|
622 |
|
|
char _l64a_buf[8];
|
623 |
|
|
char _signal_buf[_REENT_SIGNAL_SIZE];
|
624 |
|
|
int _getdate_err;
|
625 |
|
|
_mbstate_t _mbrlen_state;
|
626 |
|
|
_mbstate_t _mbrtowc_state;
|
627 |
|
|
_mbstate_t _mbsrtowcs_state;
|
628 |
|
|
_mbstate_t _wcrtomb_state;
|
629 |
|
|
_mbstate_t _wcsrtombs_state;
|
630 |
|
|
int _h_errno;
|
631 |
|
|
} _reent;
|
632 |
|
|
/* Two next two fields were once used by malloc. They are no longer
|
633 |
|
|
used. They are used to preserve the space used before so as to
|
634 |
|
|
allow addition of new reent fields and keep binary compatibility. */
|
635 |
|
|
struct
|
636 |
|
|
{
|
637 |
|
|
#define _N_LISTS 30
|
638 |
|
|
unsigned char * _nextf[_N_LISTS];
|
639 |
|
|
unsigned int _nmalloc[_N_LISTS];
|
640 |
|
|
} _unused;
|
641 |
|
|
} _new;
|
642 |
|
|
|
643 |
|
|
/* atexit stuff */
|
644 |
|
|
struct _atexit *_atexit; /* points to head of LIFO stack */
|
645 |
|
|
struct _atexit _atexit0; /* one guaranteed table, required by ANSI */
|
646 |
|
|
|
647 |
|
|
/* signal info */
|
648 |
|
|
void (**(_sig_func))(int);
|
649 |
|
|
|
650 |
|
|
/* These are here last so that __FILE can grow without changing the offsets
|
651 |
|
|
of the above members (on the off chance that future binary compatibility
|
652 |
|
|
would be broken otherwise). */
|
653 |
|
|
struct _glue __sglue; /* root of glue chain */
|
654 |
|
|
__FILE __sf[3]; /* first three file descriptors */
|
655 |
|
|
};
|
656 |
|
|
|
657 |
|
|
#define _REENT_INIT(var) \
|
658 |
|
|
{ 0, \
|
659 |
|
|
&(var).__sf[0], \
|
660 |
|
|
&(var).__sf[1], \
|
661 |
|
|
&(var).__sf[2], \
|
662 |
|
|
0, \
|
663 |
|
|
"", \
|
664 |
|
|
0, \
|
665 |
|
|
"C", \
|
666 |
|
|
0, \
|
667 |
|
|
_NULL, \
|
668 |
|
|
_NULL, \
|
669 |
|
|
0, \
|
670 |
|
|
_NULL, \
|
671 |
|
|
_NULL, \
|
672 |
|
|
0, \
|
673 |
|
|
_NULL, \
|
674 |
|
|
{ \
|
675 |
|
|
{ \
|
676 |
|
|
0, \
|
677 |
|
|
_NULL, \
|
678 |
|
|
"", \
|
679 |
|
|
{0, 0, 0, 0, 0, 0, 0, 0, 0}, \
|
680 |
|
|
0, \
|
681 |
|
|
1, \
|
682 |
|
|
{ \
|
683 |
|
|
{_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, \
|
684 |
|
|
{_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, \
|
685 |
|
|
_RAND48_ADD \
|
686 |
|
|
}, \
|
687 |
|
|
{0, {0}}, \
|
688 |
|
|
{0, {0}}, \
|
689 |
|
|
{0, {0}}, \
|
690 |
|
|
"", \
|
691 |
|
|
"", \
|
692 |
|
|
0, \
|
693 |
|
|
{0, {0}}, \
|
694 |
|
|
{0, {0}}, \
|
695 |
|
|
{0, {0}}, \
|
696 |
|
|
{0, {0}}, \
|
697 |
|
|
{0, {0}} \
|
698 |
|
|
} \
|
699 |
|
|
}, \
|
700 |
|
|
_NULL, \
|
701 |
|
|
{_NULL, 0, {_NULL}, {{_NULL}, {_NULL}, 0, 0}}, \
|
702 |
|
|
_NULL, \
|
703 |
|
|
{_NULL, 0, _NULL} \
|
704 |
|
|
}
|
705 |
|
|
|
706 |
|
|
#define _REENT_INIT_PTR(var) \
|
707 |
|
|
{ (var)->_errno = 0; \
|
708 |
|
|
(var)->_stdin = &(var)->__sf[0]; \
|
709 |
|
|
(var)->_stdout = &(var)->__sf[1]; \
|
710 |
|
|
(var)->_stderr = &(var)->__sf[2]; \
|
711 |
|
|
(var)->_inc = 0; \
|
712 |
|
|
memset(&(var)->_emergency, 0, sizeof((var)->_emergency)); \
|
713 |
|
|
(var)->_current_category = 0; \
|
714 |
|
|
(var)->_current_locale = "C"; \
|
715 |
|
|
(var)->__sdidinit = 0; \
|
716 |
|
|
(var)->__cleanup = _NULL; \
|
717 |
|
|
(var)->_result = _NULL; \
|
718 |
|
|
(var)->_result_k = 0; \
|
719 |
|
|
(var)->_p5s = _NULL; \
|
720 |
|
|
(var)->_freelist = _NULL; \
|
721 |
|
|
(var)->_cvtlen = 0; \
|
722 |
|
|
(var)->_cvtbuf = _NULL; \
|
723 |
|
|
(var)->_new._reent._unused_rand = 0; \
|
724 |
|
|
(var)->_new._reent._strtok_last = _NULL; \
|
725 |
|
|
(var)->_new._reent._asctime_buf[0] = 0; \
|
726 |
|
|
memset(&(var)->_new._reent._localtime_buf, 0, sizeof((var)->_new._reent._localtime_buf)); \
|
727 |
|
|
(var)->_new._reent._gamma_signgam = 0; \
|
728 |
|
|
(var)->_new._reent._rand_next = 1; \
|
729 |
|
|
(var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; \
|
730 |
|
|
(var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; \
|
731 |
|
|
(var)->_new._reent._r48._seed[2] = _RAND48_SEED_2; \
|
732 |
|
|
(var)->_new._reent._r48._mult[0] = _RAND48_MULT_0; \
|
733 |
|
|
(var)->_new._reent._r48._mult[1] = _RAND48_MULT_1; \
|
734 |
|
|
(var)->_new._reent._r48._mult[2] = _RAND48_MULT_2; \
|
735 |
|
|
(var)->_new._reent._r48._add = _RAND48_ADD; \
|
736 |
|
|
(var)->_new._reent._mblen_state.__count = 0; \
|
737 |
|
|
(var)->_new._reent._mblen_state.__value.__wch = 0; \
|
738 |
|
|
(var)->_new._reent._mbtowc_state.__count = 0; \
|
739 |
|
|
(var)->_new._reent._mbtowc_state.__value.__wch = 0; \
|
740 |
|
|
(var)->_new._reent._wctomb_state.__count = 0; \
|
741 |
|
|
(var)->_new._reent._wctomb_state.__value.__wch = 0; \
|
742 |
|
|
(var)->_new._reent._mbrlen_state.__count = 0; \
|
743 |
|
|
(var)->_new._reent._mbrlen_state.__value.__wch = 0; \
|
744 |
|
|
(var)->_new._reent._mbrtowc_state.__count = 0; \
|
745 |
|
|
(var)->_new._reent._mbrtowc_state.__value.__wch = 0; \
|
746 |
|
|
(var)->_new._reent._mbsrtowcs_state.__count = 0; \
|
747 |
|
|
(var)->_new._reent._mbsrtowcs_state.__value.__wch = 0; \
|
748 |
|
|
(var)->_new._reent._wcrtomb_state.__count = 0; \
|
749 |
|
|
(var)->_new._reent._wcrtomb_state.__value.__wch = 0; \
|
750 |
|
|
(var)->_new._reent._wcsrtombs_state.__count = 0; \
|
751 |
|
|
(var)->_new._reent._wcsrtombs_state.__value.__wch = 0; \
|
752 |
|
|
(var)->_new._reent._l64a_buf[0] = '\0'; \
|
753 |
|
|
(var)->_new._reent._signal_buf[0] = '\0'; \
|
754 |
|
|
(var)->_new._reent._getdate_err = 0; \
|
755 |
|
|
(var)->_atexit = _NULL; \
|
756 |
|
|
(var)->_atexit0._next = _NULL; \
|
757 |
|
|
(var)->_atexit0._ind = 0; \
|
758 |
|
|
(var)->_atexit0._fns[0] = _NULL; \
|
759 |
|
|
(var)->_atexit0._on_exit_args._fntypes = 0; \
|
760 |
|
|
(var)->_atexit0._on_exit_args._fnargs[0] = _NULL; \
|
761 |
|
|
(var)->_sig_func = _NULL; \
|
762 |
|
|
(var)->__sglue._next = _NULL; \
|
763 |
|
|
(var)->__sglue._niobs = 0; \
|
764 |
|
|
(var)->__sglue._iobs = _NULL; \
|
765 |
|
|
memset(&(var)->__sf, 0, sizeof((var)->__sf)); \
|
766 |
|
|
}
|
767 |
|
|
|
768 |
|
|
#define _REENT_CHECK_RAND48(ptr) /* nothing */
|
769 |
|
|
#define _REENT_CHECK_MP(ptr) /* nothing */
|
770 |
|
|
#define _REENT_CHECK_TM(ptr) /* nothing */
|
771 |
|
|
#define _REENT_CHECK_ASCTIME_BUF(ptr) /* nothing */
|
772 |
|
|
#define _REENT_CHECK_EMERGENCY(ptr) /* nothing */
|
773 |
|
|
#define _REENT_CHECK_MISC(ptr) /* nothing */
|
774 |
|
|
#define _REENT_CHECK_SIGNAL_BUF(ptr) /* nothing */
|
775 |
|
|
|
776 |
|
|
#define _REENT_SIGNGAM(ptr) ((ptr)->_new._reent._gamma_signgam)
|
777 |
|
|
#define _REENT_RAND_NEXT(ptr) ((ptr)->_new._reent._rand_next)
|
778 |
|
|
#define _REENT_RAND48_SEED(ptr) ((ptr)->_new._reent._r48._seed)
|
779 |
|
|
#define _REENT_RAND48_MULT(ptr) ((ptr)->_new._reent._r48._mult)
|
780 |
|
|
#define _REENT_RAND48_ADD(ptr) ((ptr)->_new._reent._r48._add)
|
781 |
|
|
#define _REENT_MP_RESULT(ptr) ((ptr)->_result)
|
782 |
|
|
#define _REENT_MP_RESULT_K(ptr) ((ptr)->_result_k)
|
783 |
|
|
#define _REENT_MP_P5S(ptr) ((ptr)->_p5s)
|
784 |
|
|
#define _REENT_MP_FREELIST(ptr) ((ptr)->_freelist)
|
785 |
|
|
#define _REENT_ASCTIME_BUF(ptr) ((ptr)->_new._reent._asctime_buf)
|
786 |
|
|
#define _REENT_TM(ptr) (&(ptr)->_new._reent._localtime_buf)
|
787 |
|
|
#define _REENT_EMERGENCY(ptr) ((ptr)->_emergency)
|
788 |
|
|
#define _REENT_STRTOK_LAST(ptr) ((ptr)->_new._reent._strtok_last)
|
789 |
|
|
#define _REENT_MBLEN_STATE(ptr) ((ptr)->_new._reent._mblen_state)
|
790 |
|
|
#define _REENT_MBTOWC_STATE(ptr)((ptr)->_new._reent._mbtowc_state)
|
791 |
|
|
#define _REENT_WCTOMB_STATE(ptr)((ptr)->_new._reent._wctomb_state)
|
792 |
|
|
#define _REENT_MBRLEN_STATE(ptr)((ptr)->_new._reent._mbrlen_state)
|
793 |
|
|
#define _REENT_MBRTOWC_STATE(ptr)((ptr)->_new._reent._mbrtowc_state)
|
794 |
|
|
#define _REENT_MBSRTOWCS_STATE(ptr)((ptr)->_new._reent._mbsrtowcs_state)
|
795 |
|
|
#define _REENT_WCRTOMB_STATE(ptr)((ptr)->_new._reent._wcrtomb_state)
|
796 |
|
|
#define _REENT_WCSRTOMBS_STATE(ptr)((ptr)->_new._reent._wcsrtombs_state)
|
797 |
|
|
#define _REENT_L64A_BUF(ptr) ((ptr)->_new._reent._l64a_buf)
|
798 |
|
|
#define _REENT_SIGNAL_BUF(ptr) ((ptr)->_new._reent._signal_buf)
|
799 |
|
|
#define _REENT_GETDATE_ERR_P(ptr) (&((ptr)->_new._reent._getdate_err))
|
800 |
|
|
|
801 |
|
|
#endif /* !_REENT_SMALL */
|
802 |
|
|
|
803 |
|
|
/* This value is used in stdlib/misc.c. reent/reent.c has to know it
|
804 |
|
|
as well to make sure the freelist is correctly free'd. Therefore
|
805 |
|
|
we define it here, rather than in stdlib/misc.c, as before. */
|
806 |
|
|
#define _Kmax (sizeof (size_t) << 3)
|
807 |
|
|
|
808 |
|
|
/*
|
809 |
|
|
* All references to struct _reent are via this pointer.
|
810 |
|
|
* Internally, newlib routines that need to reference it should use _REENT.
|
811 |
|
|
*/
|
812 |
|
|
|
813 |
|
|
#ifndef __ATTRIBUTE_IMPURE_PTR__
|
814 |
|
|
#define __ATTRIBUTE_IMPURE_PTR__
|
815 |
|
|
#endif
|
816 |
|
|
|
817 |
|
|
extern struct _reent *_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
|
818 |
|
|
extern struct _reent *_CONST _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
|
819 |
|
|
|
820 |
|
|
void _reclaim_reent _PARAMS ((struct _reent *));
|
821 |
|
|
|
822 |
|
|
/* #define _REENT_ONLY define this to get only reentrant routines */
|
823 |
|
|
|
824 |
|
|
#ifndef _REENT_ONLY
|
825 |
|
|
|
826 |
|
|
#if defined(__DYNAMIC_REENT__) && !defined(__SINGLE_THREAD__)
|
827 |
|
|
#ifndef __getreent
|
828 |
|
|
struct _reent * _EXFUN(__getreent, (void));
|
829 |
|
|
#endif
|
830 |
|
|
# define _REENT (__getreent())
|
831 |
|
|
#else /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */
|
832 |
|
|
# define _REENT _impure_ptr
|
833 |
|
|
#endif /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */
|
834 |
|
|
|
835 |
|
|
#endif /* !_REENT_ONLY */
|
836 |
|
|
|
837 |
|
|
#define _GLOBAL_REENT _global_impure_ptr
|
838 |
|
|
|
839 |
|
|
#ifdef __cplusplus
|
840 |
|
|
}
|
841 |
|
|
#endif
|
842 |
|
|
#endif /* _SYS_REENT_H_ */
|