From fe467ab5dc7e8b4ceb095d286b60b3ea24562a87 Mon Sep 17 00:00:00 2001 From: wdfk-prog <1425075683@qq.com> Date: Sun, 8 Dec 2024 13:04:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20[klib]=E6=B7=BB=E5=8A=A0=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E6=9B=BF=E4=BB=A3=E7=9A=84=20sprintf=E3=80=81snprintf?= =?UTF-8?q?=E3=80=81printf=E3=80=81vsprintf=20=E5=92=8C=20vsnprintf=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/klibc/Kconfig | 22 +++++++++++++++++++++- src/klibc/SConscript | 10 +++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/klibc/Kconfig b/src/klibc/Kconfig index 0b00d10b8e8..eb3631b6953 100644 --- a/src/klibc/Kconfig +++ b/src/klibc/Kconfig @@ -98,7 +98,27 @@ menu "klibc options" The number of terms in a Taylor series expansion of log_10(x) to use for approximation - including the power-zero term (i.e. the value at the point of expansion). - + if RT_VER_NUM >= 0x40100 + config RT_KLIBC_USING_FULL_REPLACING_SPRINTF + bool "Enable to take over 'sprintf'" + default n + + config RT_KLIBC_USING_FULL_REPLACING_SNPRINTF + bool "Enable to take over 'snprintf'" + default n + + config RT_KLIBC_USING_FULL_REPLACING_PRINTF + bool "Enable to take over 'printf'" + default n + + config RT_KLIBC_USING_FULL_REPLACING_VSPRINTF + bool "Enable to take over 'vsprintf'" + default n + + config RT_KLIBC_USING_FULL_REPLACING_VSNPRINTF + bool "Enable to take over 'vsnprintf'" + default n + endif endif endmenu # rt_vsnprintf options diff --git a/src/klibc/SConscript b/src/klibc/SConscript index eb629ef7250..ba6ca9d450b 100644 --- a/src/klibc/SConscript +++ b/src/klibc/SConscript @@ -3,6 +3,7 @@ import os cwd = GetCurrentDir() src = ['kerrno.c', 'kstdio.c', 'kstring.c'] +CPPDEFINES = [] if not GetDepend(['RT_KLIBC_USING_LIBC_VSNPRINTF']): if GetDepend(['RT_KLIBC_USING_VSNPRINTF_STANDARD']): @@ -13,7 +14,14 @@ if not GetDepend(['RT_KLIBC_USING_LIBC_VSNPRINTF']): if not GetDepend(['RT_KLIBC_USING_LIBC_VSSCANF']): src += ['rt_vsscanf.c'] -group = DefineGroup('klibc', src, depend = ['']) +if GetDepend('RT_KLIBC_USING_FULL_REPLACING_SPRINTF'): + CPPDEFINES += ['sprintf=rt_sprintf'] +if GetDepend('RT_KLIBC_USING_FULL_REPLACING_SNPRINTF'): + CPPDEFINES += ['snprintf=rt_snprintf'] +if GetDepend('RT_KLIBC_USING_FULL_REPLACING_PRINTF'): + CPPDEFINES += ['printf=rt_kprintf'] + +group = DefineGroup('klibc', src, depend = [''], CPPDEFINES = CPPDEFINES) list = os.listdir(cwd) for item in list: