Make libc-builtin buffered printf be a common feature (#1483)

Add macros to control whether to use the libc-builtin buffered printf
and the buffer size.
This commit is contained in:
Huang Qi 2022-09-15 15:09:01 +08:00 committed by GitHub
parent ab929c20a3
commit bbea005db6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 3 deletions

View File

@ -345,9 +345,24 @@ sprintf_out(int c, struct str_context *ctx)
return c;
}
#ifdef BH_PLATFORM_OPENRTOS
PRIVILEGED_DATA static char print_buf[128] = { 0 };
PRIVILEGED_DATA static int print_buf_size = 0;
#ifndef BUILTIN_LIBC_BUFFERED_PRINTF
#define BUILTIN_LIBC_BUFFERED_PRINTF 0
#endif
#ifndef BUILTIN_LIBC_BUFFERED_PRINT_SIZE
#define BUILTIN_LIBC_BUFFERED_PRINT_SIZE 128
#endif
#ifndef BUILTIN_LIBC_BUFFERED_PRINT_PREFIX
#define BUILTIN_LIBC_BUFFERED_PRINT_PREFIX
#endif
#if BUILTIN_LIBC_BUFFERED_PRINTF != 0
BUILTIN_LIBC_BUFFERED_PRINT_PREFIX
static char print_buf[BUILTIN_LIBC_BUFFERED_PRINT_SIZE] = { 0 };
BUILTIN_LIBC_BUFFERED_PRINT_PREFIX
static int print_buf_size = 0;
static int
printf_out(int c, struct str_context *ctx)

View File

@ -77,6 +77,10 @@ typedef sem_t korp_sem;
#define CONFIG_HAS_ISATTY 0
#endif
#define BUILTIN_LIBC_BUFFERED_PRINTF 1
#define BUILTIN_LIBC_BUFFERED_PRINT_SIZE 128
#define BUILTIN_LIBC_BUFFERED_PRINT_PREFIX
/*
* NuttX doesn't have openat family.
*/