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/machine
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/machine')
-rw-r--r--newlib/libc/machine/cris/sys/errno.h2
-rw-r--r--newlib/libc/machine/powerpc/strtosfix16.c10
-rw-r--r--newlib/libc/machine/powerpc/strtosfix32.c10
-rw-r--r--newlib/libc/machine/powerpc/strtosfix64.c10
-rw-r--r--newlib/libc/machine/powerpc/strtoufix16.c10
-rw-r--r--newlib/libc/machine/powerpc/strtoufix32.c10
-rw-r--r--newlib/libc/machine/powerpc/strtoufix64.c10
-rw-r--r--newlib/libc/machine/spu/stdio.c2
-rw-r--r--newlib/libc/machine/spu/sys/errno.h2
9 files changed, 33 insertions, 33 deletions
diff --git a/newlib/libc/machine/cris/sys/errno.h b/newlib/libc/machine/cris/sys/errno.h
index 3d573015d..c8113ed73 100644
--- a/newlib/libc/machine/cris/sys/errno.h
+++ b/newlib/libc/machine/cris/sys/errno.h
@@ -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 */
diff --git a/newlib/libc/machine/powerpc/strtosfix16.c b/newlib/libc/machine/powerpc/strtosfix16.c
index 3fba45409..5475de88e 100644
--- a/newlib/libc/machine/powerpc/strtosfix16.c
+++ b/newlib/libc/machine/powerpc/strtosfix16.c
@@ -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;
}
}
diff --git a/newlib/libc/machine/powerpc/strtosfix32.c b/newlib/libc/machine/powerpc/strtosfix32.c
index b21de9ea1..6941be5d5 100644
--- a/newlib/libc/machine/powerpc/strtosfix32.c
+++ b/newlib/libc/machine/powerpc/strtosfix32.c
@@ -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;
}
}
diff --git a/newlib/libc/machine/powerpc/strtosfix64.c b/newlib/libc/machine/powerpc/strtosfix64.c
index 16032128f..9da3ffaee 100644
--- a/newlib/libc/machine/powerpc/strtosfix64.c
+++ b/newlib/libc/machine/powerpc/strtosfix64.c
@@ -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;
}
}
diff --git a/newlib/libc/machine/powerpc/strtoufix16.c b/newlib/libc/machine/powerpc/strtoufix16.c
index 9b16268bb..415652dd2 100644
--- a/newlib/libc/machine/powerpc/strtoufix16.c
+++ b/newlib/libc/machine/powerpc/strtoufix16.c
@@ -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));
diff --git a/newlib/libc/machine/powerpc/strtoufix32.c b/newlib/libc/machine/powerpc/strtoufix32.c
index 7d03f8c9b..4340c711f 100644
--- a/newlib/libc/machine/powerpc/strtoufix32.c
+++ b/newlib/libc/machine/powerpc/strtoufix32.c
@@ -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;
}
}
diff --git a/newlib/libc/machine/powerpc/strtoufix64.c b/newlib/libc/machine/powerpc/strtoufix64.c
index a2f0484b3..205706856 100644
--- a/newlib/libc/machine/powerpc/strtoufix64.c
+++ b/newlib/libc/machine/powerpc/strtoufix64.c
@@ -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;
}
}
diff --git a/newlib/libc/machine/spu/stdio.c b/newlib/libc/machine/spu/stdio.c
index 87e4c406d..1dcc88b60 100644
--- a/newlib/libc/machine/spu/stdio.c
+++ b/newlib/libc/machine/spu/stdio.c
@@ -47,7 +47,7 @@ __sfp (struct _reent *d)
return &__fp[i];
}
}
- d->_errno = EMFILE;
+ _REENT_ERRNO(d) = EMFILE;
return NULL;
}
diff --git a/newlib/libc/machine/spu/sys/errno.h b/newlib/libc/machine/spu/sys/errno.h
index b008ff6f4..8758283eb 100644
--- a/newlib/libc/machine/spu/sys/errno.h
+++ b/newlib/libc/machine/spu/sys/errno.h
@@ -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 */