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 <yselkowi@redhat.com>
This commit is contained in:
Yaakov Selkowitz 2016-08-12 03:16:52 -05:00
parent 9169111acf
commit b14a1dbc86
2 changed files with 31 additions and 3 deletions

View File

@ -35,9 +35,22 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#include <stddef.h> #include <stddef.h>
/* typedef only __gnuc_va_list, used throughout the header */
#define __need___va_list #define __need___va_list
#include <stdarg.h> #include <stdarg.h>
/* 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 <stdarg.h>
#endif
#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
/* /*
* <sys/reent.h> defines __FILE, _fpos_t. * <sys/reent.h> defines __FILE, _fpos_t.
* They must be defined there because struct _reent needs them (and we don't * They must be defined there because struct _reent needs them (and we don't

View File

@ -11,15 +11,28 @@
#define __need_NULL #define __need_NULL
#include <stddef.h> #include <stddef.h>
#define __need___va_list
#include <stdarg.h>
/* For _mbstate_t definition. */ /* For _mbstate_t definition. */
#include <sys/_types.h> #include <sys/_types.h>
#include <sys/cdefs.h> #include <sys/cdefs.h>
/* For __STDC_ISO_10646__ */ /* For __STDC_ISO_10646__ */
#include <sys/features.h> #include <sys/features.h>
/* typedef only __gnuc_va_list, used throughout the header */
#define __need___va_list
#include <stdarg.h>
/* 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 <stdarg.h>
#endif
#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
#if __XSI_VISIBLE /* && __XSI_VISIBLE < 800 */ #if __XSI_VISIBLE /* && __XSI_VISIBLE < 800 */
#include <wctype.h> #include <wctype.h>
#endif #endif
@ -52,11 +65,13 @@
_BEGIN_STD_C _BEGIN_STD_C
#if __POSIX_VISIBLE >= 200809 || _XSI_VISIBLE
/* As in stdio.h, <sys/reent.h> defines __FILE. */ /* As in stdio.h, <sys/reent.h> defines __FILE. */
#if !defined(__FILE_defined) #if !defined(__FILE_defined)
typedef __FILE FILE; typedef __FILE FILE;
# define __FILE_defined # define __FILE_defined
#endif #endif
#endif
/* As required by POSIX.1-2008, declare tm as incomplete type. /* As required by POSIX.1-2008, declare tm as incomplete type.
The actual definition is in time.h. */ The actual definition is in time.h. */