diff --git a/src/usr/include/stdarg.h b/src/usr/include/stdarg.h index 0c0bcb4..126c0b8 100644 --- a/src/usr/include/stdarg.h +++ b/src/usr/include/stdarg.h @@ -6,12 +6,13 @@ namespace std { #endif typedef struct va_list { - int *base; // using int* to jmp at 4 bytes gap + void *base; } va_list; -#define va_start(list, last) ((list).base = (((int*)&(last))+1)) +#define va_start(list, last) ((list).base = ((void*)(&(last)+1))) #define va_end(list) (list).base = NULL -#define va_arg(list, type) (*(type*)((list).base++)) +#define va_arg(list, type) (*(type*)((list).base+=sizeof(type), \ + (list).base-sizeof(type))) #define va_copy(dst, src) (dst).base = (src).base #ifdef __cplusplus diff --git a/src/usr/lib/stdio.c b/src/usr/lib/stdio.c index ec5f546..54d2f61 100644 --- a/src/usr/lib/stdio.c +++ b/src/usr/lib/stdio.c @@ -42,7 +42,7 @@ static int vsnprintf(char *s, size_t n, const char *fmt, va_list args) { s[len++]='%'; break; case 'c': - s[len++]=va_arg(args, char); + s[len++]=(char)va_arg(args, int); break; case 's': innerstr = va_arg(args, const char*);