Add function "kernaux_printf"

This commit is contained in:
Alex Kotov 2020-12-07 02:37:53 +05:00
parent 1bdda5b53e
commit ceff5cf197
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
8 changed files with 53 additions and 3 deletions

View File

@ -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

View File

@ -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)*

View File

@ -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

View File

@ -4,4 +4,5 @@ nobase_include_HEADERS = \
kernaux/console.h \
kernaux/multiboot2.h \
kernaux/pfa.h \
kernaux/printf.h \
kernaux/stdlib.h

17
include/kernaux/printf.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef KERNAUX_INCLUDED_PRINTF
#define KERNAUX_INCLUDED_PRINTF 1
#include <stdarg.h>
#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

19
src/printf.c Normal file
View File

@ -0,0 +1,19 @@
#include "config.h"
#include <kernaux/printf.h>
#include <kernaux/stdlib.h>
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
) {
}

BIN
tests/test_printf Executable file

Binary file not shown.

6
tests/test_printf.c Normal file
View File

@ -0,0 +1,6 @@
#include <kernaux/printf.h>
int main()
{
return 0;
}