public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] fix incompatible pointer type for va_list in nano versions of printf and scanf for target like Power
Date: Mon, 08 Jan 2018 10:07:00 -0000 [thread overview]
Message-ID: <20180108100702.19295.qmail@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=fcd33916ac03086b9090c68e88036afa4b25d913
commit fcd33916ac03086b9090c68e88036afa4b25d913
Author: Alexander Fedotov <alfedotov@gmail.com>
Date: Mon Dec 25 16:28:22 2017 +0300
fix incompatible pointer type for va_list in nano versions of printf and scanf for target like PowerPC
Diff:
---
newlib/libc/stdio/nano-vfprintf.c | 14 ++++++++++++--
newlib/libc/stdio/nano-vfscanf.c | 15 ++++++++++++---
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/newlib/libc/stdio/nano-vfprintf.c b/newlib/libc/stdio/nano-vfprintf.c
index e6604e7..663eb71 100644
--- a/newlib/libc/stdio/nano-vfprintf.c
+++ b/newlib/libc/stdio/nano-vfprintf.c
@@ -168,6 +168,16 @@ static char *rcsid = "$Id$";
#include "vfieeefp.h"
#include "nano-vfprintf_local.h"
+
+/* GCC PR 14577 at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14557 */
+#if __STDC_VERSION__ >= 201112L
+#define va_ptr(ap) _Generic(&(ap), va_list *: &(ap), default: (va_list *)(ap))
+#elif __GNUC__ >= 4
+#define va_ptr(ap) __builtin_choose_expr(__builtin_types_compatible_p(__typeof__(&(ap)), va_list *), &(ap), (va_list *)(ap))
+#else
+#define va_ptr(ap) (sizeof(ap) == sizeof(va_list) ? (va_list *)&(ap) : (va_list *)(ap))
+#endif
+
/* The __ssputs_r function is shared between all versions of vfprintf
and vfwprintf. */
#ifdef STRING_ONLY
@@ -633,12 +643,12 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
}
else
{
- n = _printf_float (data, &prt_data, fp, pfunc, &ap);
+ n = _printf_float (data, &prt_data, fp, pfunc, va_ptr(ap));
}
}
else
#endif
- n = _printf_i (data, &prt_data, fp, pfunc, &ap);
+ n = _printf_i (data, &prt_data, fp, pfunc, va_ptr(ap));
if (n == -1)
goto error;
diff --git a/newlib/libc/stdio/nano-vfscanf.c b/newlib/libc/stdio/nano-vfscanf.c
index 564f291..6467e54 100644
--- a/newlib/libc/stdio/nano-vfscanf.c
+++ b/newlib/libc/stdio/nano-vfscanf.c
@@ -119,6 +119,15 @@ Supporting OS subroutines required:
#include "../stdlib/local.h"
#include "nano-vfscanf_local.h"
+/* GCC PR 14577 at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14557 */
+#if __STDC_VERSION__ >= 201112L
+#define va_ptr(ap) _Generic(&(ap), va_list *: &(ap), default: (va_list *)(ap))
+#elif __GNUC__ >= 4
+#define va_ptr(ap) __builtin_choose_expr(__builtin_types_compatible_p(__typeof__(&(ap)), va_list *), &(ap), (va_list *)(ap))
+#else
+#define va_ptr(ap) (sizeof(ap) == sizeof(va_list) ? (va_list *)&(ap) : (va_list *)(ap))
+#endif
+
#define VFSCANF vfscanf
#define _VFSCANF_R _vfscanf_r
#define __SVFSCANF __svfscanf
@@ -424,12 +433,12 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
}
ret = 0;
if (scan_data.code < CT_INT)
- ret = _scanf_chars (rptr, &scan_data, fp, &ap);
+ ret = _scanf_chars (rptr, &scan_data, fp, va_ptr(ap));
else if (scan_data.code < CT_FLOAT)
- ret = _scanf_i (rptr, &scan_data, fp, &ap);
+ ret = _scanf_i (rptr, &scan_data, fp, va_ptr(ap));
#ifdef FLOATING_POINT
else if (_scanf_float)
- ret = _scanf_float (rptr, &scan_data, fp, &ap);
+ ret = _scanf_float (rptr, &scan_data, fp, va_ptr(ap));
#endif
if (ret == MATCH_FAILURE)
reply other threads:[~2018-01-08 10:07 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=20180108100702.19295.qmail@sourceware.org \
--to=corinna@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).