Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/include/sys/reent.h')
-rw-r--r--newlib/libc/include/sys/reent.h136
1 files changed, 32 insertions, 104 deletions
diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reent.h
index 7911b6cbc..e783e842e 100644
--- a/newlib/libc/include/sys/reent.h
+++ b/newlib/libc/include/sys/reent.h
@@ -59,24 +59,19 @@ 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 */
struct _on_exit_args {
- void * _fnargs[_ATEXIT_SIZE]; /* user fn args */
- void * _dso_handle[_ATEXIT_SIZE];
- /* Bitmask is set if user function takes arguments. */
+ void * _fnargs[_ATEXIT_SIZE]; /* fn args for on_exit */
__ULong _fntypes; /* type of exit routine -
- Must have at least _ATEXIT_SIZE bits */
- /* Bitmask is set if function was registered via __cxa_atexit. */
- __ULong _is_cxa;
+ Must have at least _ATEXIT_SIZE bits */
};
#ifdef _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 */
struct _on_exit_args * _on_exit_args_ptr;
@@ -85,7 +80,6 @@ struct _atexit {
struct _atexit {
struct _atexit *_next; /* next in list */
int _ind; /* next index in this table */
- /* Some entries may already have been called, and will be NULL. */
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */
struct _on_exit_args _on_exit_args;
};
@@ -158,9 +152,9 @@ struct __sFILE_fake {
struct _reent *_data;
};
/* CHECK_INIT() comes from stdio/local.h; be sure to include that. */
-# define _REENT_SMALL_CHECK_INIT(ptr) CHECK_INIT(ptr)
+# define _REENT_SMALL_CHECK_INIT(fp) CHECK_INIT(fp)
#else
-# define _REENT_SMALL_CHECK_INIT(ptr) /* nothing */
+# define _REENT_SMALL_CHECK_INIT(fp) /* nothing */
#endif
struct __sFILE {
@@ -377,8 +371,7 @@ struct _reent
void (**(_sig_func))(int);
/* atexit stuff */
- struct _atexit *_atexit;
- struct _atexit _atexit0;
+ struct _atexit _atexit;
struct _glue __sglue; /* root of glue chain */
__FILE *__sf; /* file descriptors */
@@ -388,32 +381,10 @@ struct _reent
};
#define _REENT_INIT(var) \
- { (__FILE *)&var.__sf_fake, \
- (__FILE *)&var.__sf_fake, \
- (__FILE *)&var.__sf_fake, \
- 0, \
- 0, \
- _NULL, \
- 0, \
- 0, \
- "C", \
- _NULL, \
- _NULL, \
- 0, \
- 0, \
- _NULL, \
- _NULL, \
- _NULL, \
- _NULL, \
- _NULL, \
- _NULL, \
- {_NULL, 0, {_NULL}, _NULL}, \
- {_NULL, 0, _NULL}, \
- _NULL, \
- {_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL}, \
- _NULL, \
- _NULL \
- }
+ { (__FILE *)&var.__sf_fake, (__FILE *)&var.__sf_fake, \
+ (__FILE *)&var.__sf_fake, 0, 0, _NULL, 0, 0, \
+ "C", _NULL, _NULL, 0, 0, _NULL, _NULL, _NULL, _NULL, _NULL, \
+ { 0, _NULL, _NULL, 0 }, { _NULL, 0, _NULL }, _NULL, 0, _NULL, _NULL }
#define _REENT_INIT_PTR(var) \
{ var->_stdin = (__FILE *)&var->__sf_fake; \
@@ -434,26 +405,23 @@ struct _reent
var->_localtime_buf = _NULL; \
var->_asctime_buf = _NULL; \
var->_sig_func = _NULL; \
- var->_atexit = _NULL; \
- var->_atexit0._next = _NULL; \
- var->_atexit0._ind = 0; \
- var->_atexit0._fns[0] = _NULL; \
- var->_atexit0._on_exit_args_ptr = _NULL; \
+ var->_atexit._ind = 0; \
+ var->_atexit._fns[0] = _NULL; \
+ var->_atexit._on_exit_args = _NULL; \
var->__sglue._next = _NULL; \
var->__sglue._niobs = 0; \
var->__sglue._iobs = _NULL; \
var->__sf = 0; \
+ var->_misc = _NULL; \
+ var->_signal_buf = _NULL; \
+ var->_getdate_err = 0; \
var->__sf_fake._p = _NULL; \
var->__sf_fake._r = 0; \
var->__sf_fake._w = 0; \
var->__sf_fake._flags = 0; \
var->__sf_fake._file = 0; \
- var->__sf_fake._bf._base = _NULL; \
- var->__sf_fake._bf._size = 0; \
var->__sf_fake._lbfsize = 0; \
var->__sf_fake._data = _NULL; \
- var->_misc = _NULL; \
- var->_signal_buf = _NULL; \
}
/* Only built the assert() calls if we are built with debugging. */
@@ -640,61 +608,23 @@ struct _reent
};
#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, \
- "", \
- {0, 0, 0, 0, 0, 0, 0, 0, 0}, \
- 0, \
- 1, \
- { \
- {_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, \
- {_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, \
- _RAND48_ADD \
- }, \
- {0, {0}}, \
- {0, {0}}, \
- {0, {0}}, \
- "", \
- "", \
- 0, \
- {0, {0}}, \
- {0, {0}}, \
- {0, {0}}, \
- {0, {0}}, \
- {0, {0}} \
- } \
- }, \
- _NULL, \
- {_NULL, 0, {_NULL}, {{_NULL}, {_NULL}, 0, 0}}, \
- _NULL, \
- {_NULL, 0, _NULL} \
- }
+ { 0, &var.__sf[0], &var.__sf[1], &var.__sf[2], 0, "", 0, "C", \
+ 0, _NULL, _NULL, 0, _NULL, _NULL, 0, _NULL, { {0, _NULL, "", \
+ { 0,0,0,0,0,0,0,0}, 0, 1, \
+ {{_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, \
+ {_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, _RAND48_ADD}, \
+ {0, {0}}, {0, {0}}, {0, {0}}, "", "", 0, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}} } } }
#define _REENT_INIT_PTR(var) \
- { var->_errno = 0; \
+ { int i; \
+ char *tmp_ptr; \
+ var->_errno = 0; \
var->_stdin = &var->__sf[0]; \
var->_stdout = &var->__sf[1]; \
var->_stderr = &var->__sf[2]; \
var->_inc = 0; \
- memset(&var->_emergency, 0, sizeof(var->_emergency)); \
+ for (i = 0; i < _REENT_EMERGENCY_SIZE; ++i) \
+ var->_emergency[i] = 0; \
var->_current_category = 0; \
var->_current_locale = "C"; \
var->__sdidinit = 0; \
@@ -708,7 +638,9 @@ struct _reent
var->_new._reent._unused_rand = 0; \
var->_new._reent._strtok_last = _NULL; \
var->_new._reent._asctime_buf[0] = 0; \
- memset(&var->_new._reent._localtime_buf, 0, sizeof(var->_new._reent._localtime_buf)); \
+ tmp_ptr = (char *)&var->_new._reent._localtime_buf; \
+ for (i = 0; i < sizeof(struct __tm); ++i) \
+ tmp_ptr[i] = 0; \
var->_new._reent._gamma_signgam = 0; \
var->_new._reent._rand_next = 1; \
var->_new._reent._r48._seed[0] = _RAND48_SEED_0; \
@@ -738,7 +670,6 @@ struct _reent
var->_new._reent._signal_buf[0] = '\0'; \
var->_new._reent._getdate_err = 0; \
var->_atexit = _NULL; \
- var->_atexit0._next = _NULL; \
var->_atexit0._ind = 0; \
var->_atexit0._fns[0] = _NULL; \
var->_atexit0._on_exit_args._fntypes = 0; \
@@ -747,7 +678,7 @@ struct _reent
var->__sglue._next = _NULL; \
var->__sglue._niobs = 0; \
var->__sglue._iobs = _NULL; \
- memset(&var->__sf, 0, sizeof(var->__sf)); \
+ memset(var->__sf,0,sizeof(var->__sf)); \
}
#define _REENT_CHECK_RAND48(ptr) /* nothing */
@@ -797,7 +728,6 @@ struct _reent
#endif
extern struct _reent *_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
-extern struct _reent *_CONST _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
void _reclaim_reent _PARAMS ((struct _reent *));
@@ -806,9 +736,7 @@ void _reclaim_reent _PARAMS ((struct _reent *));
#ifndef _REENT_ONLY
#if defined(__DYNAMIC_REENT__) && !defined(__SINGLE_THREAD__)
-#ifndef __getreent
struct _reent * _EXFUN(__getreent, (void));
-#endif
# define _REENT (__getreent())
#else /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */
# define _REENT _impure_ptr
@@ -816,7 +744,7 @@ void _reclaim_reent _PARAMS ((struct _reent *));
#endif /* !_REENT_ONLY */
-#define _GLOBAL_REENT _global_impure_ptr
+#define _GLOBAL_REENT _impure_ptr
#ifdef __cplusplus
}