2013-04-29 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/stdio/local.h (CHECK_INIT): Evaluate argument only once. (CHECK_STD_INIT): Likewise. * libc/stdio/fgetc.c (fgetc): Use local variable for _REENT. * libc/stdio/fgetwc.c (fwgetc): Likewise. * libc/stdio/fgetws.c (fgetws): Likewise. * libc/stdio/fputc.c (fputc): Likewise. * libc/stdio/fputwc.c (fputwc): Likewise. * libc/stdio/fputws.c (fputws): Likewise. * libc/stdio/getc.c (getc): Likewise. * libc/stdio/getchar.c (_getchar_r): Likewise. * libc/stdio/putc.c (putc): Likewise. * libc/stdio/putchar.c (putchar): Likewise. * libc/stdio/scanf.c (scanf): Likewise. * libc/stdio/setvbuf.c (setvbuf): Likewise. * libc/stdio/ungetwc.c (ungetwc): Likewise. * libc/stdio/vfscanf.c (VFSCANF): Likewise. * libc/stdio/vfwscanf.c (VFWSCANF): Likewise. * libc/stdio/viprintf.c (viprintf): Likewise. * libc/stdio/viscanf.c (viscanf): Likewise. * libc/stdio/vprintf.c (vprintf): Likewise. * libc/stdio/vscanf.c (vscanf): Likewise. * libc/stdio/vwprintf.c (vwprintf): Likewise. * libc/stdio/vwscanf.c (vwscanf): Likewise. * libc/stdio/wscanf.c (wscanf): Likewise. * libc/stdlib/ecvtbuf.c (fcvtbuf): Likewise. (fcvtbuf): Likewise. (ecvtbuf): Likewise. (ecvtbuf): Likewise. * libc/stdlib/mblen.c (mblen): Likewise. * libc/stdlib/mbrlen.c (mbrlen): Likewise. * libc/stdlib/mbrtowc.c (mbrtowc): Likewise. * libc/stdlib/mbtowc.c (mbtowc): Likewise. * libc/stdlib/rand.c (srand): Likewise. (rand): Likewise. * libc/stdlib/wcrtomb.c (wcrtomb): Likewise. * libc/stdlib/wctob.c (wctob): Likewise. * libc/stdlib/wctomb.c (wctomb): Likewise. * libc/string/strtok.c (strtok): Likewise. * libc/time/asctime.c (asctime): Likewise. * libc/time/gmtime.c (gmtime): Likewise. * libc/time/lcltime.c (lcltime): Likewise.
This commit is contained in:
parent
2a55aa79a9
commit
b334e6660a
|
@ -1,3 +1,47 @@
|
||||||
|
2013-04-29 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
|
* libc/stdio/local.h (CHECK_INIT): Evaluate argument only once.
|
||||||
|
(CHECK_STD_INIT): Likewise.
|
||||||
|
* libc/stdio/fgetc.c (fgetc): Use local variable for _REENT.
|
||||||
|
* libc/stdio/fgetwc.c (fwgetc): Likewise.
|
||||||
|
* libc/stdio/fgetws.c (fgetws): Likewise.
|
||||||
|
* libc/stdio/fputc.c (fputc): Likewise.
|
||||||
|
* libc/stdio/fputwc.c (fputwc): Likewise.
|
||||||
|
* libc/stdio/fputws.c (fputws): Likewise.
|
||||||
|
* libc/stdio/getc.c (getc): Likewise.
|
||||||
|
* libc/stdio/getchar.c (_getchar_r): Likewise.
|
||||||
|
* libc/stdio/putc.c (putc): Likewise.
|
||||||
|
* libc/stdio/putchar.c (putchar): Likewise.
|
||||||
|
* libc/stdio/scanf.c (scanf): Likewise.
|
||||||
|
* libc/stdio/setvbuf.c (setvbuf): Likewise.
|
||||||
|
* libc/stdio/ungetwc.c (ungetwc): Likewise.
|
||||||
|
* libc/stdio/vfscanf.c (VFSCANF): Likewise.
|
||||||
|
* libc/stdio/vfwscanf.c (VFWSCANF): Likewise.
|
||||||
|
* libc/stdio/viprintf.c (viprintf): Likewise.
|
||||||
|
* libc/stdio/viscanf.c (viscanf): Likewise.
|
||||||
|
* libc/stdio/vprintf.c (vprintf): Likewise.
|
||||||
|
* libc/stdio/vscanf.c (vscanf): Likewise.
|
||||||
|
* libc/stdio/vwprintf.c (vwprintf): Likewise.
|
||||||
|
* libc/stdio/vwscanf.c (vwscanf): Likewise.
|
||||||
|
* libc/stdio/wscanf.c (wscanf): Likewise.
|
||||||
|
* libc/stdlib/ecvtbuf.c (fcvtbuf): Likewise.
|
||||||
|
(fcvtbuf): Likewise.
|
||||||
|
(ecvtbuf): Likewise.
|
||||||
|
(ecvtbuf): Likewise.
|
||||||
|
* libc/stdlib/mblen.c (mblen): Likewise.
|
||||||
|
* libc/stdlib/mbrlen.c (mbrlen): Likewise.
|
||||||
|
* libc/stdlib/mbrtowc.c (mbrtowc): Likewise.
|
||||||
|
* libc/stdlib/mbtowc.c (mbtowc): Likewise.
|
||||||
|
* libc/stdlib/rand.c (srand): Likewise.
|
||||||
|
(rand): Likewise.
|
||||||
|
* libc/stdlib/wcrtomb.c (wcrtomb): Likewise.
|
||||||
|
* libc/stdlib/wctob.c (wctob): Likewise.
|
||||||
|
* libc/stdlib/wctomb.c (wctomb): Likewise.
|
||||||
|
* libc/string/strtok.c (strtok): Likewise.
|
||||||
|
* libc/time/asctime.c (asctime): Likewise.
|
||||||
|
* libc/time/gmtime.c (gmtime): Likewise.
|
||||||
|
* libc/time/lcltime.c (lcltime): Likewise.
|
||||||
|
|
||||||
2013-04-29 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
2013-04-29 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
* libc/include/sys/reent.h (_REENT_INIT_PTR): Reduce code size.
|
* libc/include/sys/reent.h (_REENT_INIT_PTR): Reduce code size.
|
||||||
|
|
|
@ -92,9 +92,11 @@ _DEFUN(fgetc, (fp),
|
||||||
{
|
{
|
||||||
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
|
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
|
||||||
int result;
|
int result;
|
||||||
CHECK_INIT(_REENT, fp);
|
struct _reent *reent = _REENT;
|
||||||
|
|
||||||
|
CHECK_INIT(reent, fp);
|
||||||
_newlib_flockfile_start (fp);
|
_newlib_flockfile_start (fp);
|
||||||
result = __sgetc_r (_REENT, fp);
|
result = __sgetc_r (reent, fp);
|
||||||
_newlib_flockfile_end (fp);
|
_newlib_flockfile_end (fp);
|
||||||
return result;
|
return result;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -175,6 +175,8 @@ wint_t
|
||||||
_DEFUN(fgetwc, (fp),
|
_DEFUN(fgetwc, (fp),
|
||||||
FILE *fp)
|
FILE *fp)
|
||||||
{
|
{
|
||||||
CHECK_INIT(_REENT, fp);
|
struct _reent *reent = _REENT;
|
||||||
return _fgetwc_r (_REENT, fp);
|
|
||||||
|
CHECK_INIT(reent, fp);
|
||||||
|
return _fgetwc_r (reent, fp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,8 @@ _DEFUN(fgetws, (ws, n, fp),
|
||||||
int n _AND
|
int n _AND
|
||||||
FILE *fp)
|
FILE *fp)
|
||||||
{
|
{
|
||||||
CHECK_INIT (_REENT, fp);
|
struct _reent *reent = _REENT;
|
||||||
return _fgetws_r (_REENT, ws, n, fp);
|
|
||||||
|
CHECK_INIT (reent, fp);
|
||||||
|
return _fgetws_r (reent, ws, n, fp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,9 +97,11 @@ _DEFUN(fputc, (ch, file),
|
||||||
{
|
{
|
||||||
#if !defined(__OPTIMIZE_SIZE__) && !defined(PREFER_SIZE_OVER_SPEED)
|
#if !defined(__OPTIMIZE_SIZE__) && !defined(PREFER_SIZE_OVER_SPEED)
|
||||||
int result;
|
int result;
|
||||||
CHECK_INIT(_REENT, file);
|
struct _reent *reent = _REENT;
|
||||||
|
|
||||||
|
CHECK_INIT(reent, file);
|
||||||
_newlib_flockfile_start (file);
|
_newlib_flockfile_start (file);
|
||||||
result = _putc_r (_REENT, ch, file);
|
result = _putc_r (reent, ch, file);
|
||||||
_newlib_flockfile_end (file);
|
_newlib_flockfile_end (file);
|
||||||
return result;
|
return result;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -172,6 +172,8 @@ _DEFUN(fputwc, (wc, fp),
|
||||||
wchar_t wc _AND
|
wchar_t wc _AND
|
||||||
FILE *fp)
|
FILE *fp)
|
||||||
{
|
{
|
||||||
CHECK_INIT(_REENT, fp);
|
struct _reent *reent = _REENT;
|
||||||
return _fputwc_r (_REENT, wc, fp);
|
|
||||||
|
CHECK_INIT(reent, fp);
|
||||||
|
return _fputwc_r (reent, wc, fp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,8 @@ _DEFUN(fputws, (ws, fp),
|
||||||
const wchar_t *ws _AND
|
const wchar_t *ws _AND
|
||||||
FILE *fp)
|
FILE *fp)
|
||||||
{
|
{
|
||||||
CHECK_INIT (_REENT, fp);
|
struct _reent *reent = _REENT;
|
||||||
return _fputws_r (_REENT, ws, fp);
|
|
||||||
|
CHECK_INIT (reent, fp);
|
||||||
|
return _fputws_r (reent, ws, fp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,9 +105,11 @@ _DEFUN(getc, (fp),
|
||||||
register FILE *fp)
|
register FILE *fp)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
CHECK_INIT (_REENT, fp);
|
struct _reent *reent = _REENT;
|
||||||
|
|
||||||
|
CHECK_INIT (reent, fp);
|
||||||
_newlib_flockfile_start (fp);
|
_newlib_flockfile_start (fp);
|
||||||
result = __sgetc_r (_REENT, fp);
|
result = __sgetc_r (reent, fp);
|
||||||
_newlib_flockfile_end (fp);
|
_newlib_flockfile_end (fp);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,9 +91,11 @@ _DEFUN(_getchar_r, (reent),
|
||||||
int
|
int
|
||||||
_DEFUN_VOID(getchar)
|
_DEFUN_VOID(getchar)
|
||||||
{
|
{
|
||||||
|
struct _reent *reent = _REENT;
|
||||||
|
|
||||||
/* CHECK_INIT is called (eventually) by __srefill_r. */
|
/* CHECK_INIT is called (eventually) by __srefill_r. */
|
||||||
_REENT_SMALL_CHECK_INIT (_REENT);
|
_REENT_SMALL_CHECK_INIT (reent);
|
||||||
return _getc_r (_REENT, _stdin_r (_REENT));
|
return _getc_r (reent, _stdin_r (reent));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -175,34 +175,37 @@ extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *,
|
||||||
|
|
||||||
#ifdef _REENT_SMALL
|
#ifdef _REENT_SMALL
|
||||||
#define CHECK_INIT(ptr, fp) \
|
#define CHECK_INIT(ptr, fp) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if ((ptr) && !(ptr)->__sdidinit) \
|
struct _reent *_check_init_ptr = (ptr); \
|
||||||
__sinit (ptr); \
|
if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \
|
||||||
if ((fp) == (FILE *)&__sf_fake_stdin) \
|
__sinit (_check_init_ptr); \
|
||||||
(fp) = _stdin_r(ptr); \
|
if ((fp) == (FILE *)&__sf_fake_stdin) \
|
||||||
else if ((fp) == (FILE *)&__sf_fake_stdout) \
|
(fp) = _stdin_r(_check_init_ptr); \
|
||||||
(fp) = _stdout_r(ptr); \
|
else if ((fp) == (FILE *)&__sf_fake_stdout) \
|
||||||
else if ((fp) == (FILE *)&__sf_fake_stderr) \
|
(fp) = _stdout_r(_check_init_ptr); \
|
||||||
(fp) = _stderr_r(ptr); \
|
else if ((fp) == (FILE *)&__sf_fake_stderr) \
|
||||||
} \
|
(fp) = _stderr_r(_check_init_ptr); \
|
||||||
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#else /* !_REENT_SMALL */
|
#else /* !_REENT_SMALL */
|
||||||
#define CHECK_INIT(ptr, fp) \
|
#define CHECK_INIT(ptr, fp) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if ((ptr) && !(ptr)->__sdidinit) \
|
struct _reent *_check_init_ptr = (ptr); \
|
||||||
__sinit (ptr); \
|
if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \
|
||||||
} \
|
__sinit (_check_init_ptr); \
|
||||||
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#endif /* !_REENT_SMALL */
|
#endif /* !_REENT_SMALL */
|
||||||
|
|
||||||
#define CHECK_STD_INIT(ptr) \
|
#define CHECK_STD_INIT(ptr) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if ((ptr) && !(ptr)->__sdidinit) \
|
struct _reent *_check_init_ptr = (ptr); \
|
||||||
__sinit (ptr); \
|
if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \
|
||||||
} \
|
__sinit (_check_init_ptr); \
|
||||||
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
/* Return true and set errno and stream error flag iff the given FILE
|
/* Return true and set errno and stream error flag iff the given FILE
|
||||||
|
|
|
@ -111,9 +111,11 @@ _DEFUN(putc, (c, fp),
|
||||||
{
|
{
|
||||||
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
|
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
|
||||||
int result;
|
int result;
|
||||||
CHECK_INIT (_REENT, fp);
|
struct _reent *reent = _REENT;
|
||||||
|
|
||||||
|
CHECK_INIT (reent, fp);
|
||||||
_newlib_flockfile_start (fp);
|
_newlib_flockfile_start (fp);
|
||||||
result = __sputc_r (_REENT, c, fp);
|
result = __sputc_r (reent, c, fp);
|
||||||
_newlib_flockfile_end (fp);
|
_newlib_flockfile_end (fp);
|
||||||
return result;
|
return result;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -90,8 +90,10 @@ int
|
||||||
_DEFUN(putchar, (c),
|
_DEFUN(putchar, (c),
|
||||||
int c)
|
int c)
|
||||||
{
|
{
|
||||||
_REENT_SMALL_CHECK_INIT (_REENT);
|
struct _reent *reent = _REENT;
|
||||||
return _putc_r (_REENT, c, _stdout_r (_REENT));
|
|
||||||
|
_REENT_SMALL_CHECK_INIT (reent);
|
||||||
|
return _putc_r (reent, c, _stdout_r (reent));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,14 +38,15 @@ scanf(fmt, va_alist)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
struct _reent *reent = _REENT;
|
||||||
|
|
||||||
_REENT_SMALL_CHECK_INIT (_REENT);
|
_REENT_SMALL_CHECK_INIT (reent);
|
||||||
#ifdef _HAVE_STDC
|
#ifdef _HAVE_STDC
|
||||||
va_start (ap, fmt);
|
va_start (ap, fmt);
|
||||||
#else
|
#else
|
||||||
va_start (ap);
|
va_start (ap);
|
||||||
#endif
|
#endif
|
||||||
ret = _vfscanf_r (_REENT, _stdin_r (_REENT), fmt, ap);
|
ret = _vfscanf_r (reent, _stdin_r (reent), fmt, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,8 +103,9 @@ _DEFUN(setvbuf, (fp, buf, mode, size),
|
||||||
register size_t size)
|
register size_t size)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
struct _reent *reent = _REENT;
|
||||||
|
|
||||||
CHECK_INIT (_REENT, fp);
|
CHECK_INIT (reent, fp);
|
||||||
|
|
||||||
_newlib_flockfile_start (fp);
|
_newlib_flockfile_start (fp);
|
||||||
|
|
||||||
|
@ -126,11 +127,11 @@ _DEFUN(setvbuf, (fp, buf, mode, size),
|
||||||
* non buffer flags, and clear malloc flag.
|
* non buffer flags, and clear malloc flag.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_fflush_r (_REENT, fp);
|
_fflush_r (reent, fp);
|
||||||
fp->_r = 0;
|
fp->_r = 0;
|
||||||
fp->_lbfsize = 0;
|
fp->_lbfsize = 0;
|
||||||
if (fp->_flags & __SMBF)
|
if (fp->_flags & __SMBF)
|
||||||
_free_r (_REENT, (_PTR) fp->_bf._base);
|
_free_r (reent, (_PTR) fp->_bf._base);
|
||||||
fp->_flags &= ~(__SLBF | __SNBF | __SMBF);
|
fp->_flags &= ~(__SLBF | __SNBF | __SMBF);
|
||||||
|
|
||||||
if (mode == _IONBF)
|
if (mode == _IONBF)
|
||||||
|
@ -180,7 +181,7 @@ nbf:
|
||||||
|
|
||||||
case _IOFBF:
|
case _IOFBF:
|
||||||
/* no flag */
|
/* no flag */
|
||||||
_REENT->__cleanup = _cleanup_r;
|
reent->__cleanup = _cleanup_r;
|
||||||
fp->_bf._base = fp->_p = (unsigned char *) buf;
|
fp->_bf._base = fp->_p = (unsigned char *) buf;
|
||||||
fp->_bf._size = size;
|
fp->_bf._size = size;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -110,6 +110,8 @@ _DEFUN(ungetwc, (wint_t wc, FILE *fp),
|
||||||
wint_t wc _AND
|
wint_t wc _AND
|
||||||
FILE *fp)
|
FILE *fp)
|
||||||
{
|
{
|
||||||
CHECK_INIT (_REENT, fp);
|
struct _reent *reent = _REENT;
|
||||||
return _ungetwc_r (_REENT, wc, fp);
|
|
||||||
|
CHECK_INIT (reent, fp);
|
||||||
|
return _ungetwc_r (reent, wc, fp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,8 +266,10 @@ _DEFUN(VFSCANF, (fp, fmt, ap),
|
||||||
_CONST char *fmt _AND
|
_CONST char *fmt _AND
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
CHECK_INIT(_REENT, fp);
|
struct _reent *reent = _REENT;
|
||||||
return __SVFSCANF_R (_REENT, fp, fmt, ap);
|
|
||||||
|
CHECK_INIT(reent, fp);
|
||||||
|
return __SVFSCANF_R (reent, fp, fmt, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -258,8 +258,10 @@ _DEFUN(VFWSCANF, (fp, fmt, ap),
|
||||||
_CONST wchar_t *fmt _AND
|
_CONST wchar_t *fmt _AND
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
CHECK_INIT(_REENT, fp);
|
struct _reent *reent = _REENT;
|
||||||
return __SVFWSCANF_R (_REENT, fp, fmt, ap);
|
|
||||||
|
CHECK_INIT(reent, fp);
|
||||||
|
return __SVFWSCANF_R (reent, fp, fmt, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -109,8 +109,10 @@ _DEFUN(viprintf, (fmt, ap),
|
||||||
_CONST char *fmt _AND
|
_CONST char *fmt _AND
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
_REENT_SMALL_CHECK_INIT (_REENT);
|
struct _reent *reent = _REENT;
|
||||||
return _vfiprintf_r (_REENT, _stdout_r (_REENT), fmt, ap);
|
|
||||||
|
_REENT_SMALL_CHECK_INIT (reent);
|
||||||
|
return _vfiprintf_r (reent, _stdout_r (reent), fmt, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !_REENT_ONLY */
|
#endif /* !_REENT_ONLY */
|
||||||
|
|
|
@ -127,8 +127,10 @@ _DEFUN(viscanf, (fmt, ap),
|
||||||
_CONST char *fmt _AND
|
_CONST char *fmt _AND
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
_REENT_SMALL_CHECK_INIT (_REENT);
|
struct _reent *reent = _REENT;
|
||||||
return __svfiscanf_r (_REENT, _stdin_r (_REENT), fmt, ap);
|
|
||||||
|
_REENT_SMALL_CHECK_INIT (reent);
|
||||||
|
return __svfiscanf_r (reent, _stdin_r (reent), fmt, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !_REENT_ONLY */
|
#endif /* !_REENT_ONLY */
|
||||||
|
|
|
@ -33,8 +33,10 @@ _DEFUN(vprintf, (fmt, ap),
|
||||||
_CONST char *fmt _AND
|
_CONST char *fmt _AND
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
_REENT_SMALL_CHECK_INIT (_REENT);
|
struct _reent *reent = _REENT;
|
||||||
return _vfprintf_r (_REENT, _stdout_r (_REENT), fmt, ap);
|
|
||||||
|
_REENT_SMALL_CHECK_INIT (reent);
|
||||||
|
return _vfprintf_r (reent, _stdout_r (reent), fmt, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !_REENT_ONLY */
|
#endif /* !_REENT_ONLY */
|
||||||
|
|
|
@ -34,8 +34,10 @@ _DEFUN(vscanf, (fmt, ap),
|
||||||
_CONST char *fmt _AND
|
_CONST char *fmt _AND
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
_REENT_SMALL_CHECK_INIT (_REENT);
|
struct _reent *reent = _REENT;
|
||||||
return __svfscanf_r (_REENT, _stdin_r (_REENT), fmt, ap);
|
|
||||||
|
_REENT_SMALL_CHECK_INIT (reent);
|
||||||
|
return __svfscanf_r (reent, _stdin_r (reent), fmt, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !_REENT_ONLY */
|
#endif /* !_REENT_ONLY */
|
||||||
|
|
|
@ -30,8 +30,10 @@ _DEFUN(vwprintf, (fmt, ap),
|
||||||
_CONST wchar_t *fmt _AND
|
_CONST wchar_t *fmt _AND
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
_REENT_SMALL_CHECK_INIT (_REENT);
|
struct _reent *reent = _REENT;
|
||||||
return _vfwprintf_r (_REENT, _stdout_r (_REENT), fmt, ap);
|
|
||||||
|
_REENT_SMALL_CHECK_INIT (reent);
|
||||||
|
return _vfwprintf_r (reent, _stdout_r (reent), fmt, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !_REENT_ONLY */
|
#endif /* !_REENT_ONLY */
|
||||||
|
|
|
@ -33,8 +33,10 @@
|
||||||
int
|
int
|
||||||
vwscanf (_CONST wchar_t *fmt, va_list ap)
|
vwscanf (_CONST wchar_t *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
_REENT_SMALL_CHECK_INIT (_REENT);
|
struct _reent *reent = _REENT;
|
||||||
return __svfwscanf_r (_REENT, _stdin_r (_REENT), fmt, ap);
|
|
||||||
|
_REENT_SMALL_CHECK_INIT (reent);
|
||||||
|
return __svfwscanf_r (reent, _stdin_r (reent), fmt, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !_REENT_ONLY */
|
#endif /* !_REENT_ONLY */
|
||||||
|
|
|
@ -29,10 +29,11 @@ wscanf(_CONST wchar_t *fmt, ...)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
struct _reent *reent = _REENT;
|
||||||
|
|
||||||
_REENT_SMALL_CHECK_INIT (_REENT);
|
_REENT_SMALL_CHECK_INIT (reent);
|
||||||
va_start (ap, fmt);
|
va_start (ap, fmt);
|
||||||
ret = _vfwscanf_r (_REENT, _stdin_r (_REENT), fmt, ap);
|
ret = _vfwscanf_r (reent, _stdin_r (reent), fmt, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,6 +233,7 @@ _DEFUN (fcvtbuf, (invalue, ndigit, decpt, sign, fcvt_buf),
|
||||||
int *sign _AND
|
int *sign _AND
|
||||||
char *fcvt_buf)
|
char *fcvt_buf)
|
||||||
{
|
{
|
||||||
|
struct _reent *reent = _REENT;
|
||||||
char *save;
|
char *save;
|
||||||
char *p;
|
char *p;
|
||||||
char *end;
|
char *end;
|
||||||
|
@ -240,27 +241,27 @@ _DEFUN (fcvtbuf, (invalue, ndigit, decpt, sign, fcvt_buf),
|
||||||
|
|
||||||
if (fcvt_buf == NULL)
|
if (fcvt_buf == NULL)
|
||||||
{
|
{
|
||||||
if (_REENT->_cvtlen <= ndigit + 35)
|
if (reent->_cvtlen <= ndigit + 35)
|
||||||
{
|
{
|
||||||
if ((fcvt_buf = (char *) _realloc_r (_REENT, _REENT->_cvtbuf,
|
if ((fcvt_buf = (char *) _realloc_r (reent, reent->_cvtbuf,
|
||||||
ndigit + 36)) == NULL)
|
ndigit + 36)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
_REENT->_cvtlen = ndigit + 36;
|
reent->_cvtlen = ndigit + 36;
|
||||||
_REENT->_cvtbuf = fcvt_buf;
|
reent->_cvtbuf = fcvt_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
fcvt_buf = _REENT->_cvtbuf ;
|
fcvt_buf = reent->_cvtbuf ;
|
||||||
}
|
}
|
||||||
|
|
||||||
save = fcvt_buf;
|
save = fcvt_buf;
|
||||||
|
|
||||||
if (invalue < 1.0 && invalue > -1.0)
|
if (invalue < 1.0 && invalue > -1.0)
|
||||||
{
|
{
|
||||||
p = _dtoa_r (_REENT, invalue, 2, ndigit, decpt, sign, &end);
|
p = _dtoa_r (reent, invalue, 2, ndigit, decpt, sign, &end);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p = _dtoa_r (_REENT, invalue, 3, ndigit, decpt, sign, &end);
|
p = _dtoa_r (reent, invalue, 3, ndigit, decpt, sign, &end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now copy */
|
/* Now copy */
|
||||||
|
@ -289,6 +290,7 @@ _DEFUN (ecvtbuf, (invalue, ndigit, decpt, sign, fcvt_buf),
|
||||||
int *sign _AND
|
int *sign _AND
|
||||||
char *fcvt_buf)
|
char *fcvt_buf)
|
||||||
{
|
{
|
||||||
|
struct _reent *reent = _REENT;
|
||||||
char *save;
|
char *save;
|
||||||
char *p;
|
char *p;
|
||||||
char *end;
|
char *end;
|
||||||
|
@ -296,21 +298,21 @@ _DEFUN (ecvtbuf, (invalue, ndigit, decpt, sign, fcvt_buf),
|
||||||
|
|
||||||
if (fcvt_buf == NULL)
|
if (fcvt_buf == NULL)
|
||||||
{
|
{
|
||||||
if (_REENT->_cvtlen <= ndigit)
|
if (reent->_cvtlen <= ndigit)
|
||||||
{
|
{
|
||||||
if ((fcvt_buf = (char *) _realloc_r (_REENT, _REENT->_cvtbuf,
|
if ((fcvt_buf = (char *) _realloc_r (reent, reent->_cvtbuf,
|
||||||
ndigit + 1)) == NULL)
|
ndigit + 1)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
_REENT->_cvtlen = ndigit + 1;
|
reent->_cvtlen = ndigit + 1;
|
||||||
_REENT->_cvtbuf = fcvt_buf;
|
reent->_cvtbuf = fcvt_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
fcvt_buf = _REENT->_cvtbuf ;
|
fcvt_buf = reent->_cvtbuf ;
|
||||||
}
|
}
|
||||||
|
|
||||||
save = fcvt_buf;
|
save = fcvt_buf;
|
||||||
|
|
||||||
p = _dtoa_r (_REENT, invalue, 2, ndigit, decpt, sign, &end);
|
p = _dtoa_r (reent, invalue, 2, ndigit, decpt, sign, &end);
|
||||||
|
|
||||||
/* Now copy */
|
/* Now copy */
|
||||||
|
|
||||||
|
|
|
@ -55,11 +55,12 @@ _DEFUN (mblen, (s, n),
|
||||||
{
|
{
|
||||||
#ifdef _MB_CAPABLE
|
#ifdef _MB_CAPABLE
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
struct _reent *reent = _REENT;
|
||||||
mbstate_t *state;
|
mbstate_t *state;
|
||||||
|
|
||||||
_REENT_CHECK_MISC(_REENT);
|
_REENT_CHECK_MISC(reent);
|
||||||
state = &(_REENT_MBLEN_STATE(_REENT));
|
state = &(_REENT_MBLEN_STATE(reent));
|
||||||
retval = __mbtowc (_REENT, NULL, s, n, __locale_charset (), state);
|
retval = __mbtowc (reent, NULL, s, n, __locale_charset (), state);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
{
|
{
|
||||||
state->__count = 0;
|
state->__count = 0;
|
||||||
|
|
|
@ -11,8 +11,10 @@ mbrlen(const char *s, size_t n, mbstate_t *ps)
|
||||||
#ifdef _MB_CAPABLE
|
#ifdef _MB_CAPABLE
|
||||||
if (ps == NULL)
|
if (ps == NULL)
|
||||||
{
|
{
|
||||||
_REENT_CHECK_MISC(_REENT);
|
struct _reent *reent = _REENT;
|
||||||
ps = &(_REENT_MBRLEN_STATE(_REENT));
|
|
||||||
|
_REENT_CHECK_MISC(reent);
|
||||||
|
ps = &(_REENT_MBRLEN_STATE(reent));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -52,24 +52,25 @@ _DEFUN (mbrtowc, (pwc, s, n, ps),
|
||||||
return _mbrtowc_r (_REENT, pwc, s, n, ps);
|
return _mbrtowc_r (_REENT, pwc, s, n, ps);
|
||||||
#else
|
#else
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
struct _reent *reent = _REENT;
|
||||||
|
|
||||||
#ifdef _MB_CAPABLE
|
#ifdef _MB_CAPABLE
|
||||||
if (ps == NULL)
|
if (ps == NULL)
|
||||||
{
|
{
|
||||||
_REENT_CHECK_MISC(_REENT);
|
_REENT_CHECK_MISC(reent);
|
||||||
ps = &(_REENT_MBRTOWC_STATE(_REENT));
|
ps = &(_REENT_MBRTOWC_STATE(reent));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
retval = __mbtowc (_REENT, NULL, "", 1, __locale_charset (), ps);
|
retval = __mbtowc (reent, NULL, "", 1, __locale_charset (), ps);
|
||||||
else
|
else
|
||||||
retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps);
|
retval = __mbtowc (reent, pwc, s, n, __locale_charset (), ps);
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
{
|
{
|
||||||
ps->__count = 0;
|
ps->__count = 0;
|
||||||
_REENT->_errno = EILSEQ;
|
reent->_errno = EILSEQ;
|
||||||
return (size_t)(-1);
|
return (size_t)(-1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -64,12 +64,13 @@ _DEFUN (mbtowc, (pwc, s, n),
|
||||||
{
|
{
|
||||||
#ifdef _MB_CAPABLE
|
#ifdef _MB_CAPABLE
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
struct _reent *reent = _REENT;
|
||||||
mbstate_t *ps;
|
mbstate_t *ps;
|
||||||
|
|
||||||
_REENT_CHECK_MISC(_REENT);
|
_REENT_CHECK_MISC(reent);
|
||||||
ps = &(_REENT_MBTOWC_STATE(_REENT));
|
ps = &(_REENT_MBTOWC_STATE(reent));
|
||||||
|
|
||||||
retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps);
|
retval = __mbtowc (reent, pwc, s, n, __locale_charset (), ps);
|
||||||
|
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,20 +72,24 @@ on two different systems.
|
||||||
void
|
void
|
||||||
_DEFUN (srand, (seed), unsigned int seed)
|
_DEFUN (srand, (seed), unsigned int seed)
|
||||||
{
|
{
|
||||||
_REENT_CHECK_RAND48(_REENT);
|
struct _reent *reent = _REENT;
|
||||||
_REENT_RAND_NEXT(_REENT) = seed;
|
|
||||||
|
_REENT_CHECK_RAND48(reent);
|
||||||
|
_REENT_RAND_NEXT(reent) = seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_DEFUN_VOID (rand)
|
_DEFUN_VOID (rand)
|
||||||
{
|
{
|
||||||
|
struct _reent *reent = _REENT;
|
||||||
|
|
||||||
/* This multiplier was obtained from Knuth, D.E., "The Art of
|
/* This multiplier was obtained from Knuth, D.E., "The Art of
|
||||||
Computer Programming," Vol 2, Seminumerical Algorithms, Third
|
Computer Programming," Vol 2, Seminumerical Algorithms, Third
|
||||||
Edition, Addison-Wesley, 1998, p. 106 (line 26) & p. 108 */
|
Edition, Addison-Wesley, 1998, p. 106 (line 26) & p. 108 */
|
||||||
_REENT_CHECK_RAND48(_REENT);
|
_REENT_CHECK_RAND48(reent);
|
||||||
_REENT_RAND_NEXT(_REENT) =
|
_REENT_RAND_NEXT(reent) =
|
||||||
_REENT_RAND_NEXT(_REENT) * __extension__ 6364136223846793005LL + 1;
|
_REENT_RAND_NEXT(reent) * __extension__ 6364136223846793005LL + 1;
|
||||||
return (int)((_REENT_RAND_NEXT(_REENT) >> 32) & RAND_MAX);
|
return (int)((_REENT_RAND_NEXT(reent) >> 32) & RAND_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _REENT_ONLY */
|
#endif /* _REENT_ONLY */
|
||||||
|
|
|
@ -50,25 +50,26 @@ _DEFUN (wcrtomb, (s, wc, ps),
|
||||||
return _wcrtomb_r (_REENT, s, wc, ps);
|
return _wcrtomb_r (_REENT, s, wc, ps);
|
||||||
#else
|
#else
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
struct _reent *reent = _REENT;
|
||||||
char buf[10];
|
char buf[10];
|
||||||
|
|
||||||
#ifdef _MB_CAPABLE
|
#ifdef _MB_CAPABLE
|
||||||
if (ps == NULL)
|
if (ps == NULL)
|
||||||
{
|
{
|
||||||
_REENT_CHECK_MISC(_REENT);
|
_REENT_CHECK_MISC(reent);
|
||||||
ps = &(_REENT_WCRTOMB_STATE(_REENT));
|
ps = &(_REENT_WCRTOMB_STATE(reent));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
retval = __wctomb (_REENT, buf, L'\0', __locale_charset (), ps);
|
retval = __wctomb (reent, buf, L'\0', __locale_charset (), ps);
|
||||||
else
|
else
|
||||||
retval = __wctomb (_REENT, s, wc, __locale_charset (), ps);
|
retval = __wctomb (reent, s, wc, __locale_charset (), ps);
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
{
|
{
|
||||||
ps->__count = 0;
|
ps->__count = 0;
|
||||||
_REENT->_errno = EILSEQ;
|
reent->_errno = EILSEQ;
|
||||||
return (size_t)(-1);
|
return (size_t)(-1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
int
|
int
|
||||||
wctob (wint_t wc)
|
wctob (wint_t wc)
|
||||||
{
|
{
|
||||||
|
struct _reent *reent;
|
||||||
mbstate_t mbs;
|
mbstate_t mbs;
|
||||||
unsigned char pmb[MB_LEN_MAX];
|
unsigned char pmb[MB_LEN_MAX];
|
||||||
|
|
||||||
|
@ -17,8 +18,9 @@ wctob (wint_t wc)
|
||||||
/* Put mbs in initial state. */
|
/* Put mbs in initial state. */
|
||||||
memset (&mbs, '\0', sizeof (mbs));
|
memset (&mbs, '\0', sizeof (mbs));
|
||||||
|
|
||||||
_REENT_CHECK_MISC(_REENT);
|
reent = _REENT;
|
||||||
|
_REENT_CHECK_MISC(reent);
|
||||||
|
|
||||||
return __wctomb (_REENT, (char *) pmb, wc, __locale_charset (), &mbs) == 1
|
return __wctomb (reent, (char *) pmb, wc, __locale_charset (), &mbs) == 1
|
||||||
? (int) pmb[0] : EOF;
|
? (int) pmb[0] : EOF;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,10 +57,12 @@ _DEFUN (wctomb, (s, wchar),
|
||||||
wchar_t wchar)
|
wchar_t wchar)
|
||||||
{
|
{
|
||||||
#ifdef _MB_CAPABLE
|
#ifdef _MB_CAPABLE
|
||||||
_REENT_CHECK_MISC(_REENT);
|
struct _reent *reent = _REENT;
|
||||||
|
|
||||||
return __wctomb (_REENT, s, wchar, __locale_charset (),
|
_REENT_CHECK_MISC(reent);
|
||||||
&(_REENT_WCTOMB_STATE(_REENT)));
|
|
||||||
|
return __wctomb (reent, s, wchar, __locale_charset (),
|
||||||
|
&(_REENT_WCTOMB_STATE(reent)));
|
||||||
#else /* not _MB_CAPABLE */
|
#else /* not _MB_CAPABLE */
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -95,7 +95,9 @@ _DEFUN (strtok, (s, delim),
|
||||||
register char *s _AND
|
register char *s _AND
|
||||||
register const char *delim)
|
register const char *delim)
|
||||||
{
|
{
|
||||||
_REENT_CHECK_MISC(_REENT);
|
struct _reent *reent = _REENT;
|
||||||
return __strtok_r (s, delim, &(_REENT_STRTOK_LAST(_REENT)), 1);
|
|
||||||
|
_REENT_CHECK_MISC(reent);
|
||||||
|
return __strtok_r (s, delim, &(_REENT_STRTOK_LAST(reent)), 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,8 +57,10 @@ char *
|
||||||
_DEFUN (asctime, (tim_p),
|
_DEFUN (asctime, (tim_p),
|
||||||
_CONST struct tm *tim_p)
|
_CONST struct tm *tim_p)
|
||||||
{
|
{
|
||||||
_REENT_CHECK_ASCTIME_BUF(_REENT);
|
struct _reent *reent = _REENT;
|
||||||
return asctime_r (tim_p, _REENT_ASCTIME_BUF(_REENT));
|
|
||||||
|
_REENT_CHECK_ASCTIME_BUF(reent);
|
||||||
|
return asctime_r (tim_p, _REENT_ASCTIME_BUF(reent));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -61,8 +61,10 @@ struct tm *
|
||||||
_DEFUN (gmtime, (tim_p),
|
_DEFUN (gmtime, (tim_p),
|
||||||
_CONST time_t * tim_p)
|
_CONST time_t * tim_p)
|
||||||
{
|
{
|
||||||
_REENT_CHECK_TM(_REENT);
|
struct _reent *reent = _REENT;
|
||||||
return gmtime_r (tim_p, (struct tm *)_REENT_TM(_REENT));
|
|
||||||
|
_REENT_CHECK_TM(reent);
|
||||||
|
return gmtime_r (tim_p, (struct tm *)_REENT_TM(reent));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,8 +53,10 @@ struct tm *
|
||||||
_DEFUN (localtime, (tim_p),
|
_DEFUN (localtime, (tim_p),
|
||||||
_CONST time_t * tim_p)
|
_CONST time_t * tim_p)
|
||||||
{
|
{
|
||||||
_REENT_CHECK_TM(_REENT);
|
struct _reent *reent = _REENT;
|
||||||
return localtime_r (tim_p, (struct tm *)_REENT_TM(_REENT));
|
|
||||||
|
_REENT_CHECK_TM(reent);
|
||||||
|
return localtime_r (tim_p, (struct tm *)_REENT_TM(reent));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue