stdarg.h (2030B)
1 /* boot2 stdarg.h — flatten-time stdarg shim used by host `cc -E` in 2 * bootprep/stage1-flatten.sh (tcc.flat.c) and bootprep/libc-flatten.sh 3 * (libc.flat.c). Both pass -nostdinc and -I bootprep/headers, so this 4 * is what tcc's source and vendor/mes-libc/libc.c see for <stdarg.h> 5 * when the host preprocessor flattens them. 6 * 7 * Routes va_* through __builtin_va_*, so the resulting flat.c 8 * compiles cleanly under both cc.scm (which recognizes 9 * __builtin_va_list and __builtin_va_start/arg/end as builtins) 10 * and stock gcc/clang (where they're native). 11 * 12 * Distinct from tcc-0.9.26's compiler-owned include/stdarg.h, which is 13 * patched and prepended to libc.flat.c so that tcc itself — which has 14 * no __builtin_va_* keywords — can compile through the flattened libc 15 * by mapping __builtin_va_* onto its native __va_* intrinsics. 16 */ 17 #ifndef __MES_STDARG_H 18 #define __MES_STDARG_H 1 19 20 typedef __builtin_va_list va_list; 21 22 #define va_start(v, l) __builtin_va_start((v), (l)) 23 #define va_end(v) __builtin_va_end((v)) 24 #define va_arg(v, t) __builtin_va_arg((v), t) 25 #define va_arg8(ap, type) va_arg((ap), type) 26 #define va_copy(d, s) __builtin_va_copy((d), (s)) 27 28 /* mes/include/stdarg.h forward-declares the v* family here (instead 29 * of in <stdio.h>); tcc.c calls vsnprintf without ever including 30 * <stdio.h>, so dropping mes's stdarg.h in favor of this shim must 31 * still leak these prototypes. FILE and size_t come from a prior 32 * include in mes-libc TUs; tcc.c works because it includes 33 * <sys/types.h> for size_t and uses (FILE*) implicitly. */ 34 int vexec (char const *file_name, va_list ap); 35 int vfprintf (FILE *stream, char const *template, va_list ap); 36 int vfscanf (FILE *stream, char const *template, va_list ap); 37 int vprintf (char const *format, va_list ap); 38 int vsprintf (char *str, char const *format, va_list ap); 39 int vsnprintf(char *str, size_t size, char const *format, va_list ap); 40 int vsscanf (char const *s, char const *template, va_list ap); 41 42 #endif /* __MES_STDARG_H */