diff --git a/Makefile.am b/Makefile.am index 7fc8ebc..8f07ae2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,11 +10,13 @@ AM_CFLAGS = \ lib_LIBRARIES = libkernaux.a TESTS = \ + tests/test_printf \ tests/test_stdlib noinst_PROGRAMS = $(TESTS) libkernaux_a_SOURCES = \ + src/printf.c \ src/stdlib.c if ARCH_X86 @@ -83,6 +85,10 @@ tests_test_pfa_SOURCES = \ $(libkernaux_a_SOURCES) \ tests/test_pfa.c +tests_test_printf_SOURCES = \ + $(libkernaux_a_SOURCES) \ + tests/test_printf.c + tests_test_stdlib_SOURCES = \ $(libkernaux_a_SOURCES) \ tests/test_stdlib.c diff --git a/README.md b/README.md index 6876262..09b2e94 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,12 @@ API * [Page Frame Allocator](/include/kernaux/pfa.h) *(work in progress)* * ELF utils *(planned)* * [Architecture-specific helpers](/include/kernaux/arch/) -* [stdlib replacement](/include/kernaux/stdlib.h) (with prefix): +* [printf replacement](/include/kernaux/printf.h) *(work in progress)* +* [stdlib replacement](/include/kernaux/stdlib.h): * `memset` * `strlen` * `strncpy` - * `itoa` *(incomplete)* + * `itoa` *(work in progress)* diff --git a/configure.ac b/configure.ac index 6c1a151..43a2646 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,6 @@ AC_PROG_CC_C99 AC_PROG_RANLIB AC_C_INLINE AC_CHECK_HEADER_STDBOOL -AC_CHECK_HEADERS([stddef.h]) +AC_CHECK_HEADERS([stdarg.h stddef.h]) AC_OUTPUT diff --git a/include/Makefile.am b/include/Makefile.am index 7f41fc3..ad88137 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -4,4 +4,5 @@ nobase_include_HEADERS = \ kernaux/console.h \ kernaux/multiboot2.h \ kernaux/pfa.h \ + kernaux/printf.h \ kernaux/stdlib.h diff --git a/include/kernaux/printf.h b/include/kernaux/printf.h new file mode 100644 index 0000000..09da72c --- /dev/null +++ b/include/kernaux/printf.h @@ -0,0 +1,17 @@ +#ifndef KERNAUX_INCLUDED_PRINTF +#define KERNAUX_INCLUDED_PRINTF 1 + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void kernaux_printf(void (*putchar)(char), const char *format, ...); +void kernaux_printf_va(void (*putchar)(char), const char *format, va_list va); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/printf.c b/src/printf.c new file mode 100644 index 0000000..2f9ef8d --- /dev/null +++ b/src/printf.c @@ -0,0 +1,19 @@ +#include "config.h" + +#include +#include + +void kernaux_printf(void (*putchar)(char), const char *format, ...) +{ + va_list va; + va_start(va, format); + kernaux_printf_va(putchar, format, va); + va_end(va); +} + +void kernaux_printf_va( + void (*const putchar)(char), + const char *format, + va_list va +) { +} diff --git a/tests/test_printf b/tests/test_printf new file mode 100755 index 0000000..3584e9c Binary files /dev/null and b/tests/test_printf differ diff --git a/tests/test_printf.c b/tests/test_printf.c new file mode 100644 index 0000000..5df8faf --- /dev/null +++ b/tests/test_printf.c @@ -0,0 +1,6 @@ +#include + +int main() +{ + return 0; +}