stdarg.h (1830B)
1 /* boot2 stdarg.h — shadows mes/include/stdarg.h for both flatten 2 * paths (scripts/{stage1,libc}-flatten.sh both have -I on the 3 * containing dir ahead of mes's include tree). Routes va_* through 4 * __builtin_va_*, so tcc.flat.c and libc.flat.c compile cleanly 5 * under both our cc.scm (which recognizes __builtin_va_list and 6 * __builtin_va_start/arg/end) and stock gcc/clang (where they're 7 * native). 8 * 9 * Mes's stdarg.h has a similar __builtin-routed branch but only 10 * activates under __riscv. We can't set -D __riscv at flatten time 11 * without also flipping setjmp.h and tcc-internal arch logic, so we 12 * shadow the whole header instead. 13 */ 14 #ifndef __MES_STDARG_H 15 #define __MES_STDARG_H 1 16 17 typedef __builtin_va_list va_list; 18 19 #define va_start(v, l) __builtin_va_start((v), (l)) 20 #define va_end(v) __builtin_va_end((v)) 21 #define va_arg(v, t) __builtin_va_arg((v), t) 22 #define va_arg8(ap, type) va_arg((ap), type) 23 #define va_copy(d, s) __builtin_va_copy((d), (s)) 24 25 /* mes/include/stdarg.h forward-declares the v* family here (instead 26 * of in <stdio.h>); tcc.c calls vsnprintf without ever including 27 * <stdio.h>, so dropping mes's stdarg.h in favor of this shim must 28 * still leak these prototypes. FILE and size_t come from a prior 29 * include in mes-libc TUs; tcc.c works because it includes 30 * <sys/types.h> for size_t and uses (FILE*) implicitly. */ 31 int vexec (char const *file_name, va_list ap); 32 int vfprintf (FILE *stream, char const *template, va_list ap); 33 int vfscanf (FILE *stream, char const *template, va_list ap); 34 int vprintf (char const *format, va_list ap); 35 int vsprintf (char *str, char const *format, va_list ap); 36 int vsnprintf(char *str, size_t size, char const *format, va_list ap); 37 int vsscanf (char const *s, char const *template, va_list ap); 38 39 #endif /* __MES_STDARG_H */