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-28 12:58:36 +0300
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-07-13 07:55:46 +0300
commit627a5cb4133ece2a80dbca27c403d4ceb3139130 (patch)
tree039bdd320b53c183829c7c32712e09da41ccf0ee /newlib/libc/include
parentf3b8138239d3ba34c4ecaa4305b0fbd7eb4e28a5 (diff)
Add _REENT_STDIN(ptr)
Add a _REENT_STDIN() macro to encapsulate access to the _stdin member of struct reent. This will help to replace the struct member with a thread-local storage object in a follow up patch.
Diffstat (limited to 'newlib/libc/include')
-rw-r--r--newlib/libc/include/stdio.h4
-rw-r--r--newlib/libc/include/sys/reent.h1
-rw-r--r--newlib/libc/include/wchar.h4
3 files changed, 5 insertions, 4 deletions
diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
index b995b56d2..c802b3737 100644
--- a/newlib/libc/include/stdio.h
+++ b/newlib/libc/include/stdio.h
@@ -167,11 +167,11 @@ typedef _ssize_t ssize_t;
#define TMP_MAX 26
-#define stdin (_REENT->_stdin)
+#define stdin _REENT_STDIN(_REENT)
#define stdout (_REENT->_stdout)
#define stderr (_REENT->_stderr)
-#define _stdin_r(x) ((x)->_stdin)
+#define _stdin_r(x) _REENT_STDIN(x)
#define _stdout_r(x) ((x)->_stdout)
#define _stderr_r(x) ((x)->_stderr)
diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reent.h
index 70a987100..801fe20f4 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_STDIN(_ptr) ((_ptr)->_stdin)
#define _REENT_INIT_PTR(var) \
{ memset((var), 0, sizeof(*(var))); \
diff --git a/newlib/libc/include/wchar.h b/newlib/libc/include/wchar.h
index 0d3e636f9..5e9202820 100644
--- a/newlib/libc/include/wchar.h
+++ b/newlib/libc/include/wchar.h
@@ -320,13 +320,13 @@ int _wscanf_r (struct _reent *, const wchar_t *, ...);
#define getwc(fp) fgetwc(fp)
#define putwc(wc,fp) fputwc((wc), (fp))
-#define getwchar() fgetwc(_REENT->_stdin)
+#define getwchar() fgetwc(_REENT_STDIN(_REENT))
#define putwchar(wc) fputwc((wc), _REENT->_stdout)
#if __GNU_VISIBLE
#define getwc_unlocked(fp) fgetwc_unlocked(fp)
#define putwc_unlocked(wc,fp) fputwc_unlocked((wc), (fp))
-#define getwchar_unlocked() fgetwc_unlocked(_REENT->_stdin)
+#define getwchar_unlocked() fgetwc_unlocked(_REENT_STDIN(_REENT))
#define putwchar_unlocked(wc) fputwc_unlocked((wc), _REENT->_stdout)
#endif