From a492c6ec119bd1151a6f2f7b70875ba173e9c036 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 3 Sep 2023 01:30:53 +0200 Subject: libc: split up large .c files, slimming down small binaries a bit --- src/libc/stdio/fprintf.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/libc/stdio/fprintf.c (limited to 'src/libc/stdio/fprintf.c') diff --git a/src/libc/stdio/fprintf.c b/src/libc/stdio/fprintf.c new file mode 100644 index 0000000..cd2851c --- /dev/null +++ b/src/libc/stdio/fprintf.c @@ -0,0 +1,32 @@ +#include +#include + +static void backend_file(void *arg, const char *buf, size_t len) { + fwrite(buf, 1, len, arg); +} + +int fprintf(FILE *restrict f, const char *restrict fmt, ...) { + int ret; + va_list argp; + va_start(argp, fmt); + ret = vfprintf(f, fmt, argp); + va_end(argp); + return ret; +} + +int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap) { + return __printf_internal(fmt, ap, backend_file, f); +} + +int printf(const char *restrict fmt, ...) { + int ret; + va_list argp; + va_start(argp, fmt); + ret = vprintf(fmt, argp); + va_end(argp); + return ret; +} + +int vprintf(const char *restrict fmt, va_list ap) { + return vfprintf(stdout, fmt, ap); +} -- cgit v1.2.3