Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [klib]添加完整替代的 sprintf、snprintf、printf、vsprintf 和 vsnprintf 配置选项 #9752

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/klibc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 9 additions & 1 deletion src/klibc/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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']):
Expand All @@ -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']

Comment on lines +17 to +23
Copy link
Member

@mysterywolf mysterywolf Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个功能先不这么加了

group = DefineGroup('klibc', src, depend = [''], CPPDEFINES = CPPDEFINES)

list = os.listdir(cwd)
for item in list:
Expand Down
Loading