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.
This commit is contained in:
Matt Joyce 2022-01-18 10:13:04 +01:00 committed by Sebastian Huber
parent d0d78e96eb
commit f3b8138239
108 changed files with 264 additions and 263 deletions

View File

@ -84,7 +84,7 @@ _wctrans_r (struct _reent *r,
return WCT_TOUPPER;
else
{
r->_errno = EINVAL;
_REENT_ERRNO(r) = EINVAL;
return 0;
}
}

View File

@ -128,7 +128,7 @@ _wctype_r (struct _reent *r,
}
/* otherwise invalid */
r->_errno = EINVAL;
_REENT_ERRNO(r) = EINVAL;
return 0;
}

View File

@ -10,7 +10,7 @@
int *
__errno ()
{
return &_REENT->_errno;
return &_REENT_ERRNO(_REENT);
}
#endif

View File

@ -211,7 +211,7 @@ _iconv_r (struct _reent *rptr,
|| (ic->handlers != &_iconv_null_conversion_handlers
&& ic->handlers != &_iconv_ucs_conversion_handlers))
{
__errno_r (rptr) = EBADF;
_REENT_ERRNO (rptr) = EBADF;
return (size_t)-1;
}
@ -257,19 +257,19 @@ _iconv_r (struct _reent *rptr,
ic->handlers->set_state (ic->data, &state_save, 1);
}
__errno_r (rptr) = E2BIG;
_REENT_ERRNO (rptr) = E2BIG;
return (size_t)-1;
}
if (*inbytesleft == 0)
{
__errno_r (rptr) = EINVAL;
_REENT_ERRNO (rptr) = EINVAL;
return (size_t)-1;
}
if (*outbytesleft == 0 || *outbuf == NULL)
{
__errno_r (rptr) = E2BIG;
_REENT_ERRNO (rptr) = E2BIG;
return (size_t)-1;
}
@ -294,7 +294,7 @@ _iconv_close_r (struct _reent *rptr,
|| (ic->handlers != &_iconv_null_conversion_handlers
&& ic->handlers != &_iconv_ucs_conversion_handlers))
{
__errno_r (rptr) = EBADF;
_REENT_ERRNO (rptr) = EBADF;
return -1;
}

View File

@ -177,7 +177,7 @@ _iconv_nls_conv (struct _reent *rptr,
|| (ic->handlers != &_iconv_null_conversion_handlers
&& ic->handlers != &_iconv_ucs_conversion_handlers))
{
__errno_r (rptr) = EBADF;
_REENT_ERRNO (rptr) = EBADF;
return (size_t)-1;
}
@ -189,7 +189,7 @@ _iconv_nls_conv (struct _reent *rptr,
if (outbytesleft == NULL || *outbytesleft == 0)
{
__errno_r (rptr) = E2BIG;
_REENT_ERRNO (rptr) = E2BIG;
return (size_t)-1;
}

View File

@ -73,7 +73,7 @@ null_conversion_convert (struct _reent *rptr,
{
result = (size_t)-1;
len = *outbytesleft;
__errno_r (rptr) = E2BIG;
_REENT_ERRNO (rptr) = E2BIG;
}
if ((flags & 1) == 0)

View File

@ -164,7 +164,7 @@ ucs_based_conversion_convert (struct _reent *rptr,
if (*outbytesleft == 0)
{
__errno_r (rptr) = E2BIG;
_REENT_ERRNO (rptr) = E2BIG;
return (size_t)-1;
}
@ -173,13 +173,13 @@ ucs_based_conversion_convert (struct _reent *rptr,
if (ch == (ucs4_t)ICONV_CES_BAD_SEQUENCE)
{
__errno_r (rptr) = EINVAL;
_REENT_ERRNO (rptr) = EINVAL;
return (size_t)-1;
}
if (ch == (ucs4_t)ICONV_CES_INVALID_CHARACTER)
{
__errno_r (rptr) = EILSEQ;
_REENT_ERRNO (rptr) = EILSEQ;
return (size_t)-1;
}
@ -196,7 +196,7 @@ ucs_based_conversion_convert (struct _reent *rptr,
{
*inbuf = inbuf_save;
*inbytesleft = inbyteslef_save;
__errno_r (rptr) = E2BIG;
_REENT_ERRNO (rptr) = E2BIG;
return (size_t)-1;
}
else if (bytes == (size_t)ICONV_CES_INVALID_CHARACTER)
@ -204,7 +204,7 @@ ucs_based_conversion_convert (struct _reent *rptr,
if (flags & ICONV_FAIL_BIT)
{
/* Generate error */
__errno_r (rptr) = EILSEQ;
_REENT_ERRNO (rptr) = EILSEQ;
return (size_t)-1;
}
/*
@ -221,7 +221,7 @@ ucs_based_conversion_convert (struct _reent *rptr,
outbytesleft);
if ((__int32_t)bytes < 0)
{
__errno_r (rptr) = E2BIG;
_REENT_ERRNO (rptr) = E2BIG;
return (size_t)-1;
}

View File

@ -26,7 +26,7 @@ extern __IMPORT char *program_invocation_name;
extern __IMPORT char *program_invocation_short_name;
#endif
#define __errno_r(ptr) ((ptr)->_errno)
#define __errno_r(ptr) _REENT_ERRNO(ptr)
#define EPERM 1 /* Not owner */
#define ENOENT 2 /* No such file or directory */

View File

@ -719,6 +719,7 @@ struct _reent
#endif /* !_REENT_SMALL */
#define _REENT_EMERGENCY(_ptr) ((_ptr)->_emergency)
#define _REENT_ERRNO(_ptr) ((_ptr)->_errno)
#define _REENT_INIT_PTR(var) \
{ memset((var), 0, sizeof(*(var))); \

View File

@ -24,7 +24,7 @@ extern int *__errno (void);
extern const char * const _sys_errlist[];
extern int _sys_nerr;
#define __errno_r(ptr) ((ptr)->_errno)
#define __errno_r(ptr) _REENT_ERRNO(ptr)
/* Adjusted to the linux asm/errno.h */
#define EPERM 1 /* Operation not permitted */

View File

@ -108,10 +108,10 @@ _strtosfix16_r (struct _reent *rptr,
{
if (isnan (dbl.d))
{
rptr->_errno = EDOM;
_REENT_ERRNO(rptr) = EDOM;
return 0;
}
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
if (word0(dbl) & Sign_bit)
return SHRT_MIN;
return SHRT_MAX;
@ -120,12 +120,12 @@ _strtosfix16_r (struct _reent *rptr,
/* check for normal saturation */
if (dbl.d >= 1.0)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return SHRT_MAX;
}
else if (dbl.d < -1.0)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return SHRT_MIN;
}
@ -152,7 +152,7 @@ _strtosfix16_r (struct _reent *rptr,
/* check if positive saturation has occurred because of rounding */
if (!sign && result < 0)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return SHRT_MAX;
}
}

View File

@ -29,10 +29,10 @@ _strtosfix32_r (struct _reent *rptr,
{
if (isnan (dbl.d))
{
rptr->_errno = EDOM;
_REENT_ERRNO(rptr) = EDOM;
return 0;
}
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
if (word0(dbl) & Sign_bit)
return LONG_MIN;
return LONG_MAX;
@ -41,12 +41,12 @@ _strtosfix32_r (struct _reent *rptr,
/* check for normal saturation */
if (dbl.d >= 1.0)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return LONG_MAX;
}
else if (dbl.d < -1.0)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return LONG_MIN;
}
@ -75,7 +75,7 @@ _strtosfix32_r (struct _reent *rptr,
/* check if positive saturation has occurred because of rounding */
if (!sign && result < 0)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return LONG_MAX;
}
}

View File

@ -32,10 +32,10 @@ _strtosfix64_r (struct _reent *rptr,
{
if (ld_type == 1)
{
rptr->_errno = EDOM;
_REENT_ERRNO(rptr) = EDOM;
return 0;
}
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
if (word0(ldbl) & Sign_bit)
return LONG_LONG_MIN;
return LONG_LONG_MAX;
@ -63,7 +63,7 @@ _strtosfix64_r (struct _reent *rptr,
{
if (exp > 0 || (exp == 0 && tmp != 0x8000000000000000LL))
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return LONG_LONG_MIN;
}
}
@ -71,7 +71,7 @@ _strtosfix64_r (struct _reent *rptr,
{
if (exp >= 0)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return LONG_LONG_MAX;
}
}
@ -88,7 +88,7 @@ _strtosfix64_r (struct _reent *rptr,
/* check if positive saturation has occurred because of rounding */
if (!sign && result < 0)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return LONG_LONG_MAX;
}
}

View File

@ -106,10 +106,10 @@ _strtoufix16_r (struct _reent *rptr,
{
if (isnan (dbl.d))
{
rptr->_errno = EDOM;
_REENT_ERRNO(rptr) = EDOM;
return 0;
}
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
if (word0(dbl) & Sign_bit)
return 0;
return USHRT_MAX;
@ -118,12 +118,12 @@ _strtoufix16_r (struct _reent *rptr,
/* check for normal saturation */
if (dbl.d >= 1.0)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return USHRT_MAX;
}
else if (dbl.d < 0)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return 0;
}
@ -147,7 +147,7 @@ _strtoufix16_r (struct _reent *rptr,
if (negexp == 0)
{
/* we have overflow which means saturation */
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return USHRT_MAX;
}
result |= (1 << (16 - negexp));

View File

@ -28,10 +28,10 @@ _strtoufix32_r (struct _reent *rptr,
{
if (isnan (dbl.d))
{
rptr->_errno = EDOM;
_REENT_ERRNO(rptr) = EDOM;
return 0;
}
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
if (word0(dbl) & Sign_bit)
return 0;
return ULONG_MAX;
@ -40,12 +40,12 @@ _strtoufix32_r (struct _reent *rptr,
/* check for normal saturation */
if (dbl.d >= 1.0)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return ULONG_MAX;
}
else if (dbl.d < 0)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return 0;
}
@ -77,7 +77,7 @@ _strtoufix32_r (struct _reent *rptr,
/* if rounding causes carry, then saturation has occurred */
if (result < tmp)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return ULONG_MAX;
}
}

View File

@ -31,10 +31,10 @@ _strtoufix64_r (struct _reent *rptr,
{
if (ld_type == 1)
{
rptr->_errno = EDOM;
_REENT_ERRNO(rptr) = EDOM;
return 0;
}
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
if (word0(ldbl) & Sign_bit)
return 0;
return ULONG_LONG_MAX;
@ -60,14 +60,14 @@ _strtoufix64_r (struct _reent *rptr,
/* check for saturation */
if (sign)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return 0;
}
else
{
if (exp > 0 || (exp == 0 && tmp >= 0x8000000000000000LL))
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return ULONG_LONG_MAX;
}
}
@ -89,7 +89,7 @@ _strtoufix64_r (struct _reent *rptr,
/* if rounding causes carry, then saturation has occurred */
if (result < tmp)
{
rptr->_errno = ERANGE;
_REENT_ERRNO(rptr) = ERANGE;
return ULONG_LONG_MAX;
}
}

View File

@ -47,7 +47,7 @@ __sfp (struct _reent *d)
return &__fp[i];
}
}
d->_errno = EMFILE;
_REENT_ERRNO(d) = EMFILE;
return NULL;
}

View File

@ -34,7 +34,7 @@ extern "C" {
extern const char * const _sys_errlist[];
extern int _sys_nerr;
#define __errno_r(ptr) ((ptr)->_errno)
#define __errno_r(ptr) _REENT_ERRNO(ptr)
/* Adjusted to the linux asm/errno.h */
#define EPERM 1 /* Operation not permitted */

View File

@ -45,7 +45,7 @@ _close_r (ptr, fd)
errno = 0;
if ((ret = _close (fd)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -54,7 +54,7 @@ _execve_r (struct _reent *ptr,
errno = 0;
if ((ret = _execve (name, argv, env)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}
@ -86,7 +86,7 @@ _fork_r (struct _reent *ptr)
errno = 0;
if ((ret = _fork ()) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}
@ -118,7 +118,7 @@ _wait_r (struct _reent *ptr,
errno = 0;
if ((ret = _wait (status)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -49,7 +49,7 @@ _fcntl_r (struct _reent *ptr,
errno = 0;
if ((ret = _fcntl (fd, cmd, arg)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -55,7 +55,7 @@ _fstat64_r (struct _reent *ptr,
errno = 0;
if ((ret = _fstat64 (fd, pstat)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -53,7 +53,7 @@ _fstat_r (ptr, fd, pstat)
errno = 0;
if ((ret = _fstat (fd, pstat)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -60,7 +60,7 @@ _gettimeofday_r (struct _reent *ptr,
errno = 0;
if ((ret = _gettimeofday (ptimeval, ptimezone)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -50,7 +50,7 @@ _isatty_r (ptr, fd)
errno = 0;
if ((ret = _isatty (fd)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -51,7 +51,7 @@ _link_r (struct _reent *ptr,
errno = 0;
if ((ret = _link (old, new)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -50,7 +50,7 @@ _lseek64_r (struct _reent *ptr,
errno = 0;
if ((ret = _lseek64 (fd, pos, whence)) == (_off64_t) -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -47,7 +47,7 @@ _lseek_r (struct _reent *ptr,
errno = 0;
if ((ret = _lseek (fd, pos, whence)) == (_off_t) -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -48,7 +48,7 @@ _mkdir_r (struct _reent *ptr,
errno = 0;
if ((ret = _mkdir (path, mode)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -52,7 +52,7 @@ _open64_r (ptr, file, flags, mode)
errno = 0;
if ((ret = _open64 (file, flags, mode)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -48,7 +48,7 @@ _open_r (struct _reent *ptr,
errno = 0;
if ((ret = _open (file, flags, mode)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -47,7 +47,7 @@ _read_r (struct _reent *ptr,
errno = 0;
if ((ret = (_ssize_t)_read (fd, buf, cnt)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -49,7 +49,7 @@ _rename_r (struct _reent *ptr,
#ifdef HAVE_RENAME
errno = 0;
if ((ret = _rename (old, new)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
#else
if (_link_r (ptr, old, new) == -1)
return -1;

View File

@ -49,7 +49,7 @@ _sbrk_r (struct _reent *ptr,
errno = 0;
if ((ret = (char *)(_sbrk (incr))) == (void *) -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -51,7 +51,7 @@ _kill_r (struct _reent *ptr,
errno = 0;
if ((ret = _kill (pid, sig)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -53,7 +53,7 @@ _stat64_r (struct _reent *ptr,
errno = 0;
if ((ret = _stat64 (file, pstat)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -53,7 +53,7 @@ _stat_r (struct _reent *ptr,
errno = 0;
if ((ret = _stat (file, pstat)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -45,7 +45,7 @@ _unlink_r (struct _reent *ptr,
errno = 0;
if ((ret = _unlink (file)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -47,7 +47,7 @@ _write_r (struct _reent *ptr,
errno = 0;
if ((ret = (_ssize_t)_write (fd, buf, cnt)) == -1 && errno != 0)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return ret;
}

View File

@ -115,7 +115,7 @@ _signal_r (struct _reent *ptr,
if (sig < 0 || sig >= NSIG)
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
return SIG_ERR;
}
@ -136,7 +136,7 @@ _raise_r (struct _reent *ptr,
if (sig < 0 || sig >= NSIG)
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
return -1;
}
@ -151,7 +151,7 @@ _raise_r (struct _reent *ptr,
return 0;
else if (func == SIG_ERR)
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
return 1;
}
else

View File

@ -42,7 +42,7 @@ _asniprintf_r (struct _reent *ptr,
for _size. */
if (len > INT_MAX)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return NULL;
}
f._bf._size = f._w = len;
@ -88,7 +88,7 @@ asniprintf (char *buf,
for _size. */
if (len > INT_MAX)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return NULL;
}
f._bf._size = f._w = len;

View File

@ -42,7 +42,7 @@ _asnprintf_r (struct _reent *__restrict ptr,
for _size. */
if (len > INT_MAX)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return NULL;
}
f._bf._size = f._w = len;
@ -94,7 +94,7 @@ asnprintf (char *__restrict buf,
for _size. */
if (len > INT_MAX)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return NULL;
}
f._bf._size = f._w = len;

View File

@ -73,7 +73,7 @@ _fdopen_r (struct _reent *ptr,
fdmode = fdflags & O_ACCMODE;
if (fdmode != O_RDWR && (fdmode != (oflags & O_ACCMODE)))
{
ptr->_errno = EBADF;
_REENT_ERRNO(ptr) = EBADF;
return 0;
}
#endif

View File

@ -137,8 +137,8 @@ __sflush_r (struct _reent *ptr,
/* Save last errno and set errno to 0, so we can check if a device
returns with a valid position -1. We restore the last errno if
no other error condition has been encountered. */
tmp_errno = ptr->_errno;
ptr->_errno = 0;
tmp_errno = _REENT_ERRNO(ptr);
_REENT_ERRNO(ptr) = 0;
/* Get the physical position we are at in the file. */
if (fp->_flags & __SOFF)
curoff = fp->_offset;
@ -152,13 +152,13 @@ __sflush_r (struct _reent *ptr,
else
#endif
curoff = fp->_seek (ptr, fp->_cookie, 0, SEEK_CUR);
if (curoff == -1L && ptr->_errno != 0)
if (curoff == -1L && _REENT_ERRNO(ptr) != 0)
{
int result = EOF;
if (ptr->_errno == ESPIPE || ptr->_errno == EINVAL)
if (_REENT_ERRNO(ptr) == ESPIPE || _REENT_ERRNO(ptr) == EINVAL)
{
result = 0;
ptr->_errno = tmp_errno;
_REENT_ERRNO(ptr) = tmp_errno;
}
else
fp->_flags |= __SERR;
@ -180,8 +180,8 @@ __sflush_r (struct _reent *ptr,
else
#endif
curoff = fp->_seek (ptr, fp->_cookie, curoff, SEEK_SET);
if (curoff != -1 || ptr->_errno == 0
|| ptr->_errno == ESPIPE || ptr->_errno == EINVAL)
if (curoff != -1 || _REENT_ERRNO(ptr) == 0
|| _REENT_ERRNO(ptr) == ESPIPE || _REENT_ERRNO(ptr) == EINVAL)
{
/* Seek successful or ignorable error condition.
We can clear read buffer now. */
@ -190,9 +190,9 @@ __sflush_r (struct _reent *ptr,
#endif
fp->_r = 0;
fp->_p = fp->_bf._base;
if ((fp->_flags & __SOFF) && (curoff != -1 || ptr->_errno == 0))
if ((fp->_flags & __SOFF) && (curoff != -1 || _REENT_ERRNO(ptr) == 0))
fp->_offset = curoff;
ptr->_errno = tmp_errno;
_REENT_ERRNO(ptr) = tmp_errno;
if (HASUB (fp))
FREEUB (ptr, fp);
}

View File

@ -73,7 +73,7 @@ fileno (FILE * f)
else
{
result = -1;
_REENT->_errno = EBADF;
_REENT_ERRNO(_REENT) = EBADF;
}
_newlib_flockfile_end (f);
return result;

View File

@ -39,7 +39,7 @@ fileno_unlocked (FILE * f)
else
{
result = -1;
_REENT->_errno = EBADF;
_REENT_ERRNO(_REENT) = EBADF;
}
return result;
}

View File

@ -179,7 +179,7 @@ __sfp (struct _reent *d)
break;
}
_newlib_sfp_lock_exit ();
d->_errno = ENOMEM;
_REENT_ERRNO(d) = ENOMEM;
return NULL;
found:

View File

@ -56,7 +56,7 @@ __sflags (struct _reent *ptr,
o = O_CREAT | O_APPEND;
break;
default: /* illegal mode */
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
return (0);
}
while (*++mode)

View File

@ -148,7 +148,7 @@ fmemwriter (struct _reent *ptr,
memcpy (c->buf + c->pos - n, buf, n - adjust);
else
{
ptr->_errno = ENOSPC;
_REENT_ERRNO(ptr) = ENOSPC;
return EOF;
}
return n;
@ -175,18 +175,18 @@ fmemseeker (struct _reent *ptr,
offset += c->eof;
if (offset < 0)
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
offset = -1;
}
else if (offset > c->max)
{
ptr->_errno = ENOSPC;
_REENT_ERRNO(ptr) = ENOSPC;
offset = -1;
}
#ifdef __LARGE64_FILES
else if ((_fpos_t) offset != offset)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
offset = -1;
}
#endif /* __LARGE64_FILES */
@ -224,12 +224,12 @@ fmemseeker64 (struct _reent *ptr,
offset += c->eof;
if (offset < 0)
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
offset = -1;
}
else if (offset > c->max)
{
ptr->_errno = ENOSPC;
_REENT_ERRNO(ptr) = ENOSPC;
offset = -1;
}
else
@ -277,7 +277,7 @@ _fmemopen_r (struct _reent *ptr,
return NULL;
if (!size || !(buf || flags & __SRW))
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
return NULL;
}
if ((fp = __sfp (ptr)) == NULL)

View File

@ -107,7 +107,7 @@ fcreader (struct _reent *ptr,
fccookie *c = (fccookie *) cookie;
errno = 0;
if ((result = c->readfn (c->cookie, buf, n)) < 0 && errno)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return result;
}
@ -129,7 +129,7 @@ fcwriter (struct _reent *ptr,
}
errno = 0;
if ((result = c->writefn (c->cookie, buf, n)) < 0 && errno)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return result;
}
@ -148,11 +148,11 @@ fcseeker (struct _reent *ptr,
errno = 0;
if (c->seekfn (c->cookie, &offset, whence) < 0 && errno)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
#ifdef __LARGE64_FILES
else if ((_fpos_t)offset != offset)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
offset = -1;
}
#endif /* __LARGE64_FILES */
@ -170,7 +170,7 @@ fcseeker64 (struct _reent *ptr,
fccookie *c = (fccookie *) cookie;
errno = 0;
if (c->seekfn (c->cookie, &offset, whence) < 0 && errno)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return (_fpos64_t) offset;
}
#endif /* __LARGE64_FILES */
@ -185,7 +185,7 @@ fccloser (struct _reent *ptr,
{
errno = 0;
if ((result = c->closefn (c->cookie)) < 0 && errno)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
}
_free_r (ptr, c);
return result;
@ -207,7 +207,7 @@ _fopencookie_r (struct _reent *ptr,
if (((flags & (__SRD | __SRW)) && !functions.read)
|| ((flags & (__SWR | __SRW)) && !functions.write))
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
return NULL;
}
if ((fp = __sfp (ptr)) == NULL)

View File

@ -72,7 +72,7 @@ _fpurge_r (struct _reent *ptr,
t = fp->_flags;
if (!t)
{
ptr->_errno = EBADF;
_REENT_ERRNO(ptr) = EBADF;
_newlib_flockfile_exit (fp);
return EOF;
}

View File

@ -137,7 +137,7 @@ _freopen_r (struct _reent *ptr,
if (file != NULL)
{
f = _open_r (ptr, (char *) file, oflags, 0666);
e = ptr->_errno;
e = _REENT_ERRNO(ptr);
}
else
{
@ -205,7 +205,7 @@ _freopen_r (struct _reent *ptr,
{ /* did not get it after all */
__sfp_lock_acquire ();
fp->_flags = 0; /* set it free */
ptr->_errno = e; /* restore in case _close clobbered */
_REENT_ERRNO(ptr) = e; /* restore in case _close clobbered */
if (!(oflags2 & __SNLK))
_funlockfile (fp);
#ifndef __SINGLE_THREAD__

View File

@ -128,7 +128,7 @@ _fseeko_r (struct _reent *ptr,
if ((seekfn = fp->_seek) == NULL)
{
ptr->_errno = ESPIPE; /* ??? */
_REENT_ERRNO(ptr) = ESPIPE; /* ??? */
_newlib_flockfile_exit (fp);
return EOF;
}
@ -178,7 +178,7 @@ _fseeko_r (struct _reent *ptr,
break;
default:
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
_newlib_flockfile_exit (fp);
return (EOF);
}

View File

@ -92,7 +92,7 @@ _ftell_r (struct _reent *ptr,
if ((long)pos != pos)
{
pos = -1;
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
}
return (long)pos;
}

View File

@ -96,7 +96,7 @@ _ftello_r (struct _reent * ptr,
if (fp->_seek == NULL)
{
ptr->_errno = ESPIPE;
_REENT_ERRNO(ptr) = ESPIPE;
_newlib_flockfile_exit (fp);
return (_off_t) -1;
}

View File

@ -113,7 +113,7 @@ funreader (struct _reent *ptr,
funcookie *c = (funcookie *) cookie;
errno = 0;
if ((result = c->readfn (c->cookie, buf, n)) < 0 && errno)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return result;
}
@ -127,7 +127,7 @@ funwriter (struct _reent *ptr,
funcookie *c = (funcookie *) cookie;
errno = 0;
if ((result = c->writefn (c->cookie, buf, n)) < 0 && errno)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return result;
}
@ -142,15 +142,15 @@ funseeker (struct _reent *ptr,
fpos_t result;
errno = 0;
if ((result = c->seekfn (c->cookie, (fpos_t) off, whence)) < 0 && errno)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
#else /* __LARGE64_FILES */
_fpos64_t result;
errno = 0;
if ((result = c->seekfn (c->cookie, (_fpos64_t) off, whence)) < 0 && errno)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
else if ((_fpos_t)result != result)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
result = -1;
}
#endif /* __LARGE64_FILES */
@ -168,7 +168,7 @@ funseeker64 (struct _reent *ptr,
funcookie *c = (funcookie *) cookie;
errno = 0;
if ((result = c->seekfn (c->cookie, off, whence)) < 0 && errno)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
return result;
}
#endif /* __LARGE64_FILES */
@ -183,7 +183,7 @@ funcloser (struct _reent *ptr,
{
errno = 0;
if ((result = c->closefn (c->cookie)) < 0 && errno)
ptr->_errno = errno;
_REENT_ERRNO(ptr) = errno;
}
_free_r (ptr, c);
return result;
@ -202,7 +202,7 @@ _funopen_r (struct _reent *ptr,
if (!readfn && !writefn)
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
return NULL;
}
if ((fp = __sfp (ptr)) == NULL)

View File

@ -145,7 +145,7 @@ __sfvwrite_r (struct _reent *ptr,
str = (unsigned char *)_malloc_r (ptr, newsize);
if (!str)
{
ptr->_errno = ENOMEM;
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
memcpy (str, fp->_bf._base, curpos);
@ -162,7 +162,7 @@ __sfvwrite_r (struct _reent *ptr,
_free_r (ptr, fp->_bf._base);
fp->_flags &= ~__SMBF;
/* Ensure correct errno, even if free changed it. */
ptr->_errno = ENOMEM;
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
}

View File

@ -159,7 +159,7 @@ _gettemp (struct _reent *ptr,
continue;
if (trv - path < suffixlen)
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
return 0;
}
trv -= suffixlen;
@ -171,7 +171,7 @@ _gettemp (struct _reent *ptr,
}
if (end - trv < 6)
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
return 0;
}
@ -195,7 +195,7 @@ _gettemp (struct _reent *ptr,
return (0);
if (!(sbuf.st_mode & S_IFDIR))
{
ptr->_errno = ENOTDIR;
_REENT_ERRNO(ptr) = ENOTDIR;
return (0);
}
*trv = '/';
@ -211,10 +211,10 @@ _gettemp (struct _reent *ptr,
#ifdef HAVE_MKDIR
if (_mkdir_r (ptr, path, 0700) == 0)
return 1;
if (ptr->_errno != EEXIST)
if (_REENT_ERRNO(ptr) != EEXIST)
return 0;
#else /* !HAVE_MKDIR */
ptr->_errno = ENOSYS;
_REENT_ERRNO(ptr) = ENOSYS;
return 0;
#endif /* !HAVE_MKDIR */
}
@ -225,7 +225,7 @@ _gettemp (struct _reent *ptr,
if ((*doopen = _open_r (ptr, path, O_CREAT | O_EXCL | O_RDWR | flags,
0600)) >= 0)
return 1;
if (ptr->_errno != EEXIST)
if (_REENT_ERRNO(ptr) != EEXIST)
return 0;
}
#ifdef __USE_INTERNAL_STAT64
@ -233,7 +233,7 @@ _gettemp (struct _reent *ptr,
#else
else if (_stat_r (ptr, path, &sbuf))
#endif
return (ptr->_errno == ENOENT ? 1 : 0);
return (_REENT_ERRNO(ptr) == ENOENT ? 1 : 0);
/* tricky little algorithm for backward compatibility */
for (trv = start;;)

View File

@ -201,7 +201,7 @@ __ssputs_r (struct _reent *ptr,
str = (unsigned char *)_malloc_r (ptr, newsize);
if (!str)
{
ptr->_errno = ENOMEM;
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
memcpy (str, fp->_bf._base, curpos);
@ -215,7 +215,7 @@ __ssputs_r (struct _reent *ptr,
/* Free unneeded buffer. */
_free_r (ptr, fp->_bf._base);
/* Ensure correct errno, even if free changed it. */
ptr->_errno = ENOMEM;
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
}
@ -291,7 +291,7 @@ __ssprint_r (struct _reent *ptr,
str = (unsigned char *)_malloc_r (ptr, newsize);
if (!str)
{
ptr->_errno = ENOMEM;
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
memcpy (str, fp->_bf._base, curpos);
@ -306,7 +306,7 @@ __ssprint_r (struct _reent *ptr,
/* Free unneeded buffer. */
_free_r (ptr, fp->_bf._base);
/* Ensure correct errno, even if free changed it. */
ptr->_errno = ENOMEM;
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
}
@ -501,7 +501,7 @@ _VFPRINTF_R (struct _reent *data,
fp->_bf._base = fp->_p = _malloc_r (data, 64);
if (!fp->_p)
{
data->_errno = ENOMEM;
_REENT_ERRNO(data) = ENOMEM;
return EOF;
}
fp->_bf._size = 64;

View File

@ -105,7 +105,7 @@ memwriter (struct _reent *ptr,
big that user cannot do ftello. */
if (sizeof (OFF_T) == sizeof (size_t) && (ssize_t) (c->pos + n) < 0)
{
ptr->_errno = EFBIG;
_REENT_ERRNO(ptr) = EFBIG;
return EOF;
}
/* Grow the buffer, if necessary. Choose a geometric growth factor
@ -160,18 +160,18 @@ memseeker (struct _reent *ptr,
offset += c->eof;
if (offset < 0)
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
offset = -1;
}
else if ((size_t) offset != offset)
{
ptr->_errno = ENOSPC;
_REENT_ERRNO(ptr) = ENOSPC;
offset = -1;
}
#ifdef __LARGE64_FILES
else if ((_fpos_t) offset != offset)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
offset = -1;
}
#endif /* __LARGE64_FILES */
@ -227,12 +227,12 @@ memseeker64 (struct _reent *ptr,
offset += c->eof;
if (offset < 0)
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
offset = -1;
}
else if ((size_t) offset != offset)
{
ptr->_errno = ENOSPC;
_REENT_ERRNO(ptr) = ENOSPC;
offset = -1;
}
else
@ -301,7 +301,7 @@ internal_open_memstream_r (struct _reent *ptr,
if (!buf || !size)
{
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
return NULL;
}
if ((fp = __sfp (ptr)) == NULL)

View File

@ -90,7 +90,7 @@ _perror_r (struct _reent *ptr,
WRITE_STR (": ");
}
if ((error = _strerror_r (ptr, ptr->_errno, 1, &dummy)) != NULL)
if ((error = _strerror_r (ptr, _REENT_ERRNO(ptr), 1, &dummy)) != NULL)
WRITE_STR (error);
#ifdef __SCLE

View File

@ -56,7 +56,7 @@ __srefill_r (struct _reent * ptr,
{
if ((fp->_flags & __SRW) == 0)
{
ptr->_errno = EBADF;
_REENT_ERRNO(ptr) = EBADF;
fp->_flags |= __SERR;
return EOF;
}

View File

@ -38,7 +38,7 @@ _sniprintf_r (struct _reent *ptr,
if (size > INT_MAX)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return EOF;
}
f._flags = __SWR | __SSTR;
@ -49,7 +49,7 @@ _sniprintf_r (struct _reent *ptr,
ret = _svfiprintf_r (ptr, &f, fmt, ap);
va_end (ap);
if (ret < EOF)
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
if (size > 0)
*f._p = 0;
return (ret);
@ -69,7 +69,7 @@ sniprintf (char *str,
if (size > INT_MAX)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return EOF;
}
f._flags = __SWR | __SSTR;
@ -80,7 +80,7 @@ sniprintf (char *str,
ret = _svfiprintf_r (ptr, &f, fmt, ap);
va_end (ap);
if (ret < EOF)
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
if (size > 0)
*f._p = 0;
return (ret);

View File

@ -37,7 +37,7 @@ _snprintf_r (struct _reent *ptr,
if (size > INT_MAX)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return EOF;
}
f._flags = __SWR | __SSTR;
@ -48,7 +48,7 @@ _snprintf_r (struct _reent *ptr,
ret = _svfprintf_r (ptr, &f, fmt, ap);
va_end (ap);
if (ret < EOF)
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
if (size > 0)
*f._p = 0;
return (ret);
@ -74,7 +74,7 @@ snprintf (char *__restrict str,
if (size > INT_MAX)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return EOF;
}
f._flags = __SWR | __SSTR;
@ -85,7 +85,7 @@ snprintf (char *__restrict str,
ret = _svfprintf_r (ptr, &f, fmt, ap);
va_end (ap);
if (ret < EOF)
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
if (size > 0)
*f._p = 0;
return (ret);

View File

@ -564,7 +564,7 @@ _swprintf_r (struct _reent *ptr,
if (size > INT_MAX / sizeof (wchar_t))
{
ptr->_errno = EOVERFLOW; /* POSIX extension */
_REENT_ERRNO(ptr) = EOVERFLOW; /* POSIX extension */
return EOF;
}
f._flags = __SWR | __SSTR;
@ -584,7 +584,7 @@ _swprintf_r (struct _reent *ptr,
/* _svfwprintf_r() returns how many wide characters it would have printed
* if there were enough space. Return an error if too big to fit in str,
* unlike snprintf, which returns the size needed. */
ptr->_errno = EOVERFLOW; /* POSIX extension */
_REENT_ERRNO(ptr) = EOVERFLOW; /* POSIX extension */
ret = -1;
}
return (ret);
@ -604,7 +604,7 @@ swprintf (wchar_t *__restrict str,
if (size > INT_MAX / sizeof (wchar_t))
{
ptr->_errno = EOVERFLOW; /* POSIX extension */
_REENT_ERRNO(ptr) = EOVERFLOW; /* POSIX extension */
return EOF;
}
f._flags = __SWR | __SSTR;
@ -624,7 +624,7 @@ swprintf (wchar_t *__restrict str,
/* _svfwprintf_r() returns how many wide characters it would have printed
* if there were enough space. Return an error if too big to fit in str,
* unlike snprintf, which returns the size needed. */
ptr->_errno = EOVERFLOW; /* POSIX extension */
_REENT_ERRNO(ptr) = EOVERFLOW; /* POSIX extension */
ret = -1;
}
return (ret);

View File

@ -65,15 +65,15 @@ _tmpfile_r (struct _reent *ptr)
fd = _open_r (ptr, f, O_RDWR | O_CREAT | O_EXCL | O_BINARY,
S_IRUSR | S_IWUSR);
}
while (fd < 0 && ptr->_errno == EEXIST);
while (fd < 0 && _REENT_ERRNO(ptr) == EEXIST);
if (fd < 0)
return NULL;
fp = _fdopen_r (ptr, fd, "wb+");
e = ptr->_errno;
e = _REENT_ERRNO(ptr);
if (!fp)
_close_r (ptr, fd);
(void) _remove_r (ptr, f);
ptr->_errno = e;
_REENT_ERRNO(ptr) = e;
return fp;
}

View File

@ -104,7 +104,7 @@ worker (struct _reent *ptr,
t = _open_r (ptr, result, O_RDONLY, 0);
if (t == -1)
{
if (ptr->_errno == ENOSYS)
if (_REENT_ERRNO(ptr) == ENOSYS)
{
result[0] = '\0';
return 0;

View File

@ -42,7 +42,7 @@ _vasniprintf_r (struct _reent *ptr,
for _size. */
if (len > INT_MAX)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return NULL;
}
f._bf._size = f._w = len;

View File

@ -42,7 +42,7 @@ _vasnprintf_r (struct _reent *ptr,
for _size. */
if (len > INT_MAX)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return NULL;
}
f._bf._size = f._w = len;

View File

@ -222,7 +222,7 @@ __ssputs_r (struct _reent *ptr,
str = (unsigned char *)_malloc_r (ptr, newsize);
if (!str)
{
ptr->_errno = ENOMEM;
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
memcpy (str, fp->_bf._base, curpos);
@ -237,7 +237,7 @@ __ssputs_r (struct _reent *ptr,
_free_r (ptr, fp->_bf._base);
/* Ensure correct errno, even if free
* changed it. */
ptr->_errno = ENOMEM;
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
}
@ -306,7 +306,7 @@ __ssprint_r (struct _reent *ptr,
str = (unsigned char *)_malloc_r (ptr, newsize);
if (!str)
{
ptr->_errno = ENOMEM;
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
memcpy (str, fp->_bf._base, curpos);
@ -321,7 +321,7 @@ __ssprint_r (struct _reent *ptr,
_free_r (ptr, fp->_bf._base);
/* Ensure correct errno, even if free
* changed it. */
ptr->_errno = ENOMEM;
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
}
@ -868,7 +868,7 @@ _VFPRINTF_R (struct _reent *data,
fp->_bf._base = fp->_p = _malloc_r (data, 64);
if (!fp->_p)
{
data->_errno = ENOMEM;
_REENT_ERRNO(data) = ENOMEM;
return EOF;
}
fp->_bf._size = 64;
@ -1374,7 +1374,7 @@ reswitch: switch (ch) {
case 'm': /* extension */
{
int dummy;
cp = _strerror_r (data, data->_errno, 1, &dummy);
cp = _strerror_r (data, _REENT_ERRNO(data), 1, &dummy);
}
flags &= ~LONGINT;
goto string;

View File

@ -774,7 +774,7 @@ __SVFSCANF_R (struct _reent *rptr,
width = 0;
goto again;
}
rptr->_errno = EINVAL;
_REENT_ERRNO(rptr) = EINVAL;
goto input_failure;
#endif /* !_NO_POS_ARGS */

View File

@ -611,7 +611,7 @@ _VFWPRINTF_R (struct _reent *data,
fp->_bf._base = fp->_p = _malloc_r (data, 64);
if (!fp->_p)
{
data->_errno = ENOMEM;
_REENT_ERRNO(data) = ENOMEM;
return EOF;
}
fp->_bf._size = 64;
@ -1119,7 +1119,7 @@ reswitch: switch (ch) {
case L'm': /* GNU extension */
{
int dummy;
cp = (wchar_t *) _strerror_r (data, data->_errno, 1, &dummy);
cp = (wchar_t *) _strerror_r (data, _REENT_ERRNO(data), 1, &dummy);
}
flags &= ~LONGINT;
goto string;

View File

@ -682,7 +682,7 @@ __SVFWSCANF_R (struct _reent *rptr,
width = 0;
goto again;
}
rptr->_errno = EINVAL;
_REENT_ERRNO(rptr) = EINVAL;
goto input_failure;
#endif /* !_NO_POS_ARGS */

View File

@ -54,7 +54,7 @@ _vsniprintf_r (struct _reent *ptr,
if (size > INT_MAX)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return EOF;
}
f._flags = __SWR | __SSTR;
@ -63,7 +63,7 @@ _vsniprintf_r (struct _reent *ptr,
f._file = -1; /* No file. */
ret = _svfiprintf_r (ptr, &f, fmt, ap);
if (ret < EOF)
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
if (size > 0)
*f._p = 0;
return ret;

View File

@ -60,7 +60,7 @@ _vsnprintf_r (struct _reent *ptr,
if (size > INT_MAX)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return EOF;
}
f._flags = __SWR | __SSTR;
@ -69,7 +69,7 @@ _vsnprintf_r (struct _reent *ptr,
f._file = -1; /* No file. */
ret = _svfprintf_r (ptr, &f, fmt, ap);
if (ret < EOF)
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
if (size > 0)
*f._p = 0;
return ret;

View File

@ -42,7 +42,7 @@ _vswprintf_r (struct _reent *ptr,
if (size > INT_MAX / sizeof (wchar_t))
{
ptr->_errno = EOVERFLOW; /* POSIX extension */
_REENT_ERRNO(ptr) = EOVERFLOW; /* POSIX extension */
return EOF;
}
f._flags = __SWR | __SSTR;
@ -60,7 +60,7 @@ _vswprintf_r (struct _reent *ptr,
/* _svfwprintf_r() returns how many wide characters it would have printed
* if there were enough space. Return an error if too big to fit in str,
* unlike snprintf, which returns the size needed. */
ptr->_errno = EOVERFLOW; /* POSIX extension */
_REENT_ERRNO(ptr) = EOVERFLOW; /* POSIX extension */
ret = -1;
}
return ret;

View File

@ -45,7 +45,7 @@ __swsetup_r (struct _reent *ptr,
{
if ((fp->_flags & __SRW) == 0)
{
ptr->_errno = EBADF;
_REENT_ERRNO(ptr) = EBADF;
fp->_flags |= __SERR;
return EOF;
}

View File

@ -55,7 +55,7 @@ _fdopen64_r (struct _reent *ptr,
fdmode = fdflags & O_ACCMODE;
if (fdmode != O_RDWR && (fdmode != (oflags & O_ACCMODE)))
{
ptr->_errno = EBADF;
_REENT_ERRNO(ptr) = EBADF;
return 0;
}
#endif

View File

@ -138,7 +138,7 @@ _freopen64_r (struct _reent *ptr,
if (file != NULL)
{
f = _open64_r (ptr, (char *) file, oflags, 0666);
e = ptr->_errno;
e = _REENT_ERRNO(ptr);
}
else
{
@ -206,7 +206,7 @@ _freopen64_r (struct _reent *ptr,
{ /* did not get it after all */
__sfp_lock_acquire ();
fp->_flags = 0; /* set it free */
ptr->_errno = e; /* restore in case _close clobbered */
_REENT_ERRNO(ptr) = e; /* restore in case _close clobbered */
if (!(oflags2 & __SNLK))
_funlockfile (fp);
#ifndef __SINGLE_THREAD__

View File

@ -102,7 +102,7 @@ _fseeko64_r (struct _reent *ptr,
{
if ((_off_t) offset != offset)
{
ptr->_errno = EOVERFLOW;
_REENT_ERRNO(ptr) = EOVERFLOW;
return EOF;
}
return (_off64_t) _fseeko_r (ptr, fp, offset, whence);
@ -129,7 +129,7 @@ _fseeko64_r (struct _reent *ptr,
if ((seekfn = fp->_seek64) == NULL)
{
ptr->_errno = ESPIPE; /* ??? */
_REENT_ERRNO(ptr) = ESPIPE; /* ??? */
_newlib_flockfile_exit(fp);
return EOF;
}
@ -179,7 +179,7 @@ _fseeko64_r (struct _reent *ptr,
break;
default:
ptr->_errno = EINVAL;
_REENT_ERRNO(ptr) = EINVAL;
_newlib_flockfile_exit(fp);
return (EOF);
}

View File

@ -93,7 +93,7 @@ _ftello64_r (struct _reent *ptr,
if (fp->_seek64 == NULL)
{
ptr->_errno = ESPIPE;
_REENT_ERRNO(ptr) = ESPIPE;
_newlib_flockfile_exit(fp);
return (_off64_t) -1;
}

View File

@ -68,15 +68,15 @@ _tmpfile64_r (struct _reent *ptr)
fd = _open64_r (ptr, f, O_RDWR | O_CREAT | O_EXCL | O_BINARY,
S_IRUSR | S_IWUSR);
}
while (fd < 0 && ptr->_errno == EEXIST);
while (fd < 0 && _REENT_ERRNO(ptr) == EEXIST);
if (fd < 0)
return NULL;
fp = _fdopen64_r (ptr, fd, "wb+");
e = ptr->_errno;
e = _REENT_ERRNO(ptr);
if (!fp)
_close_r (ptr, fd);
(void) _remove_r (ptr, f);
ptr->_errno = e;
_REENT_ERRNO(ptr) = e;
return fp;
}

View File

@ -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;
}

View File

@ -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

View File

@ -126,7 +126,7 @@ _mbsnrtowcs_r (struct _reent *r,
else
{
ps->__count = 0;
r->_errno = EILSEQ;
_REENT_ERRNO(r) = EILSEQ;
return (size_t)-1;
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

Some files were not shown because too many files have changed in this diff Show More