From b14a1dbc8643f4f93ab31c19a1ebf338d7108baa Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Fri, 12 Aug 2016 03:16:52 -0500 Subject: [PATCH] Define va_list in stdio.h and wchar.h This typedef, along with that of FILE in wchar.h, were XSI prior to inclusion in POSIX.1-2008. Fixes: https://sourceware.org/ml/newlib/2016/msg00640.html Signed-off-by: Yaakov Selkowitz --- newlib/libc/include/stdio.h | 13 +++++++++++++ newlib/libc/include/wchar.h | 21 ++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h index 866d8167d..097b0f665 100644 --- a/newlib/libc/include/stdio.h +++ b/newlib/libc/include/stdio.h @@ -35,9 +35,22 @@ #include #include +/* typedef only __gnuc_va_list, used throughout the header */ #define __need___va_list #include +/* typedef va_list only when required */ +#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE +#ifdef __GNUC__ +#ifndef _VA_LIST_DEFINED +typedef __gnuc_va_list va_list; +#define _VA_LIST_DEFINED +#endif +#else /* !__GNUC__ */ +#include +#endif +#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */ + /* * defines __FILE, _fpos_t. * They must be defined there because struct _reent needs them (and we don't diff --git a/newlib/libc/include/wchar.h b/newlib/libc/include/wchar.h index e5b840dbe..f4996ecc5 100644 --- a/newlib/libc/include/wchar.h +++ b/newlib/libc/include/wchar.h @@ -11,15 +11,28 @@ #define __need_NULL #include -#define __need___va_list -#include - /* For _mbstate_t definition. */ #include #include /* For __STDC_ISO_10646__ */ #include +/* typedef only __gnuc_va_list, used throughout the header */ +#define __need___va_list +#include + +/* typedef va_list only when required */ +#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE +#ifdef __GNUC__ +#ifndef _VA_LIST_DEFINED +typedef __gnuc_va_list va_list; +#define _VA_LIST_DEFINED +#endif +#else /* !__GNUC__ */ +#include +#endif +#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */ + #if __XSI_VISIBLE /* && __XSI_VISIBLE < 800 */ #include #endif @@ -52,11 +65,13 @@ _BEGIN_STD_C +#if __POSIX_VISIBLE >= 200809 || _XSI_VISIBLE /* As in stdio.h, defines __FILE. */ #if !defined(__FILE_defined) typedef __FILE FILE; # define __FILE_defined #endif +#endif /* As required by POSIX.1-2008, declare tm as incomplete type. The actual definition is in time.h. */