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:
authorJeff Johnston <jjohnstn@redhat.com>2013-04-30 01:06:23 +0400
committerJeff Johnston <jjohnstn@redhat.com>2013-04-30 01:06:23 +0400
commitb334e6660a405d2d63166ad9e4560421e6810cdc (patch)
tree08690339ed7959e88c00c4ac33406843dbc3ad62 /newlib/libc/stdlib
parent2a55aa79a9fcef6b8d1bd0264ed91d0c6420d783 (diff)
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.
Diffstat (limited to 'newlib/libc/stdlib')
-rw-r--r--newlib/libc/stdlib/ecvtbuf.c28
-rw-r--r--newlib/libc/stdlib/mblen.c7
-rw-r--r--newlib/libc/stdlib/mbrlen.c6
-rw-r--r--newlib/libc/stdlib/mbrtowc.c11
-rw-r--r--newlib/libc/stdlib/mbtowc.c7
-rw-r--r--newlib/libc/stdlib/rand.c16
-rw-r--r--newlib/libc/stdlib/wcrtomb.c11
-rw-r--r--newlib/libc/stdlib/wctob.c6
-rw-r--r--newlib/libc/stdlib/wctomb.c8
9 files changed, 58 insertions, 42 deletions
diff --git a/newlib/libc/stdlib/ecvtbuf.c b/newlib/libc/stdlib/ecvtbuf.c
index 2b9b9eb8a..feaa33fd0 100644
--- a/newlib/libc/stdlib/ecvtbuf.c
+++ b/newlib/libc/stdlib/ecvtbuf.c
@@ -233,6 +233,7 @@ _DEFUN (fcvtbuf, (invalue, ndigit, decpt, sign, fcvt_buf),
int *sign _AND
char *fcvt_buf)
{
+ struct _reent *reent = _REENT;
char *save;
char *p;
char *end;
@@ -240,27 +241,27 @@ _DEFUN (fcvtbuf, (invalue, ndigit, decpt, sign, fcvt_buf),
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)
return NULL;
- _REENT->_cvtlen = ndigit + 36;
- _REENT->_cvtbuf = fcvt_buf;
+ reent->_cvtlen = ndigit + 36;
+ reent->_cvtbuf = fcvt_buf;
}
- fcvt_buf = _REENT->_cvtbuf ;
+ fcvt_buf = reent->_cvtbuf ;
}
save = fcvt_buf;
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
{
- p = _dtoa_r (_REENT, invalue, 3, ndigit, decpt, sign, &end);
+ p = _dtoa_r (reent, invalue, 3, ndigit, decpt, sign, &end);
}
/* Now copy */
@@ -289,6 +290,7 @@ _DEFUN (ecvtbuf, (invalue, ndigit, decpt, sign, fcvt_buf),
int *sign _AND
char *fcvt_buf)
{
+ struct _reent *reent = _REENT;
char *save;
char *p;
char *end;
@@ -296,21 +298,21 @@ _DEFUN (ecvtbuf, (invalue, ndigit, decpt, sign, fcvt_buf),
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)
return NULL;
- _REENT->_cvtlen = ndigit + 1;
- _REENT->_cvtbuf = fcvt_buf;
+ reent->_cvtlen = ndigit + 1;
+ reent->_cvtbuf = fcvt_buf;
}
- fcvt_buf = _REENT->_cvtbuf ;
+ fcvt_buf = reent->_cvtbuf ;
}
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 */
diff --git a/newlib/libc/stdlib/mblen.c b/newlib/libc/stdlib/mblen.c
index ace23889b..4d9ac38bd 100644
--- a/newlib/libc/stdlib/mblen.c
+++ b/newlib/libc/stdlib/mblen.c
@@ -55,11 +55,12 @@ _DEFUN (mblen, (s, n),
{
#ifdef _MB_CAPABLE
int retval = 0;
+ struct _reent *reent = _REENT;
mbstate_t *state;
- _REENT_CHECK_MISC(_REENT);
- state = &(_REENT_MBLEN_STATE(_REENT));
- retval = __mbtowc (_REENT, NULL, s, n, __locale_charset (), state);
+ _REENT_CHECK_MISC(reent);
+ state = &(_REENT_MBLEN_STATE(reent));
+ retval = __mbtowc (reent, NULL, s, n, __locale_charset (), state);
if (retval < 0)
{
state->__count = 0;
diff --git a/newlib/libc/stdlib/mbrlen.c b/newlib/libc/stdlib/mbrlen.c
index ac9aa324f..4319875a1 100644
--- a/newlib/libc/stdlib/mbrlen.c
+++ b/newlib/libc/stdlib/mbrlen.c
@@ -11,8 +11,10 @@ mbrlen(const char *s, size_t n, mbstate_t *ps)
#ifdef _MB_CAPABLE
if (ps == NULL)
{
- _REENT_CHECK_MISC(_REENT);
- ps = &(_REENT_MBRLEN_STATE(_REENT));
+ struct _reent *reent = _REENT;
+
+ _REENT_CHECK_MISC(reent);
+ ps = &(_REENT_MBRLEN_STATE(reent));
}
#endif
diff --git a/newlib/libc/stdlib/mbrtowc.c b/newlib/libc/stdlib/mbrtowc.c
index e191e1158..0a8c23a9d 100644
--- a/newlib/libc/stdlib/mbrtowc.c
+++ b/newlib/libc/stdlib/mbrtowc.c
@@ -52,24 +52,25 @@ _DEFUN (mbrtowc, (pwc, s, n, ps),
return _mbrtowc_r (_REENT, pwc, s, n, ps);
#else
int retval = 0;
+ struct _reent *reent = _REENT;
#ifdef _MB_CAPABLE
if (ps == NULL)
{
- _REENT_CHECK_MISC(_REENT);
- ps = &(_REENT_MBRTOWC_STATE(_REENT));
+ _REENT_CHECK_MISC(reent);
+ ps = &(_REENT_MBRTOWC_STATE(reent));
}
#endif
if (s == NULL)
- retval = __mbtowc (_REENT, NULL, "", 1, __locale_charset (), ps);
+ retval = __mbtowc (reent, NULL, "", 1, __locale_charset (), ps);
else
- retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps);
+ retval = __mbtowc (reent, pwc, s, n, __locale_charset (), ps);
if (retval == -1)
{
ps->__count = 0;
- _REENT->_errno = EILSEQ;
+ reent->_errno = EILSEQ;
return (size_t)(-1);
}
else
diff --git a/newlib/libc/stdlib/mbtowc.c b/newlib/libc/stdlib/mbtowc.c
index 83b6a0eda..8da309e2d 100644
--- a/newlib/libc/stdlib/mbtowc.c
+++ b/newlib/libc/stdlib/mbtowc.c
@@ -64,12 +64,13 @@ _DEFUN (mbtowc, (pwc, s, n),
{
#ifdef _MB_CAPABLE
int retval = 0;
+ struct _reent *reent = _REENT;
mbstate_t *ps;
- _REENT_CHECK_MISC(_REENT);
- ps = &(_REENT_MBTOWC_STATE(_REENT));
+ _REENT_CHECK_MISC(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)
{
diff --git a/newlib/libc/stdlib/rand.c b/newlib/libc/stdlib/rand.c
index 131e5cf09..42acde4aa 100644
--- a/newlib/libc/stdlib/rand.c
+++ b/newlib/libc/stdlib/rand.c
@@ -72,20 +72,24 @@ on two different systems.
void
_DEFUN (srand, (seed), unsigned int seed)
{
- _REENT_CHECK_RAND48(_REENT);
- _REENT_RAND_NEXT(_REENT) = seed;
+ struct _reent *reent = _REENT;
+
+ _REENT_CHECK_RAND48(reent);
+ _REENT_RAND_NEXT(reent) = seed;
}
int
_DEFUN_VOID (rand)
{
+ struct _reent *reent = _REENT;
+
/* This multiplier was obtained from Knuth, D.E., "The Art of
Computer Programming," Vol 2, Seminumerical Algorithms, Third
Edition, Addison-Wesley, 1998, p. 106 (line 26) & p. 108 */
- _REENT_CHECK_RAND48(_REENT);
- _REENT_RAND_NEXT(_REENT) =
- _REENT_RAND_NEXT(_REENT) * __extension__ 6364136223846793005LL + 1;
- return (int)((_REENT_RAND_NEXT(_REENT) >> 32) & RAND_MAX);
+ _REENT_CHECK_RAND48(reent);
+ _REENT_RAND_NEXT(reent) =
+ _REENT_RAND_NEXT(reent) * __extension__ 6364136223846793005LL + 1;
+ return (int)((_REENT_RAND_NEXT(reent) >> 32) & RAND_MAX);
}
#endif /* _REENT_ONLY */
diff --git a/newlib/libc/stdlib/wcrtomb.c b/newlib/libc/stdlib/wcrtomb.c
index 60e0d89c8..b634c23ce 100644
--- a/newlib/libc/stdlib/wcrtomb.c
+++ b/newlib/libc/stdlib/wcrtomb.c
@@ -50,25 +50,26 @@ _DEFUN (wcrtomb, (s, wc, ps),
return _wcrtomb_r (_REENT, s, wc, ps);
#else
int retval = 0;
+ struct _reent *reent = _REENT;
char buf[10];
#ifdef _MB_CAPABLE
if (ps == NULL)
{
- _REENT_CHECK_MISC(_REENT);
- ps = &(_REENT_WCRTOMB_STATE(_REENT));
+ _REENT_CHECK_MISC(reent);
+ ps = &(_REENT_WCRTOMB_STATE(reent));
}
#endif
if (s == NULL)
- retval = __wctomb (_REENT, buf, L'\0', __locale_charset (), ps);
+ retval = __wctomb (reent, buf, L'\0', __locale_charset (), ps);
else
- retval = __wctomb (_REENT, s, wc, __locale_charset (), ps);
+ retval = __wctomb (reent, s, wc, __locale_charset (), ps);
if (retval == -1)
{
ps->__count = 0;
- _REENT->_errno = EILSEQ;
+ reent->_errno = EILSEQ;
return (size_t)(-1);
}
else
diff --git a/newlib/libc/stdlib/wctob.c b/newlib/libc/stdlib/wctob.c
index d97c01f24..eebaec84f 100644
--- a/newlib/libc/stdlib/wctob.c
+++ b/newlib/libc/stdlib/wctob.c
@@ -8,6 +8,7 @@
int
wctob (wint_t wc)
{
+ struct _reent *reent;
mbstate_t mbs;
unsigned char pmb[MB_LEN_MAX];
@@ -17,8 +18,9 @@ wctob (wint_t wc)
/* Put mbs in initial state. */
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;
}
diff --git a/newlib/libc/stdlib/wctomb.c b/newlib/libc/stdlib/wctomb.c
index 9e82eaaba..8d4ceb8ad 100644
--- a/newlib/libc/stdlib/wctomb.c
+++ b/newlib/libc/stdlib/wctomb.c
@@ -57,10 +57,12 @@ _DEFUN (wctomb, (s, wchar),
wchar_t wchar)
{
#ifdef _MB_CAPABLE
- _REENT_CHECK_MISC(_REENT);
+ struct _reent *reent = _REENT;
- return __wctomb (_REENT, s, wchar, __locale_charset (),
- &(_REENT_WCTOMB_STATE(_REENT)));
+ _REENT_CHECK_MISC(reent);
+
+ return __wctomb (reent, s, wchar, __locale_charset (),
+ &(_REENT_WCTOMB_STATE(reent)));
#else /* not _MB_CAPABLE */
if (s == NULL)
return 0;