From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1921) id 3BEFB385416D; Wed, 13 Jul 2022 08:19:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3BEFB385416D Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Sebastian Huber To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Add _REENT_INC(ptr) X-Act-Checkin: newlib-cygwin X-Git-Author: Matt Joyce X-Git-Refname: refs/heads/master X-Git-Oldrev: e56801f34d798eafa054b383de5bf2df986576cc X-Git-Newrev: 0985d418cb2d0a5ba56518e9e1fb9a31f3c7ba48 Message-Id: <20220713081938.3BEFB385416D@sourceware.org> Date: Wed, 13 Jul 2022 08:19:38 +0000 (GMT) X-BeenThere: newlib-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib GIT logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2022 08:19:38 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D0985d418cb2= d0a5ba56518e9e1fb9a31f3c7ba48 commit 0985d418cb2d0a5ba56518e9e1fb9a31f3c7ba48 Author: Matt Joyce Date: Wed Feb 2 09:49:00 2022 +0100 Add _REENT_INC(ptr) =20 Add a _REENT_INC() macro to encapsulate access to the _inc member of struct reent. This will help to replace the struct member with a thread-local storage object in a follow up patch. Diff: --- newlib/libc/include/sys/reent.h | 1 + newlib/libc/stdio/tmpnam.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reen= t.h index c0647cfd9..2c1593a5f 100644 --- a/newlib/libc/include/sys/reent.h +++ b/newlib/libc/include/sys/reent.h @@ -720,6 +720,7 @@ struct _reent =20 #define _REENT_EMERGENCY(_ptr) ((_ptr)->_emergency) #define _REENT_ERRNO(_ptr) ((_ptr)->_errno) +#define _REENT_INC(_ptr) ((_ptr)->_inc) #define _REENT_STDIN(_ptr) ((_ptr)->_stdin) #define _REENT_STDOUT(_ptr) ((_ptr)->_stdout) #define _REENT_STDERR(_ptr) ((_ptr)->_stderr) diff --git a/newlib/libc/stdio/tmpnam.c b/newlib/libc/stdio/tmpnam.c index 7379a7640..2767b4b20 100644 --- a/newlib/libc/stdio/tmpnam.c +++ b/newlib/libc/stdio/tmpnam.c @@ -135,9 +135,9 @@ _tmpnam_r (struct _reent *p, } pid =3D _getpid_r (p); =20 - if (worker (p, result, P_tmpdir, "t", pid, &p->_inc)) + if (worker (p, result, P_tmpdir, "t", pid, &_REENT_INC(p))) { - p->_inc++; + _REENT_INC(p)++; return result; } =20 @@ -162,7 +162,7 @@ _tempnam_r (struct _reent *p, if (filename) { if (! worker (p, filename, dir, prefix, - _getpid_r (p) ^ (int) (_POINTER_INT) p, &p->_inc)) + _getpid_r (p) ^ (int) (_POINTER_INT) p, &_REENT_INC(p))) return NULL; } return filename;