From: Tobias Burnus <tobias@codesourcery.com>
To: <newlib@sourceware.org>
Subject: [Patch] (1/n) newlib: Only call _fputwc_r if ELIX_LEVEL >= 4 (was: Build-dependency issues with ELIX_LEVEL)
Date: Wed, 30 Mar 2022 11:43:58 +0200 [thread overview]
Message-ID: <4c157ae5-3133-88da-7156-0e454e1f6535@codesourcery.com> (raw)
In-Reply-To: <0e04b11a-1b6d-c70a-c0fe-4ece59996461@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 1030 bytes --]
Hello,
this packages the the first patch of last/first email in this thread.
As described in the commit log (and previous email),
__sprint_r and __sfputs_r of (nano-)vfprintf.c
call fputwc.c's _fputwc_r.
While the vfprintf.c file is compiled for ELIX_LEVEL >= 1,
the fputwc.c file is only compiled with ELIX_LEVEL >= 4.
Solution: This patch ignores the _WIDE_ORIENT support in
__sprint_r / __sfputs_r unless ELIX_LEVEL >= 4.
It feels like the right solution but the ELIX description is
vague enough to be not sure.
Without that patch I get for ELIX_LEVEL == 1 (with nvptx)
a link error (missing symbol) for a code calling 'fprintf'
(with no wide char used).
OK? – If so, please commit. Otherwise, comments are welcome.
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
[-- Attachment #2: 0001-newlib-Only-call-_fputwc_r-if-ELIX_LEVEL-4.patch --]
[-- Type: text/x-patch, Size: 2688 bytes --]
[PATCH] newlib: Only call _fputwc_r if ELIX_LEVEL >= 4
(nano-)vfprintf.c is enabled for ELIX_LEVEL >= 1. When _WIDE_ORIENT
is set, its __sprint_r / __sfputs_r functions unconditionally called
_fputwc_r which is only in ELEX_LEVEL >= 4. With this commit,
the _WIDE support in (nano-)vfprintf.c is disabled for ELEX_LEVEL < 4.
---
newlib/libc/stdio/nano-vfprintf.c | 4 ++--
newlib/libc/stdio/vfprintf.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/newlib/libc/stdio/nano-vfprintf.c b/newlib/libc/stdio/nano-vfprintf.c
index bc7ed0743..24472195f 100644
--- a/newlib/libc/stdio/nano-vfprintf.c
+++ b/newlib/libc/stdio/nano-vfprintf.c
@@ -351,17 +351,17 @@ __sprint_r (struct _reent *ptr,
{
register int err = 0;
if (uio->uio_resid == 0)
{
uio->uio_iovcnt = 0;
return 0;
}
-#ifdef _WIDE_ORIENT
+#if defined _WIDE_ORIENT && (!defined _ELIX_LEVEL || _ELIX_LEVEL >= 4)
if (fp->_flags2 & __SWID)
{
struct __siov *iov;
wchar_t *p;
int i, len;
iov = uio->uio_iov;
for (; uio->uio_resid != 0;
@@ -402,17 +402,17 @@ __sfputc_r (struct _reent *ptr,
int
__sfputs_r (struct _reent *ptr,
FILE *fp,
const char *buf,
size_t len)
{
register int i;
-#ifdef _WIDE_ORIENT
+#if defined _WIDE_ORIENT && (!defined _ELIX_LEVEL || _ELIX_LEVEL >= 4)
if (fp->_flags2 & __SWID)
{
wchar_t *p;
p = (wchar_t *) buf;
for (i = 0; i < (len / sizeof (wchar_t)); i++)
{
if (_fputwc_r (ptr, p[i], fp) == WEOF)
diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c
index c1483c0ac..6ff5b5686 100644
--- a/newlib/libc/stdio/vfprintf.c
+++ b/newlib/libc/stdio/vfprintf.c
@@ -365,17 +365,17 @@ int __ssprint_r (struct _reent *, FILE *, register struct __suio *);
int
__sfputs_r (struct _reent *ptr,
FILE *fp,
const char *buf,
size_t len)
{
register int i;
-#ifdef _WIDE_ORIENT
+#if defined _WIDE_ORIENT && (!defined _ELIX_LEVEL || _ELIX_LEVEL >= 4)
if (fp->_flags2 & __SWID) {
wchar_t *p;
p = (wchar_t *) buf;
for (i = 0; i < (len / sizeof (wchar_t)); i++) {
if (_fputwc_r (ptr, p[i], fp) == WEOF)
return -1;
}
@@ -401,17 +401,17 @@ __sprint_r (struct _reent *ptr,
register struct __suio *uio)
{
register int err = 0;
if (uio->uio_resid == 0) {
uio->uio_iovcnt = 0;
return (0);
}
-#ifdef _WIDE_ORIENT
+#if defined _WIDE_ORIENT && (!defined _ELIX_LEVEL || _ELIX_LEVEL >= 4)
if (fp->_flags2 & __SWID) {
struct __siov *iov;
wchar_t *p;
int i, len;
iov = uio->uio_iov;
for (; uio->uio_resid != 0;
uio->uio_resid -= len * sizeof (wchar_t), iov++) {
next prev parent reply other threads:[~2022-03-30 9:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-29 9:14 Build-dependency issues with ELIX_LEVEL Tobias Burnus
2022-03-30 9:43 ` Tobias Burnus [this message]
2022-03-30 20:02 ` [Patch] (1/n) newlib: Only call _fputwc_r if ELIX_LEVEL >= 4 (was: Build-dependency issues with ELIX_LEVEL) Jeff Johnston
2022-03-30 10:56 ` [Patch] (2/n) newlib: Move vasniprintf.c to ELIX 1 " Tobias Burnus
2022-04-06 5:11 ` *ping* " Tobias Burnus
2022-04-06 16:25 ` Jeff Johnston
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=4c157ae5-3133-88da-7156-0e454e1f6535@codesourcery.com \
--to=tobias@codesourcery.com \
--cc=newlib@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).