From 341bd73cb04f9c6e17f5e43173823c85c6f9c9ff Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 28 May 2012 16:58:25 +0200 Subject: [PATCH] GCC no longer fixes stdio.h because of va_list. Note that for non-ANSI C programs, stdio.h includes stdarg.h which defines macros that stdio.h wasn't supposed to define. --- libmaxsi/decl/va_list.h | 3 ++- libmaxsi/include/stdarg.h | 2 ++ libmaxsi/include/stdio.h | 22 ++++++++++++---------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/libmaxsi/decl/va_list.h b/libmaxsi/decl/va_list.h index 0b19e091..19663eda 100644 --- a/libmaxsi/decl/va_list.h +++ b/libmaxsi/decl/va_list.h @@ -4,5 +4,6 @@ #define va_arg(v,l) __builtin_va_arg(v,l) #define va_end(v) __builtin_va_end(v) #define va_copy(d,s) __builtin_va_copy(d,s) -typedef __builtin_va_list va_list; +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; #endif diff --git a/libmaxsi/include/stdarg.h b/libmaxsi/include/stdarg.h index 15129553..364a5e19 100644 --- a/libmaxsi/include/stdarg.h +++ b/libmaxsi/include/stdarg.h @@ -31,6 +31,8 @@ __BEGIN_DECLS @include(va_list.h) +#undef __need___va_list + __END_DECLS #endif diff --git a/libmaxsi/include/stdio.h b/libmaxsi/include/stdio.h index 31276c8c..361e6e26 100644 --- a/libmaxsi/include/stdio.h +++ b/libmaxsi/include/stdio.h @@ -27,15 +27,17 @@ #include #include +#if __STRICT_ANSI__ +#define __need___va_list +#endif +#include __BEGIN_DECLS @include(off_t.h) @include(size_t.h) @include(ssize_t.h) -@include(va_list.h) @include(NULL.h) - @include(FILE.h) struct _fpos_t; @@ -105,10 +107,10 @@ extern char* sortix_gets(void); extern int sortix_puts(const char* str); extern int sprintf(char* restrict s, const char* restrict format, ...); extern int sscanf(const char* restrict s, const char* restrict format, ...); -extern int vfprintf(FILE* restrict stream, const char* restrict format, va_list ap); -extern int vprintf(const char* restrict format, va_list ap); -extern int vsnprintf(char* restrict, size_t, const char* restrict, va_list); -extern int vsprintf(char* restrict s, const char* restrict format, va_list ap); +extern int vfprintf(FILE* restrict stream, const char* restrict format, __gnuc_va_list ap); +extern int vprintf(const char* restrict format, __gnuc_va_list ap); +extern int vsnprintf(char* restrict, size_t, const char* restrict, __gnuc_va_list); +extern int vsprintf(char* restrict s, const char* restrict format, __gnuc_va_list ap); /* TODO: These are not implemented in libmaxsi/sortix yet. */ #if defined(__SORTIX_SHOW_UNIMPLEMENTED) @@ -133,10 +135,10 @@ extern int renameat(int oldfd, const char* oldname, int newfd, const char* newna extern int scanf(const char* restrict format, ...); extern int setvbuf(FILE* restrict stream, char* restrict buf, int type, size_t size); extern int ungetc(int c, FILE* stream); -extern int vdprintf(int fildes, const char* restrict format, va_list ap); -extern int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); -extern int vscanf(const char* restrict format, va_list arg); -extern int vsscanf(const char* restrict s, const char* restrict format, va_list arg); +extern int vdprintf(int fildes, const char* restrict format, __gnuc_va_list ap); +extern int vfscanf(FILE* restrict stream, const char* restrict format, __gnuc_va_list arg); +extern int vscanf(const char* restrict format, __gnuc_va_list arg); +extern int vsscanf(const char* restrict s, const char* restrict format, __gnuc_va_list arg); extern void flockfile(FILE* file); extern void funlockfile(FILE* file); extern void setbuf(FILE* restrict stream, char* restrict buf);