From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id C748F3857350 for ; Tue, 21 Jun 2022 12:49:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C748F3857350 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embedded-brains.de Received: from sslproxy02.your-server.de ([78.47.166.47]) by dedi548.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1o3dK4-0003ZN-6I for newlib@sourceware.org; Tue, 21 Jun 2022 14:49:36 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o3dK4-000Lse-BU for newlib@sourceware.org; Tue, 21 Jun 2022 14:49:36 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 120E94800AD for ; Tue, 21 Jun 2022 14:49:36 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 7RNiZyb7F1ex for ; Tue, 21 Jun 2022 14:49:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 651C24801E2 for ; Tue, 21 Jun 2022 14:49:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id MfL7q8TfIRiy for ; Tue, 21 Jun 2022 14:49:34 +0200 (CEST) Received: from zimbra.eb.localhost (unknown [192.168.96.242]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 22C554801DF for ; Tue, 21 Jun 2022 14:49:34 +0200 (CEST) From: Sebastian Huber To: newlib@sourceware.org Subject: [PATCH 03/14] Add _REENT_ERRNO(ptr) Date: Tue, 21 Jun 2022 14:49:20 +0200 Message-Id: <20220621124931.36450-4-sebastian.huber@embedded-brains.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220621124931.36450-1-sebastian.huber@embedded-brains.de> References: <20220621124931.36450-1-sebastian.huber@embedded-brains.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.103.6/26579/Tue Jun 21 10:15:30 2022) X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jun 2022 12:49:44 -0000 From: Matt Joyce 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. --- newlib/libc/ctype/wctrans.c | 2 +- newlib/libc/ctype/wctype.c | 2 +- newlib/libc/errno/errno.c | 2 +- newlib/libc/include/sys/errno.h | 2 +- newlib/libc/include/sys/reent.h | 1 + newlib/libc/machine/cris/sys/errno.h | 2 +- newlib/libc/machine/powerpc/strtosfix16.c | 10 +++---- newlib/libc/machine/powerpc/strtosfix32.c | 10 +++---- newlib/libc/machine/powerpc/strtosfix64.c | 10 +++---- newlib/libc/machine/powerpc/strtoufix16.c | 10 +++---- newlib/libc/machine/powerpc/strtoufix32.c | 10 +++---- newlib/libc/machine/powerpc/strtoufix64.c | 10 +++---- newlib/libc/machine/spu/stdio.c | 2 +- newlib/libc/machine/spu/sys/errno.h | 2 +- newlib/libc/reent/closer.c | 2 +- newlib/libc/reent/execr.c | 6 ++-- newlib/libc/reent/fcntlr.c | 2 +- newlib/libc/reent/fstat64r.c | 2 +- newlib/libc/reent/fstatr.c | 2 +- newlib/libc/reent/gettimeofdayr.c | 2 +- newlib/libc/reent/isattyr.c | 2 +- newlib/libc/reent/linkr.c | 2 +- newlib/libc/reent/lseek64r.c | 2 +- newlib/libc/reent/lseekr.c | 2 +- newlib/libc/reent/mkdirr.c | 2 +- newlib/libc/reent/open64r.c | 2 +- newlib/libc/reent/openr.c | 2 +- newlib/libc/reent/readr.c | 2 +- newlib/libc/reent/renamer.c | 2 +- newlib/libc/reent/sbrkr.c | 2 +- newlib/libc/reent/signalr.c | 2 +- newlib/libc/reent/stat64r.c | 2 +- newlib/libc/reent/statr.c | 2 +- newlib/libc/reent/unlinkr.c | 2 +- newlib/libc/reent/writer.c | 2 +- newlib/libc/signal/signal.c | 6 ++-- newlib/libc/stdio/asniprintf.c | 4 +-- newlib/libc/stdio/asnprintf.c | 4 +-- newlib/libc/stdio/fdopen.c | 2 +- newlib/libc/stdio/fflush.c | 18 ++++++------ newlib/libc/stdio/fileno.c | 2 +- newlib/libc/stdio/fileno_u.c | 2 +- newlib/libc/stdio/findfp.c | 2 +- newlib/libc/stdio/flags.c | 2 +- newlib/libc/stdio/fmemopen.c | 14 +++++----- newlib/libc/stdio/fopencookie.c | 14 +++++----- newlib/libc/stdio/fpurge.c | 2 +- newlib/libc/stdio/freopen.c | 4 +-- newlib/libc/stdio/fseeko.c | 4 +-- newlib/libc/stdio/ftell.c | 2 +- newlib/libc/stdio/ftello.c | 2 +- newlib/libc/stdio/funopen.c | 16 +++++------ newlib/libc/stdio/fvwrite.c | 4 +-- newlib/libc/stdio/mktemp.c | 14 +++++----- newlib/libc/stdio/nano-vfprintf.c | 10 +++---- newlib/libc/stdio/open_memstream.c | 14 +++++----- newlib/libc/stdio/perror.c | 2 +- newlib/libc/stdio/refill.c | 2 +- newlib/libc/stdio/sniprintf.c | 8 +++--- newlib/libc/stdio/snprintf.c | 8 +++--- newlib/libc/stdio/swprintf.c | 8 +++--- newlib/libc/stdio/tmpfile.c | 6 ++-- newlib/libc/stdio/tmpnam.c | 2 +- newlib/libc/stdio/vasniprintf.c | 2 +- newlib/libc/stdio/vasnprintf.c | 2 +- newlib/libc/stdio/vfprintf.c | 12 ++++---- newlib/libc/stdio/vfscanf.c | 2 +- newlib/libc/stdio/vfwprintf.c | 4 +-- newlib/libc/stdio/vfwscanf.c | 2 +- newlib/libc/stdio/vsniprintf.c | 4 +-- newlib/libc/stdio/vsnprintf.c | 4 +-- newlib/libc/stdio/vswprintf.c | 4 +-- newlib/libc/stdio/wsetup.c | 2 +- newlib/libc/stdio64/fdopen64.c | 2 +- newlib/libc/stdio64/freopen64.c | 4 +-- newlib/libc/stdio64/fseeko64.c | 6 ++-- newlib/libc/stdio64/ftello64.c | 2 +- newlib/libc/stdio64/tmpfile64.c | 6 ++-- newlib/libc/stdlib/__adjust.c | 4 +-- newlib/libc/stdlib/mbrtowc.c | 4 +-- newlib/libc/stdlib/mbsnrtowcs.c | 2 +- newlib/libc/stdlib/mbtowc_r.c | 34 +++++++++++------------ newlib/libc/stdlib/strtod.c | 10 +++---- newlib/libc/stdlib/strtoimax.c | 4 +-- newlib/libc/stdlib/strtol.c | 2 +- newlib/libc/stdlib/strtoll.c | 2 +- newlib/libc/stdlib/strtoul.c | 2 +- newlib/libc/stdlib/strtoull.c | 2 +- newlib/libc/stdlib/strtoumax.c | 4 +-- newlib/libc/stdlib/wcrtomb.c | 4 +-- newlib/libc/stdlib/wcsnrtombs.c | 2 +- newlib/libc/stdlib/wcstod.c | 4 +-- newlib/libc/stdlib/wcstoimax.c | 4 +-- newlib/libc/stdlib/wcstol.c | 2 +- newlib/libc/stdlib/wcstoll.c | 2 +- newlib/libc/stdlib/wcstoul.c | 2 +- newlib/libc/stdlib/wcstoull.c | 4 +-- newlib/libc/stdlib/wcstoumax.c | 4 +-- newlib/libc/stdlib/wctomb_r.c | 18 ++++++------ newlib/libc/string/strerror.c | 2 +- winsup/cygwin/cygerrno.h | 4 +-- winsup/cygwin/errno.cc | 4 +-- winsup/cygwin/strfuncs.cc | 12 ++++---- winsup/cygwin/syscalls.cc | 4 +-- 104 files changed, 250 insertions(+), 249 deletions(-) diff --git a/newlib/libc/ctype/wctrans.c b/newlib/libc/ctype/wctrans.c index 4a58df152..dbb103d38 100644 --- a/newlib/libc/ctype/wctrans.c +++ b/newlib/libc/ctype/wctrans.c @@ -84,7 +84,7 @@ _wctrans_r (struct _reent *r, return WCT_TOUPPER; else { - r->_errno =3D EINVAL; + _REENT_ERRNO(r) =3D EINVAL; return 0; } } diff --git a/newlib/libc/ctype/wctype.c b/newlib/libc/ctype/wctype.c index 5f2ae7a25..8c7afc731 100644 --- a/newlib/libc/ctype/wctype.c +++ b/newlib/libc/ctype/wctype.c @@ -128,7 +128,7 @@ _wctype_r (struct _reent *r, } =20 /* otherwise invalid */ - r->_errno =3D EINVAL; + _REENT_ERRNO(r) =3D EINVAL; return 0; } =20 diff --git a/newlib/libc/errno/errno.c b/newlib/libc/errno/errno.c index fd1743d73..70402924b 100644 --- a/newlib/libc/errno/errno.c +++ b/newlib/libc/errno/errno.c @@ -10,7 +10,7 @@ int * __errno () { - return &_REENT->_errno; + return &_REENT_ERRNO(_REENT); } =20 #endif diff --git a/newlib/libc/include/sys/errno.h b/newlib/libc/include/sys/er= rno.h index 025b461d4..995f30e05 100644 --- a/newlib/libc/include/sys/errno.h +++ b/newlib/libc/include/sys/errno.h @@ -26,7 +26,7 @@ extern __IMPORT char *program_invocation_name; extern __IMPORT char *program_invocation_short_name; #endif =20 -#define __errno_r(ptr) ((ptr)->_errno) +#define __errno_r(ptr) _REENT_ERRNO(ptr) =20 #define EPERM 1 /* Not owner */ #define ENOENT 2 /* No such file or directory */ diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/re= ent.h index 2b0ff46b7..70a987100 100644 --- a/newlib/libc/include/sys/reent.h +++ b/newlib/libc/include/sys/reent.h @@ -719,6 +719,7 @@ struct _reent #endif /* !_REENT_SMALL */ =20 #define _REENT_EMERGENCY(_ptr) ((_ptr)->_emergency) +#define _REENT_ERRNO(_ptr) ((_ptr)->_errno) =20 #define _REENT_INIT_PTR(var) \ { memset((var), 0, sizeof(*(var))); \ diff --git a/newlib/libc/machine/cris/sys/errno.h b/newlib/libc/machine/c= ris/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; =20 -#define __errno_r(ptr) ((ptr)->_errno) +#define __errno_r(ptr) _REENT_ERRNO(ptr) =20 /* 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/mach= ine/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 =3D EDOM; + _REENT_ERRNO(rptr) =3D EDOM; return 0; } - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D 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 >=3D 1.0) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return SHRT_MAX; } else if (dbl.d < -1.0) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return SHRT_MIN; } =20 @@ -152,7 +152,7 @@ _strtosfix16_r (struct _reent *rptr, /* check if positive saturation has occurred because of rounding *= / if (!sign && result < 0) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return SHRT_MAX; } } diff --git a/newlib/libc/machine/powerpc/strtosfix32.c b/newlib/libc/mach= ine/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 =3D EDOM; + _REENT_ERRNO(rptr) =3D EDOM; return 0; } - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D 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 >=3D 1.0) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return LONG_MAX; } else if (dbl.d < -1.0) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return LONG_MIN; } =20 @@ -75,7 +75,7 @@ _strtosfix32_r (struct _reent *rptr, /* check if positive saturation has occurred because of rounding *= / if (!sign && result < 0) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return LONG_MAX; } } diff --git a/newlib/libc/machine/powerpc/strtosfix64.c b/newlib/libc/mach= ine/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 =3D=3D 1) { - rptr->_errno =3D EDOM; + _REENT_ERRNO(rptr) =3D EDOM; return 0; } - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D 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 =3D=3D 0 && tmp !=3D 0x8000000000000000LL)) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return LONG_LONG_MIN; } } @@ -71,7 +71,7 @@ _strtosfix64_r (struct _reent *rptr, { if (exp >=3D 0) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D 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 =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return LONG_LONG_MAX; } } diff --git a/newlib/libc/machine/powerpc/strtoufix16.c b/newlib/libc/mach= ine/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 =3D EDOM; + _REENT_ERRNO(rptr) =3D EDOM; return 0; } - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D 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 >=3D 1.0) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return USHRT_MAX; } else if (dbl.d < 0) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return 0; } =20 @@ -147,7 +147,7 @@ _strtoufix16_r (struct _reent *rptr, if (negexp =3D=3D 0) { /* we have overflow which means saturation */ - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return USHRT_MAX; } result |=3D (1 << (16 - negexp)); diff --git a/newlib/libc/machine/powerpc/strtoufix32.c b/newlib/libc/mach= ine/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 =3D EDOM; + _REENT_ERRNO(rptr) =3D EDOM; return 0; } - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D 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 >=3D 1.0) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return ULONG_MAX; } else if (dbl.d < 0) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return 0; } =20 @@ -77,7 +77,7 @@ _strtoufix32_r (struct _reent *rptr, /* if rounding causes carry, then saturation has occurred */ if (result < tmp) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return ULONG_MAX; } } diff --git a/newlib/libc/machine/powerpc/strtoufix64.c b/newlib/libc/mach= ine/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 =3D=3D 1) { - rptr->_errno =3D EDOM; + _REENT_ERRNO(rptr) =3D EDOM; return 0; } - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D 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 =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return 0; } else { if (exp > 0 || (exp =3D=3D 0 && tmp >=3D 0x8000000000000000LL)) { - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D 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 =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; return ULONG_LONG_MAX; } } diff --git a/newlib/libc/machine/spu/stdio.c b/newlib/libc/machine/spu/st= dio.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 =3D EMFILE; + _REENT_ERRNO(d) =3D EMFILE; return NULL; } =20 diff --git a/newlib/libc/machine/spu/sys/errno.h b/newlib/libc/machine/sp= u/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; =20 -#define __errno_r(ptr) ((ptr)->_errno) +#define __errno_r(ptr) _REENT_ERRNO(ptr) =20 /* Adjusted to the linux asm/errno.h */ #define EPERM 1 /* Operation not permitted */ diff --git a/newlib/libc/reent/closer.c b/newlib/libc/reent/closer.c index deb34b002..2d72b2ab5 100644 --- a/newlib/libc/reent/closer.c +++ b/newlib/libc/reent/closer.c @@ -45,7 +45,7 @@ _close_r (ptr, fd) =20 errno =3D 0; if ((ret =3D _close (fd)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/execr.c b/newlib/libc/reent/execr.c index 59b61223e..541fb8624 100644 --- a/newlib/libc/reent/execr.c +++ b/newlib/libc/reent/execr.c @@ -54,7 +54,7 @@ _execve_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _execve (name, argv, env)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 @@ -86,7 +86,7 @@ _fork_r (struct _reent *ptr) =20 errno =3D 0; if ((ret =3D _fork ()) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 @@ -118,7 +118,7 @@ _wait_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _wait (status)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/fcntlr.c b/newlib/libc/reent/fcntlr.c index cd19d226f..f60aa091c 100644 --- a/newlib/libc/reent/fcntlr.c +++ b/newlib/libc/reent/fcntlr.c @@ -49,7 +49,7 @@ _fcntl_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _fcntl (fd, cmd, arg)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/fstat64r.c b/newlib/libc/reent/fstat64r.c index c546f5c1d..a049206e2 100644 --- a/newlib/libc/reent/fstat64r.c +++ b/newlib/libc/reent/fstat64r.c @@ -55,7 +55,7 @@ _fstat64_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _fstat64 (fd, pstat)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/fstatr.c b/newlib/libc/reent/fstatr.c index ec906c98d..9a02e9a68 100644 --- a/newlib/libc/reent/fstatr.c +++ b/newlib/libc/reent/fstatr.c @@ -53,7 +53,7 @@ _fstat_r (ptr, fd, pstat) =20 errno =3D 0; if ((ret =3D _fstat (fd, pstat)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/gettimeofdayr.c b/newlib/libc/reent/gettim= eofdayr.c index 9b982a993..aa60e5e3a 100644 --- a/newlib/libc/reent/gettimeofdayr.c +++ b/newlib/libc/reent/gettimeofdayr.c @@ -60,7 +60,7 @@ _gettimeofday_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _gettimeofday (ptimeval, ptimezone)) =3D=3D -1 && errno != =3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/isattyr.c b/newlib/libc/reent/isattyr.c index f21bf25b2..f76945519 100644 --- a/newlib/libc/reent/isattyr.c +++ b/newlib/libc/reent/isattyr.c @@ -50,7 +50,7 @@ _isatty_r (ptr, fd) =20 errno =3D 0; if ((ret =3D _isatty (fd)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/linkr.c b/newlib/libc/reent/linkr.c index b22da5f94..169b6eeec 100644 --- a/newlib/libc/reent/linkr.c +++ b/newlib/libc/reent/linkr.c @@ -51,7 +51,7 @@ _link_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _link (old, new)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/lseek64r.c b/newlib/libc/reent/lseek64r.c index 40769fb6d..c9afd01df 100644 --- a/newlib/libc/reent/lseek64r.c +++ b/newlib/libc/reent/lseek64r.c @@ -50,7 +50,7 @@ _lseek64_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _lseek64 (fd, pos, whence)) =3D=3D (_off64_t) -1 && errno= !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/lseekr.c b/newlib/libc/reent/lseekr.c index ac2daaab9..77e66b8e1 100644 --- a/newlib/libc/reent/lseekr.c +++ b/newlib/libc/reent/lseekr.c @@ -47,7 +47,7 @@ _lseek_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _lseek (fd, pos, whence)) =3D=3D (_off_t) -1 && errno !=3D= 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/mkdirr.c b/newlib/libc/reent/mkdirr.c index fd72df64c..cf66a24d3 100644 --- a/newlib/libc/reent/mkdirr.c +++ b/newlib/libc/reent/mkdirr.c @@ -48,7 +48,7 @@ _mkdir_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _mkdir (path, mode)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/open64r.c b/newlib/libc/reent/open64r.c index 84bd67e34..fe288d083 100644 --- a/newlib/libc/reent/open64r.c +++ b/newlib/libc/reent/open64r.c @@ -52,7 +52,7 @@ _open64_r (ptr, file, flags, mode) =20 errno =3D 0; if ((ret =3D _open64 (file, flags, mode)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/openr.c b/newlib/libc/reent/openr.c index c6a7db5de..824315438 100644 --- a/newlib/libc/reent/openr.c +++ b/newlib/libc/reent/openr.c @@ -48,7 +48,7 @@ _open_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _open (file, flags, mode)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/readr.c b/newlib/libc/reent/readr.c index 7fccefd32..b2ae300d3 100644 --- a/newlib/libc/reent/readr.c +++ b/newlib/libc/reent/readr.c @@ -47,7 +47,7 @@ _read_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D (_ssize_t)_read (fd, buf, cnt)) =3D=3D -1 && errno !=3D 0= ) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/renamer.c b/newlib/libc/reent/renamer.c index 5420dc4a0..7e1e111a8 100644 --- a/newlib/libc/reent/renamer.c +++ b/newlib/libc/reent/renamer.c @@ -49,7 +49,7 @@ _rename_r (struct _reent *ptr, #ifdef HAVE_RENAME errno =3D 0; if ((ret =3D _rename (old, new)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; #else if (_link_r (ptr, old, new) =3D=3D -1) return -1; diff --git a/newlib/libc/reent/sbrkr.c b/newlib/libc/reent/sbrkr.c index 21c4bd913..ec948fe6b 100644 --- a/newlib/libc/reent/sbrkr.c +++ b/newlib/libc/reent/sbrkr.c @@ -49,7 +49,7 @@ _sbrk_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D (char *)(_sbrk (incr))) =3D=3D (void *) -1 && errno !=3D = 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/signalr.c b/newlib/libc/reent/signalr.c index 345910e4b..863ae7400 100644 --- a/newlib/libc/reent/signalr.c +++ b/newlib/libc/reent/signalr.c @@ -51,7 +51,7 @@ _kill_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _kill (pid, sig)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/stat64r.c b/newlib/libc/reent/stat64r.c index b64736ef2..160d08e33 100644 --- a/newlib/libc/reent/stat64r.c +++ b/newlib/libc/reent/stat64r.c @@ -53,7 +53,7 @@ _stat64_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _stat64 (file, pstat)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/statr.c b/newlib/libc/reent/statr.c index 9388e0246..99453e789 100644 --- a/newlib/libc/reent/statr.c +++ b/newlib/libc/reent/statr.c @@ -53,7 +53,7 @@ _stat_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _stat (file, pstat)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/unlinkr.c b/newlib/libc/reent/unlinkr.c index 41bac0194..495e65b02 100644 --- a/newlib/libc/reent/unlinkr.c +++ b/newlib/libc/reent/unlinkr.c @@ -45,7 +45,7 @@ _unlink_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D _unlink (file)) =3D=3D -1 && errno !=3D 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/reent/writer.c b/newlib/libc/reent/writer.c index 704aba18b..ac2217c57 100644 --- a/newlib/libc/reent/writer.c +++ b/newlib/libc/reent/writer.c @@ -47,7 +47,7 @@ _write_r (struct _reent *ptr, =20 errno =3D 0; if ((ret =3D (_ssize_t)_write (fd, buf, cnt)) =3D=3D -1 && errno !=3D = 0) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return ret; } =20 diff --git a/newlib/libc/signal/signal.c b/newlib/libc/signal/signal.c index 0110287d8..a249e9f00 100644 --- a/newlib/libc/signal/signal.c +++ b/newlib/libc/signal/signal.c @@ -115,7 +115,7 @@ _signal_r (struct _reent *ptr, =20 if (sig < 0 || sig >=3D NSIG) { - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; return SIG_ERR; } =20 @@ -136,7 +136,7 @@ _raise_r (struct _reent *ptr, =20 if (sig < 0 || sig >=3D NSIG) { - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; return -1; } =20 @@ -151,7 +151,7 @@ _raise_r (struct _reent *ptr, return 0; else if (func =3D=3D SIG_ERR) { - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; return 1; } else diff --git a/newlib/libc/stdio/asniprintf.c b/newlib/libc/stdio/asniprint= f.c index 0bfe00d9b..97e77748e 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 =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return NULL; } f._bf._size =3D f._w =3D len; @@ -88,7 +88,7 @@ asniprintf (char *buf, for _size. */ if (len > INT_MAX) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return NULL; } f._bf._size =3D f._w =3D len; diff --git a/newlib/libc/stdio/asnprintf.c b/newlib/libc/stdio/asnprintf.= c index f657f9ec9..f82556143 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 =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return NULL; } f._bf._size =3D f._w =3D len; @@ -94,7 +94,7 @@ asnprintf (char *__restrict buf, for _size. */ if (len > INT_MAX) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return NULL; } f._bf._size =3D f._w =3D len; diff --git a/newlib/libc/stdio/fdopen.c b/newlib/libc/stdio/fdopen.c index ef942c284..3481154d1 100644 --- a/newlib/libc/stdio/fdopen.c +++ b/newlib/libc/stdio/fdopen.c @@ -73,7 +73,7 @@ _fdopen_r (struct _reent *ptr, fdmode =3D fdflags & O_ACCMODE; if (fdmode !=3D O_RDWR && (fdmode !=3D (oflags & O_ACCMODE))) { - ptr->_errno =3D EBADF; + _REENT_ERRNO(ptr) =3D EBADF; return 0; } #endif diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c index bbec4a19b..d51e90153 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 =3D ptr->_errno; - ptr->_errno =3D 0; + tmp_errno =3D _REENT_ERRNO(ptr); + _REENT_ERRNO(ptr) =3D 0; /* Get the physical position we are at in the file. */ if (fp->_flags & __SOFF) curoff =3D fp->_offset; @@ -152,13 +152,13 @@ __sflush_r (struct _reent *ptr, else #endif curoff =3D fp->_seek (ptr, fp->_cookie, 0, SEEK_CUR); - if (curoff =3D=3D -1L && ptr->_errno !=3D 0) + if (curoff =3D=3D -1L && _REENT_ERRNO(ptr) !=3D 0) { int result =3D EOF; - if (ptr->_errno =3D=3D ESPIPE || ptr->_errno =3D=3D EINVAL) + if (_REENT_ERRNO(ptr) =3D=3D ESPIPE || _REENT_ERRNO(ptr) =3D=3D EINV= AL) { result =3D 0; - ptr->_errno =3D tmp_errno; + _REENT_ERRNO(ptr) =3D tmp_errno; } else fp->_flags |=3D __SERR; @@ -180,8 +180,8 @@ __sflush_r (struct _reent *ptr, else #endif curoff =3D fp->_seek (ptr, fp->_cookie, curoff, SEEK_SET); - if (curoff !=3D -1 || ptr->_errno =3D=3D 0 - || ptr->_errno =3D=3D ESPIPE || ptr->_errno =3D=3D EINVAL) + if (curoff !=3D -1 || _REENT_ERRNO(ptr) =3D=3D 0 + || _REENT_ERRNO(ptr) =3D=3D ESPIPE || _REENT_ERRNO(ptr) =3D=3D EI= NVAL) { /* Seek successful or ignorable error condition. We can clear read buffer now. */ @@ -190,9 +190,9 @@ __sflush_r (struct _reent *ptr, #endif fp->_r =3D 0; fp->_p =3D fp->_bf._base; - if ((fp->_flags & __SOFF) && (curoff !=3D -1 || ptr->_errno =3D=3D= 0)) + if ((fp->_flags & __SOFF) && (curoff !=3D -1 || _REENT_ERRNO(ptr)= =3D=3D 0)) fp->_offset =3D curoff; - ptr->_errno =3D tmp_errno; + _REENT_ERRNO(ptr) =3D tmp_errno; if (HASUB (fp)) FREEUB (ptr, fp); } diff --git a/newlib/libc/stdio/fileno.c b/newlib/libc/stdio/fileno.c index 10fc6e283..4faa6a843 100644 --- a/newlib/libc/stdio/fileno.c +++ b/newlib/libc/stdio/fileno.c @@ -73,7 +73,7 @@ fileno (FILE * f) else { result =3D -1; - _REENT->_errno =3D EBADF; + _REENT_ERRNO(_REENT) =3D EBADF; } _newlib_flockfile_end (f); return result; diff --git a/newlib/libc/stdio/fileno_u.c b/newlib/libc/stdio/fileno_u.c index 830a07d2b..f3940e885 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 =3D -1; - _REENT->_errno =3D EBADF; + _REENT_ERRNO(_REENT) =3D EBADF; } return result; } diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index ee991ed24..c7a4a941e 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 =3D ENOMEM; + _REENT_ERRNO(d) =3D ENOMEM; return NULL; =20 found: diff --git a/newlib/libc/stdio/flags.c b/newlib/libc/stdio/flags.c index 7bbd50181..d686fa046 100644 --- a/newlib/libc/stdio/flags.c +++ b/newlib/libc/stdio/flags.c @@ -56,7 +56,7 @@ __sflags (struct _reent *ptr, o =3D O_CREAT | O_APPEND; break; default: /* illegal mode */ - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; return (0); } while (*++mode) diff --git a/newlib/libc/stdio/fmemopen.c b/newlib/libc/stdio/fmemopen.c index 0d043520e..886ba7efe 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 =3D ENOSPC; + _REENT_ERRNO(ptr) =3D ENOSPC; return EOF; } return n; @@ -175,18 +175,18 @@ fmemseeker (struct _reent *ptr, offset +=3D c->eof; if (offset < 0) { - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; offset =3D -1; } else if (offset > c->max) { - ptr->_errno =3D ENOSPC; + _REENT_ERRNO(ptr) =3D ENOSPC; offset =3D -1; } #ifdef __LARGE64_FILES else if ((_fpos_t) offset !=3D offset) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; offset =3D -1; } #endif /* __LARGE64_FILES */ @@ -224,12 +224,12 @@ fmemseeker64 (struct _reent *ptr, offset +=3D c->eof; if (offset < 0) { - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; offset =3D -1; } else if (offset > c->max) { - ptr->_errno =3D ENOSPC; + _REENT_ERRNO(ptr) =3D ENOSPC; offset =3D -1; } else @@ -277,7 +277,7 @@ _fmemopen_r (struct _reent *ptr, return NULL; if (!size || !(buf || flags & __SRW)) { - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; return NULL; } if ((fp =3D __sfp (ptr)) =3D=3D NULL) diff --git a/newlib/libc/stdio/fopencookie.c b/newlib/libc/stdio/fopencoo= kie.c index 0861528e0..ab406a866 100644 --- a/newlib/libc/stdio/fopencookie.c +++ b/newlib/libc/stdio/fopencookie.c @@ -107,7 +107,7 @@ fcreader (struct _reent *ptr, fccookie *c =3D (fccookie *) cookie; errno =3D 0; if ((result =3D c->readfn (c->cookie, buf, n)) < 0 && errno) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return result; } =20 @@ -129,7 +129,7 @@ fcwriter (struct _reent *ptr, } errno =3D 0; if ((result =3D c->writefn (c->cookie, buf, n)) < 0 && errno) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return result; } =20 @@ -148,11 +148,11 @@ fcseeker (struct _reent *ptr, =20 errno =3D 0; if (c->seekfn (c->cookie, &offset, whence) < 0 && errno) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; #ifdef __LARGE64_FILES else if ((_fpos_t)offset !=3D offset) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; offset =3D -1; } #endif /* __LARGE64_FILES */ @@ -170,7 +170,7 @@ fcseeker64 (struct _reent *ptr, fccookie *c =3D (fccookie *) cookie; errno =3D 0; if (c->seekfn (c->cookie, &offset, whence) < 0 && errno) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return (_fpos64_t) offset; } #endif /* __LARGE64_FILES */ @@ -185,7 +185,7 @@ fccloser (struct _reent *ptr, { errno =3D 0; if ((result =3D c->closefn (c->cookie)) < 0 && errno) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D 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 =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; return NULL; } if ((fp =3D __sfp (ptr)) =3D=3D NULL) diff --git a/newlib/libc/stdio/fpurge.c b/newlib/libc/stdio/fpurge.c index 2e4f61ec9..93ac0e2a9 100644 --- a/newlib/libc/stdio/fpurge.c +++ b/newlib/libc/stdio/fpurge.c @@ -72,7 +72,7 @@ _fpurge_r (struct _reent *ptr, t =3D fp->_flags; if (!t) { - ptr->_errno =3D EBADF; + _REENT_ERRNO(ptr) =3D EBADF; _newlib_flockfile_exit (fp); return EOF; } diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index 29ba5b7ff..eb742c1da 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -137,7 +137,7 @@ _freopen_r (struct _reent *ptr, if (file !=3D NULL) { f =3D _open_r (ptr, (char *) file, oflags, 0666); - e =3D ptr->_errno; + e =3D _REENT_ERRNO(ptr); } else { @@ -205,7 +205,7 @@ _freopen_r (struct _reent *ptr, { /* did not get it after all */ __sfp_lock_acquire (); fp->_flags =3D 0; /* set it free */ - ptr->_errno =3D e; /* restore in case _close clobbered */ + _REENT_ERRNO(ptr) =3D 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 13df28bfc..6fcc8ef06 100644 --- a/newlib/libc/stdio/fseeko.c +++ b/newlib/libc/stdio/fseeko.c @@ -128,7 +128,7 @@ _fseeko_r (struct _reent *ptr, =20 if ((seekfn =3D fp->_seek) =3D=3D NULL) { - ptr->_errno =3D ESPIPE; /* ??? */ + _REENT_ERRNO(ptr) =3D ESPIPE; /* ??? */ _newlib_flockfile_exit (fp); return EOF; } @@ -178,7 +178,7 @@ _fseeko_r (struct _reent *ptr, break; =20 default: - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; _newlib_flockfile_exit (fp); return (EOF); } diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c index c540c430f..f68b3afcc 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 !=3D pos) { pos =3D -1; - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; } return (long)pos; } diff --git a/newlib/libc/stdio/ftello.c b/newlib/libc/stdio/ftello.c index 3df200cea..d62d48a89 100644 --- a/newlib/libc/stdio/ftello.c +++ b/newlib/libc/stdio/ftello.c @@ -96,7 +96,7 @@ _ftello_r (struct _reent * ptr, =20 if (fp->_seek =3D=3D NULL) { - ptr->_errno =3D ESPIPE; + _REENT_ERRNO(ptr) =3D ESPIPE; _newlib_flockfile_exit (fp); return (_off_t) -1; } diff --git a/newlib/libc/stdio/funopen.c b/newlib/libc/stdio/funopen.c index a1c0d767d..4ed50196e 100644 --- a/newlib/libc/stdio/funopen.c +++ b/newlib/libc/stdio/funopen.c @@ -113,7 +113,7 @@ funreader (struct _reent *ptr, funcookie *c =3D (funcookie *) cookie; errno =3D 0; if ((result =3D c->readfn (c->cookie, buf, n)) < 0 && errno) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return result; } =20 @@ -127,7 +127,7 @@ funwriter (struct _reent *ptr, funcookie *c =3D (funcookie *) cookie; errno =3D 0; if ((result =3D c->writefn (c->cookie, buf, n)) < 0 && errno) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return result; } =20 @@ -142,15 +142,15 @@ funseeker (struct _reent *ptr, fpos_t result; errno =3D 0; if ((result =3D c->seekfn (c->cookie, (fpos_t) off, whence)) < 0 && er= rno) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; #else /* __LARGE64_FILES */ _fpos64_t result; errno =3D 0; if ((result =3D c->seekfn (c->cookie, (_fpos64_t) off, whence)) < 0 &&= errno) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; else if ((_fpos_t)result !=3D result) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; result =3D -1; } #endif /* __LARGE64_FILES */ @@ -168,7 +168,7 @@ funseeker64 (struct _reent *ptr, funcookie *c =3D (funcookie *) cookie; errno =3D 0; if ((result =3D c->seekfn (c->cookie, off, whence)) < 0 && errno) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; return result; } #endif /* __LARGE64_FILES */ @@ -183,7 +183,7 @@ funcloser (struct _reent *ptr, { errno =3D 0; if ((result =3D c->closefn (c->cookie)) < 0 && errno) - ptr->_errno =3D errno; + _REENT_ERRNO(ptr) =3D errno; } _free_r (ptr, c); return result; @@ -202,7 +202,7 @@ _funopen_r (struct _reent *ptr, =20 if (!readfn && !writefn) { - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; return NULL; } if ((fp =3D __sfp (ptr)) =3D=3D NULL) diff --git a/newlib/libc/stdio/fvwrite.c b/newlib/libc/stdio/fvwrite.c index 587ffacd7..34361cb8d 100644 --- a/newlib/libc/stdio/fvwrite.c +++ b/newlib/libc/stdio/fvwrite.c @@ -145,7 +145,7 @@ __sfvwrite_r (struct _reent *ptr, str =3D (unsigned char *)_malloc_r (ptr, newsize); if (!str) { - ptr->_errno =3D ENOMEM; + _REENT_ERRNO(ptr) =3D 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 &=3D ~__SMBF; /* Ensure correct errno, even if free changed it. */ - ptr->_errno =3D ENOMEM; + _REENT_ERRNO(ptr) =3D ENOMEM; goto err; } } diff --git a/newlib/libc/stdio/mktemp.c b/newlib/libc/stdio/mktemp.c index 3514818a6..265968198 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 =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; return 0; } trv -=3D suffixlen; @@ -171,7 +171,7 @@ _gettemp (struct _reent *ptr, } if (end - trv < 6) { - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; return 0; } =20 @@ -195,7 +195,7 @@ _gettemp (struct _reent *ptr, return (0); if (!(sbuf.st_mode & S_IFDIR)) { - ptr->_errno =3D ENOTDIR; + _REENT_ERRNO(ptr) =3D ENOTDIR; return (0); } *trv =3D '/'; @@ -211,10 +211,10 @@ _gettemp (struct _reent *ptr, #ifdef HAVE_MKDIR if (_mkdir_r (ptr, path, 0700) =3D=3D 0) return 1; - if (ptr->_errno !=3D EEXIST) + if (_REENT_ERRNO(ptr) !=3D EEXIST) return 0; #else /* !HAVE_MKDIR */ - ptr->_errno =3D ENOSYS; + _REENT_ERRNO(ptr) =3D ENOSYS; return 0; #endif /* !HAVE_MKDIR */ } @@ -225,7 +225,7 @@ _gettemp (struct _reent *ptr, if ((*doopen =3D _open_r (ptr, path, O_CREAT | O_EXCL | O_RDWR | flag= s, 0600)) >=3D 0) return 1; - if (ptr->_errno !=3D EEXIST) + if (_REENT_ERRNO(ptr) !=3D 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 =3D=3D ENOENT ? 1 : 0); + return (_REENT_ERRNO(ptr) =3D=3D ENOENT ? 1 : 0); =20 /* tricky little algorithm for backward compatibility */ for (trv =3D start;;) diff --git a/newlib/libc/stdio/nano-vfprintf.c b/newlib/libc/stdio/nano-v= fprintf.c index 838804eb9..0d42a940f 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 =3D (unsigned char *)_malloc_r (ptr, newsize); if (!str) { - ptr->_errno =3D ENOMEM; + _REENT_ERRNO(ptr) =3D 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 =3D ENOMEM; + _REENT_ERRNO(ptr) =3D ENOMEM; goto err; } } @@ -291,7 +291,7 @@ __ssprint_r (struct _reent *ptr, str =3D (unsigned char *)_malloc_r (ptr, newsize); if (!str) { - ptr->_errno =3D ENOMEM; + _REENT_ERRNO(ptr) =3D 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 =3D ENOMEM; + _REENT_ERRNO(ptr) =3D ENOMEM; goto err; } } @@ -501,7 +501,7 @@ _VFPRINTF_R (struct _reent *data, fp->_bf._base =3D fp->_p =3D _malloc_r (data, 64); if (!fp->_p) { - data->_errno =3D ENOMEM; + _REENT_ERRNO(data) =3D ENOMEM; return EOF; } fp->_bf._size =3D 64; diff --git a/newlib/libc/stdio/open_memstream.c b/newlib/libc/stdio/open_= memstream.c index ed71b1cdc..e3a52ed33 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) =3D=3D sizeof (size_t) && (ssize_t) (c->pos + n) < = 0) { - ptr->_errno =3D EFBIG; + _REENT_ERRNO(ptr) =3D EFBIG; return EOF; } /* Grow the buffer, if necessary. Choose a geometric growth factor @@ -160,18 +160,18 @@ memseeker (struct _reent *ptr, offset +=3D c->eof; if (offset < 0) { - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; offset =3D -1; } else if ((size_t) offset !=3D offset) { - ptr->_errno =3D ENOSPC; + _REENT_ERRNO(ptr) =3D ENOSPC; offset =3D -1; } #ifdef __LARGE64_FILES else if ((_fpos_t) offset !=3D offset) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; offset =3D -1; } #endif /* __LARGE64_FILES */ @@ -227,12 +227,12 @@ memseeker64 (struct _reent *ptr, offset +=3D c->eof; if (offset < 0) { - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; offset =3D -1; } else if ((size_t) offset !=3D offset) { - ptr->_errno =3D ENOSPC; + _REENT_ERRNO(ptr) =3D ENOSPC; offset =3D -1; } else @@ -301,7 +301,7 @@ internal_open_memstream_r (struct _reent *ptr, =20 if (!buf || !size) { - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; return NULL; } if ((fp =3D __sfp (ptr)) =3D=3D NULL) diff --git a/newlib/libc/stdio/perror.c b/newlib/libc/stdio/perror.c index eda7e993b..2033a6f2f 100644 --- a/newlib/libc/stdio/perror.c +++ b/newlib/libc/stdio/perror.c @@ -90,7 +90,7 @@ _perror_r (struct _reent *ptr, WRITE_STR (": "); } =20 - if ((error =3D _strerror_r (ptr, ptr->_errno, 1, &dummy)) !=3D NULL) + if ((error =3D _strerror_r (ptr, _REENT_ERRNO(ptr), 1, &dummy)) !=3D N= ULL) WRITE_STR (error); =20 #ifdef __SCLE diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c index 8516d8576..8584906ea 100644 --- a/newlib/libc/stdio/refill.c +++ b/newlib/libc/stdio/refill.c @@ -58,7 +58,7 @@ __srefill_r (struct _reent * ptr, { if ((fp->_flags & __SRW) =3D=3D 0) { - ptr->_errno =3D EBADF; + _REENT_ERRNO(ptr) =3D EBADF; fp->_flags |=3D __SERR; return EOF; } diff --git a/newlib/libc/stdio/sniprintf.c b/newlib/libc/stdio/sniprintf.= c index 375a3971f..b05ffcb12 100644 --- a/newlib/libc/stdio/sniprintf.c +++ b/newlib/libc/stdio/sniprintf.c @@ -38,7 +38,7 @@ _sniprintf_r (struct _reent *ptr, =20 if (size > INT_MAX) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return EOF; } f._flags =3D __SWR | __SSTR; @@ -49,7 +49,7 @@ _sniprintf_r (struct _reent *ptr, ret =3D _svfiprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret < EOF) - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; if (size > 0) *f._p =3D 0; return (ret); @@ -69,7 +69,7 @@ sniprintf (char *str, =20 if (size > INT_MAX) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return EOF; } f._flags =3D __SWR | __SSTR; @@ -80,7 +80,7 @@ sniprintf (char *str, ret =3D _svfiprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret < EOF) - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; if (size > 0) *f._p =3D 0; return (ret); diff --git a/newlib/libc/stdio/snprintf.c b/newlib/libc/stdio/snprintf.c index 50d7ddd11..4a3084bea 100644 --- a/newlib/libc/stdio/snprintf.c +++ b/newlib/libc/stdio/snprintf.c @@ -37,7 +37,7 @@ _snprintf_r (struct _reent *ptr, =20 if (size > INT_MAX) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return EOF; } f._flags =3D __SWR | __SSTR; @@ -48,7 +48,7 @@ _snprintf_r (struct _reent *ptr, ret =3D _svfprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret < EOF) - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; if (size > 0) *f._p =3D 0; return (ret); @@ -74,7 +74,7 @@ snprintf (char *__restrict str, =20 if (size > INT_MAX) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return EOF; } f._flags =3D __SWR | __SSTR; @@ -85,7 +85,7 @@ snprintf (char *__restrict str, ret =3D _svfprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret < EOF) - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; if (size > 0) *f._p =3D 0; return (ret); diff --git a/newlib/libc/stdio/swprintf.c b/newlib/libc/stdio/swprintf.c index ec7e089ca..634b22beb 100644 --- a/newlib/libc/stdio/swprintf.c +++ b/newlib/libc/stdio/swprintf.c @@ -564,7 +564,7 @@ _swprintf_r (struct _reent *ptr, =20 if (size > INT_MAX / sizeof (wchar_t)) { - ptr->_errno =3D EOVERFLOW; /* POSIX extension */ + _REENT_ERRNO(ptr) =3D EOVERFLOW; /* POSIX extension */ return EOF; } f._flags =3D __SWR | __SSTR; @@ -584,7 +584,7 @@ _swprintf_r (struct _reent *ptr, /* _svfwprintf_r() returns how many wide characters it would have pr= inted * if there were enough space. Return an error if too big to fit in= str, * unlike snprintf, which returns the size needed. */ - ptr->_errno =3D EOVERFLOW; /* POSIX extension */ + _REENT_ERRNO(ptr) =3D EOVERFLOW; /* POSIX extension */ ret =3D -1; } return (ret); @@ -604,7 +604,7 @@ swprintf (wchar_t *__restrict str, =20 if (size > INT_MAX / sizeof (wchar_t)) { - ptr->_errno =3D EOVERFLOW; /* POSIX extension */ + _REENT_ERRNO(ptr) =3D EOVERFLOW; /* POSIX extension */ return EOF; } f._flags =3D __SWR | __SSTR; @@ -624,7 +624,7 @@ swprintf (wchar_t *__restrict str, /* _svfwprintf_r() returns how many wide characters it would have pr= inted * if there were enough space. Return an error if too big to fit in= str, * unlike snprintf, which returns the size needed. */ - ptr->_errno =3D EOVERFLOW; /* POSIX extension */ + _REENT_ERRNO(ptr) =3D EOVERFLOW; /* POSIX extension */ ret =3D -1; } return (ret); diff --git a/newlib/libc/stdio/tmpfile.c b/newlib/libc/stdio/tmpfile.c index f209a3edf..5fe6e3bf1 100644 --- a/newlib/libc/stdio/tmpfile.c +++ b/newlib/libc/stdio/tmpfile.c @@ -65,15 +65,15 @@ _tmpfile_r (struct _reent *ptr) fd =3D _open_r (ptr, f, O_RDWR | O_CREAT | O_EXCL | O_BINARY, S_IRUSR | S_IWUSR); } - while (fd < 0 && ptr->_errno =3D=3D EEXIST); + while (fd < 0 && _REENT_ERRNO(ptr) =3D=3D EEXIST); if (fd < 0) return NULL; fp =3D _fdopen_r (ptr, fd, "wb+"); - e =3D ptr->_errno; + e =3D _REENT_ERRNO(ptr); if (!fp) _close_r (ptr, fd); (void) _remove_r (ptr, f); - ptr->_errno =3D e; + _REENT_ERRNO(ptr) =3D e; return fp; } =20 diff --git a/newlib/libc/stdio/tmpnam.c b/newlib/libc/stdio/tmpnam.c index 3bd5b6a58..7379a7640 100644 --- a/newlib/libc/stdio/tmpnam.c +++ b/newlib/libc/stdio/tmpnam.c @@ -104,7 +104,7 @@ worker (struct _reent *ptr, t =3D _open_r (ptr, result, O_RDONLY, 0); if (t =3D=3D -1) { - if (ptr->_errno =3D=3D ENOSYS) + if (_REENT_ERRNO(ptr) =3D=3D ENOSYS) { result[0] =3D '\0'; return 0; diff --git a/newlib/libc/stdio/vasniprintf.c b/newlib/libc/stdio/vasnipri= ntf.c index edfbd2242..b24cd96fb 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 =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return NULL; } f._bf._size =3D f._w =3D len; diff --git a/newlib/libc/stdio/vasnprintf.c b/newlib/libc/stdio/vasnprint= f.c index 1fbf5a171..b3787ec7a 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 =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return NULL; } f._bf._size =3D f._w =3D len; diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 32ebb1468..6a198e2c6 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -222,7 +222,7 @@ __ssputs_r (struct _reent *ptr, str =3D (unsigned char *)_malloc_r (ptr, newsize); if (!str) { - ptr->_errno =3D ENOMEM; + _REENT_ERRNO(ptr) =3D 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 =3D ENOMEM; + _REENT_ERRNO(ptr) =3D ENOMEM; goto err; } } @@ -306,7 +306,7 @@ __ssprint_r (struct _reent *ptr, str =3D (unsigned char *)_malloc_r (ptr, newsize); if (!str) { - ptr->_errno =3D ENOMEM; + _REENT_ERRNO(ptr) =3D 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 =3D ENOMEM; + _REENT_ERRNO(ptr) =3D ENOMEM; goto err; } } @@ -868,7 +868,7 @@ _VFPRINTF_R (struct _reent *data, fp->_bf._base =3D fp->_p =3D _malloc_r (data, 64); if (!fp->_p) { - data->_errno =3D ENOMEM; + _REENT_ERRNO(data) =3D ENOMEM; return EOF; } fp->_bf._size =3D 64; @@ -1374,7 +1374,7 @@ reswitch: switch (ch) { case 'm': /* extension */ { int dummy; - cp =3D _strerror_r (data, data->_errno, 1, &dummy); + cp =3D _strerror_r (data, _REENT_ERRNO(data), 1, &dummy); } flags &=3D ~LONGINT; goto string; diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c index 037692531..cfeea9876 100644 --- a/newlib/libc/stdio/vfscanf.c +++ b/newlib/libc/stdio/vfscanf.c @@ -774,7 +774,7 @@ __SVFSCANF_R (struct _reent *rptr, width =3D 0; goto again; } - rptr->_errno =3D EINVAL; + _REENT_ERRNO(rptr) =3D EINVAL; goto input_failure; #endif /* !_NO_POS_ARGS */ =20 diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.= c index 7384b37d3..7807a1229 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 =3D fp->_p =3D _malloc_r (data, 64); if (!fp->_p) { - data->_errno =3D ENOMEM; + _REENT_ERRNO(data) =3D ENOMEM; return EOF; } fp->_bf._size =3D 64; @@ -1119,7 +1119,7 @@ reswitch: switch (ch) { case L'm': /* GNU extension */ { int dummy; - cp =3D (wchar_t *) _strerror_r (data, data->_errno, 1, &dummy); + cp =3D (wchar_t *) _strerror_r (data, _REENT_ERRNO(data), 1, &dummy)= ; } flags &=3D ~LONGINT; goto string; diff --git a/newlib/libc/stdio/vfwscanf.c b/newlib/libc/stdio/vfwscanf.c index e9e00dfec..df966f929 100644 --- a/newlib/libc/stdio/vfwscanf.c +++ b/newlib/libc/stdio/vfwscanf.c @@ -682,7 +682,7 @@ __SVFWSCANF_R (struct _reent *rptr, width =3D 0; goto again; } - rptr->_errno =3D EINVAL; + _REENT_ERRNO(rptr) =3D EINVAL; goto input_failure; #endif /* !_NO_POS_ARGS */ =20 diff --git a/newlib/libc/stdio/vsniprintf.c b/newlib/libc/stdio/vsniprint= f.c index a8b272e2f..e7625ffd5 100644 --- a/newlib/libc/stdio/vsniprintf.c +++ b/newlib/libc/stdio/vsniprintf.c @@ -54,7 +54,7 @@ _vsniprintf_r (struct _reent *ptr, =20 if (size > INT_MAX) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return EOF; } f._flags =3D __SWR | __SSTR; @@ -63,7 +63,7 @@ _vsniprintf_r (struct _reent *ptr, f._file =3D -1; /* No file. */ ret =3D _svfiprintf_r (ptr, &f, fmt, ap); if (ret < EOF) - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; if (size > 0) *f._p =3D 0; return ret; diff --git a/newlib/libc/stdio/vsnprintf.c b/newlib/libc/stdio/vsnprintf.= c index 5c617a8a3..ecf82eaef 100644 --- a/newlib/libc/stdio/vsnprintf.c +++ b/newlib/libc/stdio/vsnprintf.c @@ -60,7 +60,7 @@ _vsnprintf_r (struct _reent *ptr, =20 if (size > INT_MAX) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return EOF; } f._flags =3D __SWR | __SSTR; @@ -69,7 +69,7 @@ _vsnprintf_r (struct _reent *ptr, f._file =3D -1; /* No file. */ ret =3D _svfprintf_r (ptr, &f, fmt, ap); if (ret < EOF) - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; if (size > 0) *f._p =3D 0; return ret; diff --git a/newlib/libc/stdio/vswprintf.c b/newlib/libc/stdio/vswprintf.= c index 89795ed8d..08a8545ba 100644 --- a/newlib/libc/stdio/vswprintf.c +++ b/newlib/libc/stdio/vswprintf.c @@ -42,7 +42,7 @@ _vswprintf_r (struct _reent *ptr, =20 if (size > INT_MAX / sizeof (wchar_t)) { - ptr->_errno =3D EOVERFLOW; /* POSIX extension */ + _REENT_ERRNO(ptr) =3D EOVERFLOW; /* POSIX extension */ return EOF; } f._flags =3D __SWR | __SSTR; @@ -60,7 +60,7 @@ _vswprintf_r (struct _reent *ptr, /* _svfwprintf_r() returns how many wide characters it would have pr= inted * if there were enough space. Return an error if too big to fit in= str, * unlike snprintf, which returns the size needed. */ - ptr->_errno =3D EOVERFLOW; /* POSIX extension */ + _REENT_ERRNO(ptr) =3D EOVERFLOW; /* POSIX extension */ ret =3D -1; } return ret; diff --git a/newlib/libc/stdio/wsetup.c b/newlib/libc/stdio/wsetup.c index 6a820f1c0..0fd9690aa 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) =3D=3D 0) { - ptr->_errno =3D EBADF; + _REENT_ERRNO(ptr) =3D EBADF; fp->_flags |=3D __SERR; return EOF; } diff --git a/newlib/libc/stdio64/fdopen64.c b/newlib/libc/stdio64/fdopen6= 4.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 =3D fdflags & O_ACCMODE; if (fdmode !=3D O_RDWR && (fdmode !=3D (oflags & O_ACCMODE))) { - ptr->_errno =3D EBADF; + _REENT_ERRNO(ptr) =3D EBADF; return 0; } #endif diff --git a/newlib/libc/stdio64/freopen64.c b/newlib/libc/stdio64/freope= n64.c index e6ba64f7d..5e0c32c37 100644 --- a/newlib/libc/stdio64/freopen64.c +++ b/newlib/libc/stdio64/freopen64.c @@ -138,7 +138,7 @@ _freopen64_r (struct _reent *ptr, if (file !=3D NULL) { f =3D _open64_r (ptr, (char *) file, oflags, 0666); - e =3D ptr->_errno; + e =3D _REENT_ERRNO(ptr); } else { @@ -206,7 +206,7 @@ _freopen64_r (struct _reent *ptr, { /* did not get it after all */ __sfp_lock_acquire (); fp->_flags =3D 0; /* set it free */ - ptr->_errno =3D e; /* restore in case _close clobbered */ + _REENT_ERRNO(ptr) =3D 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/fseeko6= 4.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 !=3D offset) { - ptr->_errno =3D EOVERFLOW; + _REENT_ERRNO(ptr) =3D EOVERFLOW; return EOF; } return (_off64_t) _fseeko_r (ptr, fp, offset, whence); @@ -129,7 +129,7 @@ _fseeko64_r (struct _reent *ptr, =20 if ((seekfn =3D fp->_seek64) =3D=3D NULL) { - ptr->_errno =3D ESPIPE; /* ??? */ + _REENT_ERRNO(ptr) =3D ESPIPE; /* ??? */ _newlib_flockfile_exit(fp); return EOF; } @@ -179,7 +179,7 @@ _fseeko64_r (struct _reent *ptr, break; =20 default: - ptr->_errno =3D EINVAL; + _REENT_ERRNO(ptr) =3D EINVAL; _newlib_flockfile_exit(fp); return (EOF); } diff --git a/newlib/libc/stdio64/ftello64.c b/newlib/libc/stdio64/ftello6= 4.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, =20 if (fp->_seek64 =3D=3D NULL) { - ptr->_errno =3D ESPIPE; + _REENT_ERRNO(ptr) =3D ESPIPE; _newlib_flockfile_exit(fp); return (_off64_t) -1; } diff --git a/newlib/libc/stdio64/tmpfile64.c b/newlib/libc/stdio64/tmpfil= e64.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 =3D _open64_r (ptr, f, O_RDWR | O_CREAT | O_EXCL | O_BINARY, S_IRUSR | S_IWUSR); } - while (fd < 0 && ptr->_errno =3D=3D EEXIST); + while (fd < 0 && _REENT_ERRNO(ptr) =3D=3D EEXIST); if (fd < 0) return NULL; fp =3D _fdopen64_r (ptr, fd, "wb+"); - e =3D ptr->_errno; + e =3D _REENT_ERRNO(ptr); if (!fp) _close_r (ptr, fd); (void) _remove_r (ptr, f); - ptr->_errno =3D e; + _REENT_ERRNO(ptr) =3D e; return fp; } =20 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, =20 if (dexp > MAXE) { - ptr->_errno =3D ERANGE; + _REENT_ERRNO(ptr) =3D ERANGE; return (sign) ? -HUGE_VAL : HUGE_VAL; } else if (dexp < MINE) { - ptr->_errno =3D ERANGE; + _REENT_ERRNO(ptr) =3D ERANGE; return 0.0; } =20 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 =3D=3D -1) { ps->__count =3D 0; - ptr->_errno =3D EILSEQ; + _REENT_ERRNO(ptr) =3D EILSEQ; return (size_t)(-1); } else @@ -68,7 +68,7 @@ mbrtowc (wchar_t *__restrict pwc, if (retval =3D=3D -1) { ps->__count =3D 0; - reent->_errno =3D EILSEQ; + _REENT_ERRNO(reent) =3D EILSEQ; return (size_t)(-1); } else diff --git a/newlib/libc/stdlib/mbsnrtowcs.c b/newlib/libc/stdlib/mbsnrto= wcs.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 =3D 0; - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D 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 >=3D 0x80) { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } #endif @@ -117,7 +117,7 @@ ___iso_mbtowc (struct _reent *r, wchar_t *pwc, const = char *s, size_t n, *pwc =3D __iso_8859_conv[iso_idx][*t - 0xa0]; if (*pwc =3D=3D 0) /* Invalid character */ { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } return 1; @@ -290,7 +290,7 @@ ___cp_mbtowc (struct _reent *r, wchar_t *pwc, const c= har *s, size_t n, *pwc =3D __cp_conv[cp_idx][*t - 0x80]; if (*pwc =3D=3D 0) /* Invalid character */ { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } return 1; @@ -578,13 +578,13 @@ __utf8_mbtowc (struct _reent *r, ch =3D t[i++]; if (ch < 0x80 || ch > 0xbf) { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } if (state->__value.__wchb[0] < 0xc2) { /* overlong UTF-8 sequence */ - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } state->__count =3D 0; @@ -607,12 +607,12 @@ __utf8_mbtowc (struct _reent *r, if (state->__value.__wchb[0] =3D=3D 0xe0 && ch < 0xa0) { /* overlong UTF-8 sequence */ - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } if (ch < 0x80 || ch > 0xbf) { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } state->__value.__wchb[1] =3D ch; @@ -625,7 +625,7 @@ __utf8_mbtowc (struct _reent *r, ch =3D t[i++]; if (ch < 0x80 || ch > 0xbf) { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } state->__count =3D 0; @@ -651,12 +651,12 @@ __utf8_mbtowc (struct _reent *r, || (state->__value.__wchb[0] =3D=3D 0xf4 && ch >=3D 0x90)) { /* overlong UTF-8 sequence or result is > 0x10ffff */ - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } if (ch < 0x80 || ch > 0xbf) { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } state->__value.__wchb[1] =3D ch; @@ -669,7 +669,7 @@ __utf8_mbtowc (struct _reent *r, ch =3D (state->__count =3D=3D 2) ? t[i++] : state->__value.__wchb[= 2]; if (ch < 0x80 || ch > 0xbf) { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } state->__value.__wchb[2] =3D ch; @@ -702,7 +702,7 @@ __utf8_mbtowc (struct _reent *r, ch =3D t[i++]; if (ch < 0x80 || ch > 0xbf) { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } tmp =3D (wint_t)((state->__value.__wchb[0] & 0x07) << 18) @@ -719,7 +719,7 @@ __utf8_mbtowc (struct _reent *r, return i; } =20 - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } =20 @@ -769,7 +769,7 @@ __sjis_mbtowc (struct _reent *r, } else =20 { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } } @@ -836,7 +836,7 @@ __eucjp_mbtowc (struct _reent *r, } else { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } } @@ -851,7 +851,7 @@ __eucjp_mbtowc (struct _reent *r, } else { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } } @@ -955,7 +955,7 @@ __jis_mbtowc (struct _reent *r, break; case ERROR: default: - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } =20 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 =3D ERANGE; + _REENT_ERRNO(ptr) =3D 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) =3D 0.; #ifndef NO_ERRNO - ptr->_errno =3D ERANGE; + _REENT_ERRNO(ptr) =3D ERANGE; #endif if (bd0) goto retfree; @@ -1249,7 +1249,7 @@ _strtod_l (struct _reent *ptr, const char *__restri= ct s00, char **__restrict se, #ifndef NO_ERRNO /* try to avoid the bug of testing an 8087 register value */ if ((dword0(rv) & Exp_mask) =3D=3D 0) - ptr->_errno =3D ERANGE; + _REENT_ERRNO(ptr) =3D ERANGE; #endif } #endif /* Avoid_Underflow */ @@ -1303,7 +1303,7 @@ strtof_l (const char *__restrict s00, char **__rest= rict se, locale_t loc) float retval =3D (float) val; #ifndef NO_ERRNO if (isinf (retval) && !isinf (val)) - _REENT->_errno =3D ERANGE; + _REENT_ERRNO(_REENT) =3D ERANGE; #endif return retval; } @@ -1340,7 +1340,7 @@ strtof (const char *__restrict s00, float retval =3D (float) val; #ifndef NO_ERRNO if ((isinf (retval) && !isinf (val)) || (isdenormf(retval) && !isdenor= m(val))) - _REENT->_errno =3D ERANGE; + _REENT_ERRNO(_REENT) =3D ERANGE; #endif return retval; } diff --git a/newlib/libc/stdlib/strtoimax.c b/newlib/libc/stdlib/strtoima= x.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 * __re= strict nptr, } if (any < 0) { acc =3D neg ? INTMAX_MIN : INTMAX_MAX; - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; } else if (!any) { noconv: - rptr->_errno =3D EINVAL; + _REENT_ERRNO(rptr) =3D EINVAL; } else if (neg) acc =3D -acc; if (endptr !=3D 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 *__restric= t nptr, } if (any < 0) { acc =3D neg ? LONG_MIN : LONG_MAX; - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; } else if (neg) acc =3D -acc; if (endptr !=3D 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 *__restri= ct nptr, } if (any < 0) { acc =3D neg ? LONG_LONG_MIN : LONG_LONG_MAX; - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; } else if (neg) acc =3D -acc; if (endptr !=3D 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 *__restri= ct nptr, } if (any < 0) { acc =3D ULONG_MAX; - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; } else if (neg) acc =3D -acc; if (endptr !=3D 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 *__restr= ict nptr, } if (any < 0) { acc =3D ULONG_LONG_MAX; - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; } else if (neg) acc =3D -acc; if (endptr !=3D 0) diff --git a/newlib/libc/stdlib/strtoumax.c b/newlib/libc/stdlib/strtouma= x.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 * __re= strict nptr, } if (any < 0) { acc =3D UINTMAX_MAX; - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; } else if (!any) { noconv: - rptr->_errno =3D EINVAL; + _REENT_ERRNO(rptr) =3D EINVAL; } else if (neg) acc =3D -acc; if (endptr !=3D 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 =3D=3D -1) { ps->__count =3D 0; - ptr->_errno =3D EILSEQ; + _REENT_ERRNO(ptr) =3D EILSEQ; return (size_t)(-1); } else @@ -67,7 +67,7 @@ wcrtomb (char *__restrict s, if (retval =3D=3D -1) { ps->__count =3D 0; - reent->_errno =3D EILSEQ; + _REENT_ERRNO(reent) =3D EILSEQ; return (size_t)(-1); } else diff --git a/newlib/libc/stdlib/wcsnrtombs.c b/newlib/libc/stdlib/wcsnrto= mbs.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 wch= ar_t **src, size_t nwc, int bytes =3D loc->wctomb (r, buff, *pwcs, ps); if (bytes =3D=3D -1) { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; ps->__count =3D 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 =3D (float) val; #ifndef NO_ERRNO if (isinf (retval) && !isinf (val)) - _REENT->_errno =3D ERANGE; + _REENT_ERRNO(_REENT) =3D ERANGE; #endif return retval; } @@ -272,7 +272,7 @@ wcstof (const wchar_t *__restrict nptr, float retval =3D (float) val; #ifndef NO_ERRNO if (isinf (retval) && !isinf (val)) - _REENT->_errno =3D ERANGE; + _REENT_ERRNO(_REENT) =3D ERANGE; #endif =20 return retval; diff --git a/newlib/libc/stdlib/wcstoimax.c b/newlib/libc/stdlib/wcstoima= x.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 =3D neg ? INTMAX_MIN : INTMAX_MAX; - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; } else if (!any) { noconv: - rptr->_errno =3D EINVAL; + _REENT_ERRNO(rptr) =3D EINVAL; } else if (neg) acc =3D -acc; if (endptr !=3D 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 =3D neg ? LONG_MIN : LONG_MAX; - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; } else if (neg) acc =3D -acc; if (endptr !=3D 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 =3D neg ? LONG_LONG_MIN : LONG_LONG_MAX; - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; } else if (neg) acc =3D -acc; if (endptr !=3D 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 =3D ULONG_MAX; - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; } else if (neg) acc =3D -acc; if (endptr !=3D 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 =3D 0, any, cutlim; =20 if(base < 0 || base =3D=3D 1 || base > 36) { - rptr->_errno =3D EINVAL; + _REENT_ERRNO(rptr) =3D EINVAL; return(0ULL); } /* @@ -195,7 +195,7 @@ _wcstoull_l (struct _reent *rptr, const wchar_t *nptr= , wchar_t **endptr, } if (any < 0) { acc =3D ULLONG_MAX; - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; } else if (neg) acc =3D -acc; if (endptr !=3D 0) diff --git a/newlib/libc/stdlib/wcstoumax.c b/newlib/libc/stdlib/wcstouma= x.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 =3D UINTMAX_MAX; - rptr->_errno =3D ERANGE; + _REENT_ERRNO(rptr) =3D ERANGE; } else if (!any) { noconv: - rptr->_errno =3D EINVAL; + _REENT_ERRNO(rptr) =3D EINVAL; } else if (neg) acc =3D -acc; if (endptr !=3D 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 >=3D 0x100) #endif { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } =20 @@ -133,7 +133,7 @@ __utf8_wctomb (struct _reent *r, return 4; } =20 - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } =20 @@ -165,7 +165,7 @@ __sjis_wctomb (struct _reent *r, } else { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } } @@ -204,7 +204,7 @@ __eucjp_wctomb (struct _reent *r, } else { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } } @@ -244,7 +244,7 @@ __jis_wctomb (struct _reent *r, *s =3D (char)char2; return cnt + 2; } - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } if (state->__state !=3D 0) @@ -284,14 +284,14 @@ ___iso_wctomb (struct _reent *r, char *s, wchar_t _= wchar, int iso_idx, *s =3D (char) (mb + 0xa0); return 1; } - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } } =20 if ((size_t)wchar >=3D 0x100) { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } =20 @@ -440,14 +440,14 @@ ___cp_wctomb (struct _reent *r, char *s, wchar_t _w= char, int cp_idx, *s =3D (char) (mb + 0x80); return 1; } - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } } =20 if ((size_t)wchar >=3D 0x100) { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } =20 diff --git a/newlib/libc/string/strerror.c b/newlib/libc/string/strerror.= c index c1b934696..8f961d3b5 100644 --- a/newlib/libc/string/strerror.c +++ b/newlib/libc/string/strerror.c @@ -882,7 +882,7 @@ _strerror_r (struct _reent *ptr, #endif default: if (!errptr) - errptr =3D &ptr->_errno; + errptr =3D &_REENT_ERRNO(ptr); if ((error =3D _user_strerror (errnum, internal, errptr)) =3D=3D 0= ) error =3D ""; break; diff --git a/winsup/cygwin/cygerrno.h b/winsup/cygwin/cygerrno.h index 940bfa5e0..e1c3f04f7 100644 --- a/winsup/cygwin/cygerrno.h +++ b/winsup/cygwin/cygerrno.h @@ -36,7 +36,7 @@ extern inline int __set_errno (const char *fn, int ln, int val) { debug_printf ("%s:%d setting errno %d", fn, ln, val); - return errno =3D _impure_ptr->_errno =3D val; + return errno =3D _REENT_ERRNO(_impure_ptr) =3D val; } #define set_errno(val) __set_errno (__PRETTY_FUNCTION__, __LINE__, (val)= ) =20 @@ -55,7 +55,7 @@ class save_errno save_errno (int what) {saved =3D get_errno (); set_errno (what); } void set (int what) {set_errno (what); saved =3D what;} void reset () {saved =3D get_errno ();} - ~save_errno () {errno =3D _impure_ptr->_errno =3D saved;} + ~save_errno () {errno =3D _REENT_ERRNO(_impure_ptr) =3D saved;} }; =20 extern const char *__sp_fn; diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index f200e5b73..2f2c26984 100644 --- a/winsup/cygwin/errno.cc +++ b/winsup/cygwin/errno.cc @@ -335,7 +335,7 @@ void seterrno_from_win_error (const char *file, int line, DWORD code) { syscall_printf ("%s:%d windows error %u", file, line, code); - errno =3D _impure_ptr->_errno =3D geterrno_from_win_error (code, EACC= ES); + errno =3D _REENT_ERRNO(_impure_ptr) =3D geterrno_from_win_error (code= , EACCES); } =20 int @@ -353,7 +353,7 @@ seterrno_from_nt_status (const char *file, int line, = NTSTATUS status) SetLastError (code); syscall_printf ("%s:%d status %y -> windows error %u", file, line, status, code); - errno =3D _impure_ptr->_errno =3D geterrno_from_win_error (code, EACC= ES); + errno =3D _REENT_ERRNO(_impure_ptr) =3D geterrno_from_win_error (code= , EACCES); } =20 static char * diff --git a/winsup/cygwin/strfuncs.cc b/winsup/cygwin/strfuncs.cc index 9a97b3a24..22a79b614 100644 --- a/winsup/cygwin/strfuncs.cc +++ b/winsup/cygwin/strfuncs.cc @@ -144,7 +144,7 @@ __db_wctomb (struct _reent *r, char *s, wchar_t wchar= , UINT cp) if (ret > 0 && !def_used) return ret; =20 - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } =20 @@ -194,7 +194,7 @@ __eucjp_wctomb (struct _reent *r, char *s, wchar_t wc= har, mbstate_t *state) return ret; } =20 - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } =20 @@ -255,7 +255,7 @@ __db_mbtowc (struct _reent *r, wchar_t *pwc, const ch= ar *s, size_t n, UINT cp, here is to check if the first byte returns a valid value... */ else if (MultiByteToWideChar (cp, MB_ERR_INVALID_CHARS, s, 1, pwc,= 1)) return 1; - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } state->__value.__wchb[state->__count] =3D *s; @@ -263,7 +263,7 @@ __db_mbtowc (struct _reent *r, wchar_t *pwc, const ch= ar *s, size_t n, UINT cp, (const char *) state->__value.__wchb, 2, pwc, 1); if (!ret) { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } state->__count =3D 0; @@ -324,7 +324,7 @@ __eucjp_mbtowc (struct _reent *r, wchar_t *pwc, const= char *s, size_t n, } else if (MultiByteToWideChar (20932, MB_ERR_INVALID_CHARS, s, 1, p= wc, 1)) return 1; - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } state->__value.__wchb[state->__count++] =3D *s; @@ -347,7 +347,7 @@ jis_x_0212: if (!MultiByteToWideChar (20932, MB_ERR_INVALID_CHARS, (const char *) state->__value.__wchb, 2, pwc, 1)) { - r->_errno =3D EILSEQ; + _REENT_ERRNO(r) =3D EILSEQ; return -1; } state->__count =3D 0; diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 7d53c2af7..b8260b4d1 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1900,7 +1900,7 @@ _fstat_r (struct _reent *ptr, int fd, struct stat *= buf) int ret; =20 if ((ret =3D fstat (fd, buf)) =3D=3D -1) - ptr->_errno =3D get_errno (); + _REENT_ERRNO(ptr) =3D get_errno (); return ret; } =20 @@ -2051,7 +2051,7 @@ _stat_r (struct _reent *__restrict ptr, const char = *__restrict name, int ret; =20 if ((ret =3D stat (name, buf)) =3D=3D -1) - ptr->_errno =3D get_errno (); + _REENT_ERRNO(ptr) =3D get_errno (); return ret; } =20 --=20 2.35.3