diff options
Diffstat (limited to 'newlib/libc/stdio')
37 files changed, 105 insertions, 105 deletions
diff --git a/newlib/libc/stdio/asniprintf.c b/newlib/libc/stdio/asniprintf.c index 0bfe00d..97e7774 100644 --- a/newlib/libc/stdio/asniprintf.c +++ b/newlib/libc/stdio/asniprintf.c @@ -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; diff --git a/newlib/libc/stdio/asnprintf.c b/newlib/libc/stdio/asnprintf.c index f657f9e..f825561 100644 --- a/newlib/libc/stdio/asnprintf.c +++ b/newlib/libc/stdio/asnprintf.c @@ -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; diff --git a/newlib/libc/stdio/fdopen.c b/newlib/libc/stdio/fdopen.c index ef942c2..3481154 100644 --- a/newlib/libc/stdio/fdopen.c +++ b/newlib/libc/stdio/fdopen.c @@ -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 diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c index bbec4a1..d51e901 100644 --- a/newlib/libc/stdio/fflush.c +++ b/newlib/libc/stdio/fflush.c @@ -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); } diff --git a/newlib/libc/stdio/fileno.c b/newlib/libc/stdio/fileno.c index 10fc6e2..4faa6a8 100644 --- a/newlib/libc/stdio/fileno.c +++ b/newlib/libc/stdio/fileno.c @@ -73,7 +73,7 @@ fileno (FILE * f) else { result = -1; - _REENT->_errno = EBADF; + _REENT_ERRNO(_REENT) = EBADF; } _newlib_flockfile_end (f); return result; diff --git a/newlib/libc/stdio/fileno_u.c b/newlib/libc/stdio/fileno_u.c index 830a07d..f3940e8 100644 --- a/newlib/libc/stdio/fileno_u.c +++ b/newlib/libc/stdio/fileno_u.c @@ -39,7 +39,7 @@ fileno_unlocked (FILE * f) else { result = -1; - _REENT->_errno = EBADF; + _REENT_ERRNO(_REENT) = EBADF; } return result; } diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index ee991ed..c7a4a94 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -179,7 +179,7 @@ __sfp (struct _reent *d) break; } _newlib_sfp_lock_exit (); - d->_errno = ENOMEM; + _REENT_ERRNO(d) = ENOMEM; return NULL; found: diff --git a/newlib/libc/stdio/flags.c b/newlib/libc/stdio/flags.c index 7bbd501..d686fa0 100644 --- a/newlib/libc/stdio/flags.c +++ b/newlib/libc/stdio/flags.c @@ -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) diff --git a/newlib/libc/stdio/fmemopen.c b/newlib/libc/stdio/fmemopen.c index 0d04352..886ba7e 100644 --- a/newlib/libc/stdio/fmemopen.c +++ b/newlib/libc/stdio/fmemopen.c @@ -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) diff --git a/newlib/libc/stdio/fopencookie.c b/newlib/libc/stdio/fopencookie.c index 0861528..ab406a8 100644 --- a/newlib/libc/stdio/fopencookie.c +++ b/newlib/libc/stdio/fopencookie.c @@ -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) diff --git a/newlib/libc/stdio/fpurge.c b/newlib/libc/stdio/fpurge.c index 2e4f61e..93ac0e2 100644 --- a/newlib/libc/stdio/fpurge.c +++ b/newlib/libc/stdio/fpurge.c @@ -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; } diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index 29ba5b7..f0da9a1 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -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__ diff --git a/newlib/libc/stdio/fseeko.c b/newlib/libc/stdio/fseeko.c index 13df28b..6fcc8ef 100644 --- a/newlib/libc/stdio/fseeko.c +++ b/newlib/libc/stdio/fseeko.c @@ -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); } diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c index c540c43..f68b3af 100644 --- a/newlib/libc/stdio/ftell.c +++ b/newlib/libc/stdio/ftell.c @@ -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; } diff --git a/newlib/libc/stdio/ftello.c b/newlib/libc/stdio/ftello.c index 3df200c..d62d48a 100644 --- a/newlib/libc/stdio/ftello.c +++ b/newlib/libc/stdio/ftello.c @@ -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; } diff --git a/newlib/libc/stdio/funopen.c b/newlib/libc/stdio/funopen.c index a1c0d76..4ed5019 100644 --- a/newlib/libc/stdio/funopen.c +++ b/newlib/libc/stdio/funopen.c @@ -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) diff --git a/newlib/libc/stdio/fvwrite.c b/newlib/libc/stdio/fvwrite.c index 587ffac..34361cb 100644 --- a/newlib/libc/stdio/fvwrite.c +++ b/newlib/libc/stdio/fvwrite.c @@ -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; } } diff --git a/newlib/libc/stdio/mktemp.c b/newlib/libc/stdio/mktemp.c index 3514818..2659681 100644 --- a/newlib/libc/stdio/mktemp.c +++ b/newlib/libc/stdio/mktemp.c @@ -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;;) diff --git a/newlib/libc/stdio/nano-vfprintf.c b/newlib/libc/stdio/nano-vfprintf.c index 838804e..0d42a94 100644 --- a/newlib/libc/stdio/nano-vfprintf.c +++ b/newlib/libc/stdio/nano-vfprintf.c @@ -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; diff --git a/newlib/libc/stdio/open_memstream.c b/newlib/libc/stdio/open_memstream.c index ed71b1c..e3a52ed 100644 --- a/newlib/libc/stdio/open_memstream.c +++ b/newlib/libc/stdio/open_memstream.c @@ -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) diff --git a/newlib/libc/stdio/perror.c b/newlib/libc/stdio/perror.c index eda7e99..2033a6f 100644 --- a/newlib/libc/stdio/perror.c +++ b/newlib/libc/stdio/perror.c @@ -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 diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c index 91e79e8..7bd3880 100644 --- a/newlib/libc/stdio/refill.c +++ b/newlib/libc/stdio/refill.c @@ -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; } diff --git a/newlib/libc/stdio/sniprintf.c b/newlib/libc/stdio/sniprintf.c index 375a397..b05ffcb 100644 --- a/newlib/libc/stdio/sniprintf.c +++ b/newlib/libc/stdio/sniprintf.c @@ -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); diff --git a/newlib/libc/stdio/snprintf.c b/newlib/libc/stdio/snprintf.c index 50d7ddd..4a3084b 100644 --- a/newlib/libc/stdio/snprintf.c +++ b/newlib/libc/stdio/snprintf.c @@ -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); diff --git a/newlib/libc/stdio/swprintf.c b/newlib/libc/stdio/swprintf.c index ec7e089..634b22b 100644 --- a/newlib/libc/stdio/swprintf.c +++ b/newlib/libc/stdio/swprintf.c @@ -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); diff --git a/newlib/libc/stdio/tmpfile.c b/newlib/libc/stdio/tmpfile.c index f209a3e..5fe6e3b 100644 --- a/newlib/libc/stdio/tmpfile.c +++ b/newlib/libc/stdio/tmpfile.c @@ -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; } diff --git a/newlib/libc/stdio/tmpnam.c b/newlib/libc/stdio/tmpnam.c index 3bd5b6a..7379a76 100644 --- a/newlib/libc/stdio/tmpnam.c +++ b/newlib/libc/stdio/tmpnam.c @@ -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; diff --git a/newlib/libc/stdio/vasniprintf.c b/newlib/libc/stdio/vasniprintf.c index edfbd22..b24cd96 100644 --- a/newlib/libc/stdio/vasniprintf.c +++ b/newlib/libc/stdio/vasniprintf.c @@ -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; diff --git a/newlib/libc/stdio/vasnprintf.c b/newlib/libc/stdio/vasnprintf.c index 1fbf5a1..b3787ec 100644 --- a/newlib/libc/stdio/vasnprintf.c +++ b/newlib/libc/stdio/vasnprintf.c @@ -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; diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 32ebb14..6a198e2 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -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; diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c index 0376925..cfeea98 100644 --- a/newlib/libc/stdio/vfscanf.c +++ b/newlib/libc/stdio/vfscanf.c @@ -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 */ diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.c index 7384b37..7807a12 100644 --- a/newlib/libc/stdio/vfwprintf.c +++ b/newlib/libc/stdio/vfwprintf.c @@ -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; diff --git a/newlib/libc/stdio/vfwscanf.c b/newlib/libc/stdio/vfwscanf.c index e9e00df..df966f9 100644 --- a/newlib/libc/stdio/vfwscanf.c +++ b/newlib/libc/stdio/vfwscanf.c @@ -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 */ diff --git a/newlib/libc/stdio/vsniprintf.c b/newlib/libc/stdio/vsniprintf.c index a8b272e..e7625ff 100644 --- a/newlib/libc/stdio/vsniprintf.c +++ b/newlib/libc/stdio/vsniprintf.c @@ -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; diff --git a/newlib/libc/stdio/vsnprintf.c b/newlib/libc/stdio/vsnprintf.c index 5c617a8..ecf82ea 100644 --- a/newlib/libc/stdio/vsnprintf.c +++ b/newlib/libc/stdio/vsnprintf.c @@ -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; diff --git a/newlib/libc/stdio/vswprintf.c b/newlib/libc/stdio/vswprintf.c index 89795ed..08a8545 100644 --- a/newlib/libc/stdio/vswprintf.c +++ b/newlib/libc/stdio/vswprintf.c @@ -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; diff --git a/newlib/libc/stdio/wsetup.c b/newlib/libc/stdio/wsetup.c index 6a820f1..0fd9690 100644 --- a/newlib/libc/stdio/wsetup.c +++ b/newlib/libc/stdio/wsetup.c @@ -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; } |