aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdlib
diff options
context:
space:
mode:
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 2b9b9eb..feaa33f 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 ace2388..4d9ac38 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 ac9aa32..4319875 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 e191e11..0a8c23a 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 83b6a0e..8da309e 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 131e5cf..42acde4 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 60e0d89..b634c23 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 d97c01f..eebaec8 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 9e82eaa..8d4ceb8 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;