public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Sebastian Huber <sh@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] Add _REENT_INC(ptr)
Date: Wed, 13 Jul 2022 08:19:38 +0000 (GMT)	[thread overview]
Message-ID: <20220713081938.3BEFB385416D@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0985d418cb2d0a5ba56518e9e1fb9a31f3c7ba48

commit 0985d418cb2d0a5ba56518e9e1fb9a31f3c7ba48
Author: Matt Joyce <matthew.joyce@embedded-brains.de>
Date:   Wed Feb 2 09:49:00 2022 +0100

    Add _REENT_INC(ptr)
    
    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/reent.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
 
 #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 = _getpid_r (p);
 
-  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;
     }
 
@@ -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;


                 reply	other threads:[~2022-07-13  8:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220713081938.3BEFB385416D@sourceware.org \
    --to=sh@sourceware.org \
    --cc=newlib-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).