[fix][util] fix printf, use alias bflb_printf to reduce size

This commit is contained in:
jzlv 2022-11-23 10:55:06 +08:00
parent d906c9e306
commit eef2ce183c
3 changed files with 4 additions and 16 deletions

View file

@ -53,14 +53,12 @@ if(CONFIG_VLIBC)
sdk_add_compile_definitions(-DCONFIG_VLIBC_FATFS)
endif()
# sdk_add_compile_definitions(-Dprintf=vlibc_printf)
sdk_library_add_sources(vlibc/printf.c)
sdk_library_add_sources(vlibc/syscalls.c)
sdk_library_add_sources(vlibc/vlibc_stdio.c)
sdk_library_add_sources(vlibc/vlibc_vsnprintf.c)
sdk_add_include_directories(vlibc)
else()
# sdk_add_compile_definitions(-Dprintf=bflb_printf)
sdk_library_add_sources(libc/vsnprintf.c)
sdk_library_add_sources(libc/syscalls.c)
sdk_library_add_sources(libc/printf.c)

View file

@ -3,19 +3,10 @@
struct bflb_device_s *console = NULL;
#ifdef CONFIG_CUSTOM_PRINTF
int puts(const char *s)
{
int len = strlen(s);
int puts(const char *fmt) __attribute__((alias("bflb_printf")));
int printf(const char *fmt, ...) __attribute__((alias("bflb_printf")));
bflb_uart_put(console, (uint8_t *)s, len);
if (s[len - 1] == '\r') {
bflb_uart_putchar(console, '\n');
}
return len;
}
int printf(const char *fmt, ...)
int bflb_printf(const char *fmt, ...)
{
char print_buf[128];
uint32_t len;
@ -31,7 +22,6 @@ int printf(const char *fmt, ...)
return 0;
}
#endif
#define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ')
void bflb_dump_hex(const void *ptr, uint32_t buflen)

View file

@ -10,7 +10,7 @@ extern struct bflb_device_s *console;
/* Reentrant versions of system calls. */
/* global errno in RT-Thread */
/* global errno */
static volatile int _sys_errno = 0;
#ifndef _REENT_ONLY