Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Joyce <matthew.joyce@embedded-brains.de>2022-01-18 12:13:04 +0300
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-07-13 07:55:41 +0300
commitf3b8138239d3ba34c4ecaa4305b0fbd7eb4e28a5 (patch)
tree80cc7a629134d4568bf5dc71898266555a6863b0 /newlib/libc/stdio64
parentd0d78e96ebf4187fb9362465f1a397680447046f (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/stdio64')
-rw-r--r--newlib/libc/stdio64/fdopen64.c2
-rw-r--r--newlib/libc/stdio64/freopen64.c4
-rw-r--r--newlib/libc/stdio64/fseeko64.c6
-rw-r--r--newlib/libc/stdio64/ftello64.c2
-rw-r--r--newlib/libc/stdio64/tmpfile64.c6
5 files changed, 10 insertions, 10 deletions
diff --git a/newlib/libc/stdio64/fdopen64.c b/newlib/libc/stdio64/fdopen64.c
index 9d9645b36..d93b3d4d8 100644
--- a/newlib/libc/stdio64/fdopen64.c
+++ b/newlib/libc/stdio64/fdopen64.c
@@ -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
diff --git a/newlib/libc/stdio64/freopen64.c b/newlib/libc/stdio64/freopen64.c
index e6ba64f7d..4d1e9b76c 100644
--- a/newlib/libc/stdio64/freopen64.c
+++ b/newlib/libc/stdio64/freopen64.c
@@ -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__
diff --git a/newlib/libc/stdio64/fseeko64.c b/newlib/libc/stdio64/fseeko64.c
index 3087bef9e..c5b30aed0 100644
--- a/newlib/libc/stdio64/fseeko64.c
+++ b/newlib/libc/stdio64/fseeko64.c
@@ -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);
}
diff --git a/newlib/libc/stdio64/ftello64.c b/newlib/libc/stdio64/ftello64.c
index 6fb76c3ef..cd00def46 100644
--- a/newlib/libc/stdio64/ftello64.c
+++ b/newlib/libc/stdio64/ftello64.c
@@ -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;
}
diff --git a/newlib/libc/stdio64/tmpfile64.c b/newlib/libc/stdio64/tmpfile64.c
index 18a38d65c..35b035c91 100644
--- a/newlib/libc/stdio64/tmpfile64.c
+++ b/newlib/libc/stdio64/tmpfile64.c
@@ -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;
}