diff options
author | Matt Joyce <matthew.joyce@embedded-brains.de> | 2022-01-18 12:13:04 +0300 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2022-07-13 07:55:41 +0300 |
commit | f3b8138239d3ba34c4ecaa4305b0fbd7eb4e28a5 (patch) | |
tree | 80cc7a629134d4568bf5dc71898266555a6863b0 /newlib/libc/stdlib | |
parent | d0d78e96ebf4187fb9362465f1a397680447046f (diff) |
Add _REENT_ERRNO(ptr)
Add a _REENT_ERRNO() macro to encapsulate the access to the
_errno member of struct reent. This will help to replace the
structure member with a thread-local storage object in a follow
up patch.
Replace uses of __errno_r() with _REENT_ERRNO(). Keep __errno_r() macro for
potential users outside of Newlib.
Diffstat (limited to 'newlib/libc/stdlib')
-rw-r--r-- | newlib/libc/stdlib/__adjust.c | 4 | ||||
-rw-r--r-- | newlib/libc/stdlib/mbrtowc.c | 4 | ||||
-rw-r--r-- | newlib/libc/stdlib/mbsnrtowcs.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdlib/mbtowc_r.c | 34 | ||||
-rw-r--r-- | newlib/libc/stdlib/strtod.c | 10 | ||||
-rw-r--r-- | newlib/libc/stdlib/strtoimax.c | 4 | ||||
-rw-r--r-- | newlib/libc/stdlib/strtol.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdlib/strtoll.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdlib/strtoul.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdlib/strtoull.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdlib/strtoumax.c | 4 | ||||
-rw-r--r-- | newlib/libc/stdlib/wcrtomb.c | 4 | ||||
-rw-r--r-- | newlib/libc/stdlib/wcsnrtombs.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdlib/wcstod.c | 4 | ||||
-rw-r--r-- | newlib/libc/stdlib/wcstoimax.c | 4 | ||||
-rw-r--r-- | newlib/libc/stdlib/wcstol.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdlib/wcstoll.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdlib/wcstoul.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdlib/wcstoull.c | 4 | ||||
-rw-r--r-- | newlib/libc/stdlib/wcstoumax.c | 4 | ||||
-rw-r--r-- | newlib/libc/stdlib/wctomb_r.c | 18 |
21 files changed, 58 insertions, 58 deletions
diff --git a/newlib/libc/stdlib/__adjust.c b/newlib/libc/stdlib/__adjust.c index 4c478f30b..ab6f125b9 100644 --- a/newlib/libc/stdlib/__adjust.c +++ b/newlib/libc/stdlib/__adjust.c @@ -21,12 +21,12 @@ __adjust (struct _reent *ptr, if (dexp > MAXE) { - ptr->_errno = ERANGE; + _REENT_ERRNO(ptr) = ERANGE; return (sign) ? -HUGE_VAL : HUGE_VAL; } else if (dexp < MINE) { - ptr->_errno = ERANGE; + _REENT_ERRNO(ptr) = ERANGE; return 0.0; } diff --git a/newlib/libc/stdlib/mbrtowc.c b/newlib/libc/stdlib/mbrtowc.c index 65284a0eb..521b7a5f4 100644 --- a/newlib/libc/stdlib/mbrtowc.c +++ b/newlib/libc/stdlib/mbrtowc.c @@ -32,7 +32,7 @@ _mbrtowc_r (struct _reent *ptr, if (retval == -1) { ps->__count = 0; - ptr->_errno = EILSEQ; + _REENT_ERRNO(ptr) = EILSEQ; return (size_t)(-1); } else @@ -68,7 +68,7 @@ mbrtowc (wchar_t *__restrict pwc, if (retval == -1) { ps->__count = 0; - reent->_errno = EILSEQ; + _REENT_ERRNO(reent) = EILSEQ; return (size_t)(-1); } else diff --git a/newlib/libc/stdlib/mbsnrtowcs.c b/newlib/libc/stdlib/mbsnrtowcs.c index d3ce25084..8f94b1da5 100644 --- a/newlib/libc/stdlib/mbsnrtowcs.c +++ b/newlib/libc/stdlib/mbsnrtowcs.c @@ -126,7 +126,7 @@ _mbsnrtowcs_r (struct _reent *r, else { ps->__count = 0; - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return (size_t)-1; } } diff --git a/newlib/libc/stdlib/mbtowc_r.c b/newlib/libc/stdlib/mbtowc_r.c index 920a7ea3c..ca876f9a0 100644 --- a/newlib/libc/stdlib/mbtowc_r.c +++ b/newlib/libc/stdlib/mbtowc_r.c @@ -39,7 +39,7 @@ __ascii_mbtowc (struct _reent *r, #ifdef __CYGWIN__ if ((wchar_t)*t >= 0x80) { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } #endif @@ -117,7 +117,7 @@ ___iso_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n, *pwc = __iso_8859_conv[iso_idx][*t - 0xa0]; if (*pwc == 0) /* Invalid character */ { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } return 1; @@ -290,7 +290,7 @@ ___cp_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n, *pwc = __cp_conv[cp_idx][*t - 0x80]; if (*pwc == 0) /* Invalid character */ { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } return 1; @@ -578,13 +578,13 @@ __utf8_mbtowc (struct _reent *r, ch = t[i++]; if (ch < 0x80 || ch > 0xbf) { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } if (state->__value.__wchb[0] < 0xc2) { /* overlong UTF-8 sequence */ - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } state->__count = 0; @@ -607,12 +607,12 @@ __utf8_mbtowc (struct _reent *r, if (state->__value.__wchb[0] == 0xe0 && ch < 0xa0) { /* overlong UTF-8 sequence */ - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } if (ch < 0x80 || ch > 0xbf) { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } state->__value.__wchb[1] = ch; @@ -625,7 +625,7 @@ __utf8_mbtowc (struct _reent *r, ch = t[i++]; if (ch < 0x80 || ch > 0xbf) { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } state->__count = 0; @@ -651,12 +651,12 @@ __utf8_mbtowc (struct _reent *r, || (state->__value.__wchb[0] == 0xf4 && ch >= 0x90)) { /* overlong UTF-8 sequence or result is > 0x10ffff */ - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } if (ch < 0x80 || ch > 0xbf) { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } state->__value.__wchb[1] = ch; @@ -669,7 +669,7 @@ __utf8_mbtowc (struct _reent *r, ch = (state->__count == 2) ? t[i++] : state->__value.__wchb[2]; if (ch < 0x80 || ch > 0xbf) { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } state->__value.__wchb[2] = ch; @@ -702,7 +702,7 @@ __utf8_mbtowc (struct _reent *r, ch = t[i++]; if (ch < 0x80 || ch > 0xbf) { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } tmp = (wint_t)((state->__value.__wchb[0] & 0x07) << 18) @@ -719,7 +719,7 @@ __utf8_mbtowc (struct _reent *r, return i; } - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } @@ -769,7 +769,7 @@ __sjis_mbtowc (struct _reent *r, } else { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } } @@ -836,7 +836,7 @@ __eucjp_mbtowc (struct _reent *r, } else { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } } @@ -851,7 +851,7 @@ __eucjp_mbtowc (struct _reent *r, } else { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } } @@ -955,7 +955,7 @@ __jis_mbtowc (struct _reent *r, break; case ERROR: default: - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } diff --git a/newlib/libc/stdlib/strtod.c b/newlib/libc/stdlib/strtod.c index cd0222481..9156ed7d6 100644 --- a/newlib/libc/stdlib/strtod.c +++ b/newlib/libc/stdlib/strtod.c @@ -595,7 +595,7 @@ _strtod_l (struct _reent *ptr, const char *__restrict s00, char **__restrict se, if (e1 > DBL_MAX_10_EXP) { ovfl: #ifndef NO_ERRNO - ptr->_errno = ERANGE; + _REENT_ERRNO(ptr) = ERANGE; #endif /* Can't trust HUGE_VAL */ #ifdef IEEE_Arith @@ -702,7 +702,7 @@ _strtod_l (struct _reent *ptr, const char *__restrict s00, char **__restrict se, undfl: dval(rv) = 0.; #ifndef NO_ERRNO - ptr->_errno = ERANGE; + _REENT_ERRNO(ptr) = ERANGE; #endif if (bd0) goto retfree; @@ -1249,7 +1249,7 @@ _strtod_l (struct _reent *ptr, const char *__restrict s00, char **__restrict se, #ifndef NO_ERRNO /* try to avoid the bug of testing an 8087 register value */ if ((dword0(rv) & Exp_mask) == 0) - ptr->_errno = ERANGE; + _REENT_ERRNO(ptr) = ERANGE; #endif } #endif /* Avoid_Underflow */ @@ -1303,7 +1303,7 @@ strtof_l (const char *__restrict s00, char **__restrict se, locale_t loc) float retval = (float) val; #ifndef NO_ERRNO if (isinf (retval) && !isinf (val)) - _REENT->_errno = ERANGE; + _REENT_ERRNO(_REENT) = ERANGE; #endif return retval; } @@ -1340,7 +1340,7 @@ strtof (const char *__restrict s00, float retval = (float) val; #ifndef NO_ERRNO if ((isinf (retval) && !isinf (val)) || (isdenormf(retval) && !isdenorm(val))) - _REENT->_errno = ERANGE; + _REENT_ERRNO(_REENT) = ERANGE; #endif return retval; } diff --git a/newlib/libc/stdlib/strtoimax.c b/newlib/libc/stdlib/strtoimax.c index c3f27df2e..a64b7da66 100644 --- a/newlib/libc/stdlib/strtoimax.c +++ b/newlib/libc/stdlib/strtoimax.c @@ -136,10 +136,10 @@ _strtoimax_l(struct _reent *rptr, const char * __restrict nptr, } if (any < 0) { acc = neg ? INTMAX_MIN : INTMAX_MAX; - rptr->_errno = ERANGE; + _REENT_ERRNO(rptr) = ERANGE; } else if (!any) { noconv: - rptr->_errno = EINVAL; + _REENT_ERRNO(rptr) = EINVAL; } else if (neg) acc = -acc; if (endptr != NULL) diff --git a/newlib/libc/stdlib/strtol.c b/newlib/libc/stdlib/strtol.c index 6383c27e8..09d4333ed 100644 --- a/newlib/libc/stdlib/strtol.c +++ b/newlib/libc/stdlib/strtol.c @@ -204,7 +204,7 @@ _strtol_l (struct _reent *rptr, const char *__restrict nptr, } if (any < 0) { acc = neg ? LONG_MIN : LONG_MAX; - rptr->_errno = ERANGE; + _REENT_ERRNO(rptr) = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) diff --git a/newlib/libc/stdlib/strtoll.c b/newlib/libc/stdlib/strtoll.c index 9aa2c747b..0f2fa5315 100644 --- a/newlib/libc/stdlib/strtoll.c +++ b/newlib/libc/stdlib/strtoll.c @@ -201,7 +201,7 @@ _strtoll_l (struct _reent *rptr, const char *__restrict nptr, } if (any < 0) { acc = neg ? LONG_LONG_MIN : LONG_LONG_MAX; - rptr->_errno = ERANGE; + _REENT_ERRNO(rptr) = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) diff --git a/newlib/libc/stdlib/strtoul.c b/newlib/libc/stdlib/strtoul.c index 4191e43ec..d31bde5d2 100644 --- a/newlib/libc/stdlib/strtoul.c +++ b/newlib/libc/stdlib/strtoul.c @@ -178,7 +178,7 @@ _strtoul_l (struct _reent *rptr, const char *__restrict nptr, } if (any < 0) { acc = ULONG_MAX; - rptr->_errno = ERANGE; + _REENT_ERRNO(rptr) = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) diff --git a/newlib/libc/stdlib/strtoull.c b/newlib/libc/stdlib/strtoull.c index 10018ca0d..943de6b83 100644 --- a/newlib/libc/stdlib/strtoull.c +++ b/newlib/libc/stdlib/strtoull.c @@ -176,7 +176,7 @@ _strtoull_l (struct _reent *rptr, const char *__restrict nptr, } if (any < 0) { acc = ULONG_LONG_MAX; - rptr->_errno = ERANGE; + _REENT_ERRNO(rptr) = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) diff --git a/newlib/libc/stdlib/strtoumax.c b/newlib/libc/stdlib/strtoumax.c index cf1a427fe..adcf2b338 100644 --- a/newlib/libc/stdlib/strtoumax.c +++ b/newlib/libc/stdlib/strtoumax.c @@ -115,10 +115,10 @@ _strtoumax_l(struct _reent *rptr, const char * __restrict nptr, } if (any < 0) { acc = UINTMAX_MAX; - rptr->_errno = ERANGE; + _REENT_ERRNO(rptr) = ERANGE; } else if (!any) { noconv: - rptr->_errno = EINVAL; + _REENT_ERRNO(rptr) = EINVAL; } else if (neg) acc = -acc; if (endptr != NULL) diff --git a/newlib/libc/stdlib/wcrtomb.c b/newlib/libc/stdlib/wcrtomb.c index 97436cb74..6d670e23a 100644 --- a/newlib/libc/stdlib/wcrtomb.c +++ b/newlib/libc/stdlib/wcrtomb.c @@ -31,7 +31,7 @@ _wcrtomb_r (struct _reent *ptr, if (retval == -1) { ps->__count = 0; - ptr->_errno = EILSEQ; + _REENT_ERRNO(ptr) = EILSEQ; return (size_t)(-1); } else @@ -67,7 +67,7 @@ wcrtomb (char *__restrict s, if (retval == -1) { ps->__count = 0; - reent->_errno = EILSEQ; + _REENT_ERRNO(reent) = EILSEQ; return (size_t)(-1); } else diff --git a/newlib/libc/stdlib/wcsnrtombs.c b/newlib/libc/stdlib/wcsnrtombs.c index 43dd2f3e6..dfd974f24 100644 --- a/newlib/libc/stdlib/wcsnrtombs.c +++ b/newlib/libc/stdlib/wcsnrtombs.c @@ -104,7 +104,7 @@ _wcsnrtombs_l (struct _reent *r, char *dst, const wchar_t **src, size_t nwc, int bytes = loc->wctomb (r, buff, *pwcs, ps); if (bytes == -1) { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; ps->__count = 0; return (size_t)-1; } diff --git a/newlib/libc/stdlib/wcstod.c b/newlib/libc/stdlib/wcstod.c index 375ffe288..7b0983470 100644 --- a/newlib/libc/stdlib/wcstod.c +++ b/newlib/libc/stdlib/wcstod.c @@ -257,7 +257,7 @@ wcstof_l (const wchar_t *__restrict nptr, wchar_t **__restrict endptr, float retval = (float) val; #ifndef NO_ERRNO if (isinf (retval) && !isinf (val)) - _REENT->_errno = ERANGE; + _REENT_ERRNO(_REENT) = ERANGE; #endif return retval; } @@ -272,7 +272,7 @@ wcstof (const wchar_t *__restrict nptr, float retval = (float) val; #ifndef NO_ERRNO if (isinf (retval) && !isinf (val)) - _REENT->_errno = ERANGE; + _REENT_ERRNO(_REENT) = ERANGE; #endif return retval; diff --git a/newlib/libc/stdlib/wcstoimax.c b/newlib/libc/stdlib/wcstoimax.c index 02ab1c1f4..0c939c978 100644 --- a/newlib/libc/stdlib/wcstoimax.c +++ b/newlib/libc/stdlib/wcstoimax.c @@ -122,10 +122,10 @@ _wcstoimax_l(struct _reent *rptr, const wchar_t * __restrict nptr, } if (any < 0) { acc = neg ? INTMAX_MIN : INTMAX_MAX; - rptr->_errno = ERANGE; + _REENT_ERRNO(rptr) = ERANGE; } else if (!any) { noconv: - rptr->_errno = EINVAL; + _REENT_ERRNO(rptr) = EINVAL; } else if (neg) acc = -acc; if (endptr != NULL) diff --git a/newlib/libc/stdlib/wcstol.c b/newlib/libc/stdlib/wcstol.c index 8b6de3873..2a8c28f97 100644 --- a/newlib/libc/stdlib/wcstol.c +++ b/newlib/libc/stdlib/wcstol.c @@ -200,7 +200,7 @@ _wcstol_l (struct _reent *rptr, const wchar_t *nptr, wchar_t **endptr, } if (any < 0) { acc = neg ? LONG_MIN : LONG_MAX; - rptr->_errno = ERANGE; + _REENT_ERRNO(rptr) = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) diff --git a/newlib/libc/stdlib/wcstoll.c b/newlib/libc/stdlib/wcstoll.c index c0e5dc747..34a7e376d 100644 --- a/newlib/libc/stdlib/wcstoll.c +++ b/newlib/libc/stdlib/wcstoll.c @@ -200,7 +200,7 @@ _wcstoll_l (struct _reent *rptr, const wchar_t *nptr, wchar_t **endptr, } if (any < 0) { acc = neg ? LONG_LONG_MIN : LONG_LONG_MAX; - rptr->_errno = ERANGE; + _REENT_ERRNO(rptr) = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) diff --git a/newlib/libc/stdlib/wcstoul.c b/newlib/libc/stdlib/wcstoul.c index fe3c87867..9c78fc3b4 100644 --- a/newlib/libc/stdlib/wcstoul.c +++ b/newlib/libc/stdlib/wcstoul.c @@ -179,7 +179,7 @@ _wcstoul_l (struct _reent *rptr, const wchar_t *nptr, wchar_t **endptr, } if (any < 0) { acc = ULONG_MAX; - rptr->_errno = ERANGE; + _REENT_ERRNO(rptr) = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) diff --git a/newlib/libc/stdlib/wcstoull.c b/newlib/libc/stdlib/wcstoull.c index 5ac325790..09422fa97 100644 --- a/newlib/libc/stdlib/wcstoull.c +++ b/newlib/libc/stdlib/wcstoull.c @@ -150,7 +150,7 @@ _wcstoull_l (struct _reent *rptr, const wchar_t *nptr, wchar_t **endptr, register int neg = 0, any, cutlim; if(base < 0 || base == 1 || base > 36) { - rptr->_errno = EINVAL; + _REENT_ERRNO(rptr) = EINVAL; return(0ULL); } /* @@ -195,7 +195,7 @@ _wcstoull_l (struct _reent *rptr, const wchar_t *nptr, wchar_t **endptr, } if (any < 0) { acc = ULLONG_MAX; - rptr->_errno = ERANGE; + _REENT_ERRNO(rptr) = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) diff --git a/newlib/libc/stdlib/wcstoumax.c b/newlib/libc/stdlib/wcstoumax.c index 17b5275fa..623f5b947 100644 --- a/newlib/libc/stdlib/wcstoumax.c +++ b/newlib/libc/stdlib/wcstoumax.c @@ -121,10 +121,10 @@ _wcstoumax_l(struct _reent *rptr,const wchar_t * __restrict nptr, } if (any < 0) { acc = UINTMAX_MAX; - rptr->_errno = ERANGE; + _REENT_ERRNO(rptr) = ERANGE; } else if (!any) { noconv: - rptr->_errno = EINVAL; + _REENT_ERRNO(rptr) = EINVAL; } else if (neg) acc = -acc; if (endptr != NULL) diff --git a/newlib/libc/stdlib/wctomb_r.c b/newlib/libc/stdlib/wctomb_r.c index b4799341e..a7f87cd9e 100644 --- a/newlib/libc/stdlib/wctomb_r.c +++ b/newlib/libc/stdlib/wctomb_r.c @@ -35,7 +35,7 @@ __ascii_wctomb (struct _reent *r, if ((size_t)wchar >= 0x100) #endif { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } @@ -133,7 +133,7 @@ __utf8_wctomb (struct _reent *r, return 4; } - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } @@ -165,7 +165,7 @@ __sjis_wctomb (struct _reent *r, } else { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } } @@ -204,7 +204,7 @@ __eucjp_wctomb (struct _reent *r, } else { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } } @@ -244,7 +244,7 @@ __jis_wctomb (struct _reent *r, *s = (char)char2; return cnt + 2; } - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } if (state->__state != 0) @@ -284,14 +284,14 @@ ___iso_wctomb (struct _reent *r, char *s, wchar_t _wchar, int iso_idx, *s = (char) (mb + 0xa0); return 1; } - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } } if ((size_t)wchar >= 0x100) { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } @@ -440,14 +440,14 @@ ___cp_wctomb (struct _reent *r, char *s, wchar_t _wchar, int cp_idx, *s = (char) (mb + 0x80); return 1; } - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } } if ((size_t)wchar >= 0x100) { - r->_errno = EILSEQ; + _REENT_ERRNO(r) = EILSEQ; return -1; } |