boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

stdarg.h (2079B)


      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 build/<arch>/vendor/tcc/stdarg-bridge.h, which is
     13  * generated from tcc-0.9.26's own include/stdarg.h (patched) and
     14  * prepended to libc.flat.c so that tcc itself — which has no
     15  * __builtin_va_* keywords — can compile through the flattened libc
     16  * by mapping __builtin_va_* onto its native __va_* intrinsics.
     17  */
     18 #ifndef __MES_STDARG_H
     19 #define __MES_STDARG_H 1
     20 
     21 typedef __builtin_va_list va_list;
     22 
     23 #define va_start(v, l)     __builtin_va_start((v), (l))
     24 #define va_end(v)          __builtin_va_end((v))
     25 #define va_arg(v, t)       __builtin_va_arg((v), t)
     26 #define va_arg8(ap, type)  va_arg((ap), type)
     27 #define va_copy(d, s)      __builtin_va_copy((d), (s))
     28 
     29 /* mes/include/stdarg.h forward-declares the v* family here (instead
     30  * of in <stdio.h>); tcc.c calls vsnprintf without ever including
     31  * <stdio.h>, so dropping mes's stdarg.h in favor of this shim must
     32  * still leak these prototypes. FILE and size_t come from a prior
     33  * include in mes-libc TUs; tcc.c works because it includes
     34  * <sys/types.h> for size_t and uses (FILE*) implicitly. */
     35 int vexec    (char const *file_name, va_list ap);
     36 int vfprintf (FILE *stream, char const *template, va_list ap);
     37 int vfscanf  (FILE *stream, char const *template, va_list ap);
     38 int vprintf  (char const *format, va_list ap);
     39 int vsprintf (char *str, char const *format, va_list ap);
     40 int vsnprintf(char *str, size_t size, char const *format, va_list ap);
     41 int vsscanf  (char const *s, char const *template, va_list ap);
     42 
     43 #endif /* __MES_STDARG_H */