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.
This commit is contained in:
Matt Joyce 2022-02-02 09:49:00 +01:00 committed by Sebastian Huber
parent e56801f34d
commit 0985d418cb
2 changed files with 4 additions and 3 deletions

View File

@ -720,6 +720,7 @@ struct _reent
#define _REENT_EMERGENCY(_ptr) ((_ptr)->_emergency) #define _REENT_EMERGENCY(_ptr) ((_ptr)->_emergency)
#define _REENT_ERRNO(_ptr) ((_ptr)->_errno) #define _REENT_ERRNO(_ptr) ((_ptr)->_errno)
#define _REENT_INC(_ptr) ((_ptr)->_inc)
#define _REENT_STDIN(_ptr) ((_ptr)->_stdin) #define _REENT_STDIN(_ptr) ((_ptr)->_stdin)
#define _REENT_STDOUT(_ptr) ((_ptr)->_stdout) #define _REENT_STDOUT(_ptr) ((_ptr)->_stdout)
#define _REENT_STDERR(_ptr) ((_ptr)->_stderr) #define _REENT_STDERR(_ptr) ((_ptr)->_stderr)

View File

@ -135,9 +135,9 @@ _tmpnam_r (struct _reent *p,
} }
pid = _getpid_r (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; return result;
} }
@ -162,7 +162,7 @@ _tempnam_r (struct _reent *p,
if (filename) if (filename)
{ {
if (! worker (p, filename, dir, prefix, 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 NULL;
} }
return filename; return filename;