diff --git a/libc/src/stdio/printf_core/CMakeLists.txt b/libc/src/stdio/printf_core/CMakeLists.txt --- a/libc/src/stdio/printf_core/CMakeLists.txt +++ b/libc/src/stdio/printf_core/CMakeLists.txt @@ -61,8 +61,10 @@ ) -add_header_library( +add_object_library( printf_main + SRCS + printf_main.cpp HDRS printf_main.h DEPENDS diff --git a/libc/src/stdio/printf_core/file_writer.h b/libc/src/stdio/printf_core/file_writer.h --- a/libc/src/stdio/printf_core/file_writer.h +++ b/libc/src/stdio/printf_core/file_writer.h @@ -17,7 +17,7 @@ // write_to_file treats raw_pointer as a File and calls its write // function. -void write_to_file(void *raw_pointer, const char *__restrict to_write, +inline void write_to_file(void *raw_pointer, const char *__restrict to_write, size_t len) { __llvm_libc::File *file = reinterpret_cast<__llvm_libc::File *>(raw_pointer); file->write(to_write, len); diff --git a/libc/src/stdio/printf_core/printf_main.h b/libc/src/stdio/printf_core/printf_main.h --- a/libc/src/stdio/printf_core/printf_main.h +++ b/libc/src/stdio/printf_core/printf_main.h @@ -10,9 +10,6 @@ #define LLVM_LIBC_SRC_STDIO_PRINTF_CORE_PRINTF_MAIN_H #include "src/__support/arg_list.h" -#include "src/stdio/printf_core/converter.h" -#include "src/stdio/printf_core/core_structs.h" -#include "src/stdio/printf_core/parser.h" #include "src/stdio/printf_core/writer.h" #include @@ -21,19 +18,7 @@ namespace printf_core { int printf_main(Writer *writer, const char *__restrict str, - internal::ArgList &args) { - Parser parser(str, args); - - for (FormatSection cur_section = parser.get_next_section(); - cur_section.raw_len > 0; cur_section = parser.get_next_section()) { - if (cur_section.has_conv) - convert(writer, cur_section); - else - writer->write(cur_section.raw_string, cur_section.raw_len); - } - - return writer->get_chars_written(); -} + internal::ArgList &args); } // namespace printf_core } // namespace __llvm_libc diff --git a/libc/src/stdio/printf_core/printf_main.h b/libc/src/stdio/printf_core/printf_main.cpp copy from libc/src/stdio/printf_core/printf_main.h copy to libc/src/stdio/printf_core/printf_main.cpp --- a/libc/src/stdio/printf_core/printf_main.h +++ b/libc/src/stdio/printf_core/printf_main.cpp @@ -6,8 +6,7 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_STDIO_PRINTF_CORE_PRINTF_MAIN_H -#define LLVM_LIBC_SRC_STDIO_PRINTF_CORE_PRINTF_MAIN_H +#include "src/stdio/printf_core/printf_main.h" #include "src/__support/arg_list.h" #include "src/stdio/printf_core/converter.h" @@ -37,5 +36,3 @@ } // namespace printf_core } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_STDIO_PRINTF_CORE_PRINTF_MAIN_H diff --git a/libc/src/stdio/printf_core/string_writer.h b/libc/src/stdio/printf_core/string_writer.h --- a/libc/src/stdio/printf_core/string_writer.h +++ b/libc/src/stdio/printf_core/string_writer.h @@ -44,7 +44,7 @@ // write_to_string treats raw_pointer as a StringWriter and calls its write // function. -void write_to_string(void *raw_pointer, const char *__restrict to_write, +inline void write_to_string(void *raw_pointer, const char *__restrict to_write, size_t len) { StringWriter *string_writer = reinterpret_cast(raw_pointer); string_writer->write(to_write, len);