From da0bb7f6295450e30fc5608a0ecc89cc8bf572b8 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 7 Nov 2021 13:24:07 -0500 Subject: [PATCH 1/6] [kservice] add RT_WEAK for rt_vsnprintf --- src/Kconfig | 4 ++++ src/kservice.c | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Kconfig b/src/Kconfig index e31afc25fa..f6db1c0cea 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -139,6 +139,10 @@ config RT_USING_ASM_MEMCPY bool default n +config RT_USING_ASM_MEMSET + bool + default n + endmenu menuconfig RT_DEBUG diff --git a/src/kservice.c b/src/kservice.c index 4ed30f3237..79bb115c19 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -115,6 +115,7 @@ int *_rt_errno(void) } RTM_EXPORT(_rt_errno); +#ifndef RT_USING_ASM_MEMSET /** * This function will set the content of memory to specified value. * @@ -127,7 +128,7 @@ RTM_EXPORT(_rt_errno); * * @return The address of source memory. */ -RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count) +void *rt_memset(void *s, int c, rt_ubase_t count) { #ifdef RT_KSERVICE_USING_TINY_SIZE char *xs = (char *)s; @@ -200,6 +201,7 @@ RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count) #endif /* RT_KSERVICE_USING_TINY_SIZE */ } RTM_EXPORT(rt_memset); +#endif /* RT_USING_ASM_MEMSET */ #ifndef RT_USING_ASM_MEMCPY /** @@ -338,7 +340,7 @@ RTM_EXPORT(rt_memmove); * If the result > 0, cs is greater than ct. * If the result = 0, cs is equal to ct. */ -RT_WEAK rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count) +rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count) { const unsigned char *su1, *su2; int res = 0; @@ -842,7 +844,7 @@ static char *print_number(char *buf, * * @return The number of characters actually written to buffer. */ -rt_int32_t rt_vsnprintf(char *buf, +RT_WEAK rt_int32_t rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args) From 5e19b71eca9a9333c3de5434b832cde85b1d0f1a Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 16 Nov 2021 03:41:26 -0500 Subject: [PATCH 2/6] =?UTF-8?q?=E5=B0=86=E8=BF=94=E5=9B=9E=E5=80=BC?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=94=B1signed=20int=E6=94=B9=E4=B8=BAint?= =?UTF-8?q?=EF=BC=8C=E7=AC=A6=E5=90=88ISO=20C=E6=A0=87=E5=87=86=EF=BC=8C?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E7=BC=96=E8=AF=91=E5=99=A8=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rtthread.h | 10 +++++----- src/kservice.c | 12 +++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/rtthread.h b/include/rtthread.h index 83be7d1ebc..8089ca07de 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -537,14 +537,14 @@ void rt_components_board_init(void); #define rt_kprintf(...) #define rt_kputs(str) #else -void rt_kprintf(const char *fmt, ...); +int rt_kprintf(const char *fmt, ...); void rt_kputs(const char *str); #endif -rt_int32_t rt_vsprintf(char *dest, const char *format, va_list arg_ptr); -rt_int32_t rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args); -rt_int32_t rt_sprintf(char *buf, const char *format, ...); -rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *format, ...); +int rt_vsprintf(char *dest, const char *format, va_list arg_ptr); +int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args); +int rt_sprintf(char *buf, const char *format, ...); +int rt_snprintf(char *buf, rt_size_t size, const char *format, ...); #if defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE) rt_device_t rt_console_set_device(const char *name); diff --git a/src/kservice.c b/src/kservice.c index 525aacd7fd..6493c58b6a 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -844,7 +844,7 @@ static char *print_number(char *buf, * * @return The number of characters actually written to buffer. */ -RT_WEAK rt_int32_t rt_vsnprintf(char *buf, +RT_WEAK int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args) @@ -1121,7 +1121,7 @@ RTM_EXPORT(rt_vsnprintf); * * @return The number of characters actually written to buffer. */ -rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...) +int rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...) { rt_int32_t n; va_list args; @@ -1145,7 +1145,7 @@ RTM_EXPORT(rt_snprintf); * * @return The number of characters actually written to buffer. */ -rt_int32_t rt_vsprintf(char *buf, const char *format, va_list arg_ptr) +int rt_vsprintf(char *buf, const char *format, va_list arg_ptr) { return rt_vsnprintf(buf, (rt_size_t) - 1, format, arg_ptr); } @@ -1160,7 +1160,7 @@ RTM_EXPORT(rt_vsprintf); * * @return The number of characters actually written to buffer. */ -rt_int32_t rt_sprintf(char *buf, const char *format, ...) +int rt_sprintf(char *buf, const char *format, ...) { rt_int32_t n; va_list arg_ptr; @@ -1261,7 +1261,7 @@ void rt_kputs(const char *str) * * @param fmt is the format parameters. */ -RT_WEAK void rt_kprintf(const char *fmt, ...) +RT_WEAK int rt_kprintf(const char *fmt, ...) { va_list args; rt_size_t length; @@ -1289,6 +1289,8 @@ RT_WEAK void rt_kprintf(const char *fmt, ...) rt_hw_console_output(rt_log_buf); #endif /* RT_USING_DEVICE */ va_end(args); + + return length; /* the total number of printed characters */ } RTM_EXPORT(rt_kprintf); #endif /* RT_USING_CONSOLE */ From e82fe76a0fccd87f9dd801ee5a5f3a359b357aaf Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 16 Nov 2021 12:06:55 -0500 Subject: [PATCH 3/6] fix rt_size_t as rt_uint32_t --- include/rtdef.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/rtdef.h b/include/rtdef.h index a324eea122..eb9381e71f 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -78,8 +78,8 @@ typedef unsigned long rt_uint64_t; /**< 64bit unsigned inte #else typedef signed long long rt_int64_t; /**< 64bit integer type */ typedef unsigned long long rt_uint64_t; /**< 64bit unsigned integer type */ -#endif -#endif +#endif /* ARCH_CPU_64BIT */ +#endif /* RT_USING_ARCH_DATA_TYPE */ typedef int rt_bool_t; /**< boolean type */ typedef long rt_base_t; /**< Nbit CPU related date type */ @@ -89,7 +89,7 @@ typedef rt_base_t rt_err_t; /**< Type for error numb typedef rt_uint32_t rt_time_t; /**< Type for time stamp */ typedef rt_uint32_t rt_tick_t; /**< Type for tick count */ typedef rt_base_t rt_flag_t; /**< Type for flags */ -typedef rt_ubase_t rt_size_t; /**< Type for size number */ +typedef rt_uint32_t rt_size_t; /**< Type for size number */ typedef rt_ubase_t rt_dev_t; /**< Type for device */ typedef rt_base_t rt_off_t; /**< Type for offset */ From 040f05f40d16bd2d25de44d16029e21300f44253 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 16 Nov 2021 12:12:47 -0500 Subject: [PATCH 4/6] =?UTF-8?q?[sfud][cfg]=20=E5=8F=96=E6=B6=88rt=5Fkprint?= =?UTF-8?q?f=E5=A3=B0=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/spi/sfud/inc/sfud_cfg.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/drivers/spi/sfud/inc/sfud_cfg.h b/components/drivers/spi/sfud/inc/sfud_cfg.h index 01255775c8..59859149aa 100644 --- a/components/drivers/spi/sfud/inc/sfud_cfg.h +++ b/components/drivers/spi/sfud/inc/sfud_cfg.h @@ -29,7 +29,7 @@ #ifndef _SFUD_CFG_H_ #define _SFUD_CFG_H_ -#include +#include /** * It will print more information on debug mode. @@ -47,7 +47,6 @@ #define DBG_TAG "SFUD" #include -extern void rt_kprintf(const char *fmt, ...); #define SFUD_INFO(...) LOG_I(__VA_ARGS__) /** From 857428bd233730f1e717d0c0b5b6b8d5eb2d35f4 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 16 Nov 2021 16:37:34 -0500 Subject: [PATCH 5/6] [kservice] add return value's comment --- src/kservice.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/kservice.c b/src/kservice.c index 6493c58b6a..aa5b39075c 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -844,10 +844,7 @@ static char *print_number(char *buf, * * @return The number of characters actually written to buffer. */ -RT_WEAK int rt_vsnprintf(char *buf, - rt_size_t size, - const char *fmt, - va_list args) +RT_WEAK int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args) { #ifdef RT_PRINTF_LONGLONG unsigned long long num; @@ -1260,6 +1257,8 @@ void rt_kputs(const char *str) * This function will print a formatted string on system console. * * @param fmt is the format parameters. + * + * @return The number of characters actually written to buffer. */ RT_WEAK int rt_kprintf(const char *fmt, ...) { @@ -1290,7 +1289,7 @@ RT_WEAK int rt_kprintf(const char *fmt, ...) #endif /* RT_USING_DEVICE */ va_end(args); - return length; /* the total number of printed characters */ + return length; } RTM_EXPORT(rt_kprintf); #endif /* RT_USING_CONSOLE */ From cefc77ad11039eb0f93162fde3b8584c880dcf12 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 22 Nov 2021 15:02:47 -0500 Subject: [PATCH 6/6] modify rt_size_t's type --- include/rtdef.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/rtdef.h b/include/rtdef.h index eb9381e71f..240161ac8c 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -75,9 +75,11 @@ typedef unsigned int rt_uint32_t; /**< 32bit unsigned inte #ifdef ARCH_CPU_64BIT typedef signed long rt_int64_t; /**< 64bit integer type */ typedef unsigned long rt_uint64_t; /**< 64bit unsigned integer type */ +typedef unsigned long rt_size_t; /**< Type for size number */ #else typedef signed long long rt_int64_t; /**< 64bit integer type */ typedef unsigned long long rt_uint64_t; /**< 64bit unsigned integer type */ +typedef unsigned int rt_size_t; /**< Type for size number */ #endif /* ARCH_CPU_64BIT */ #endif /* RT_USING_ARCH_DATA_TYPE */ @@ -89,7 +91,6 @@ typedef rt_base_t rt_err_t; /**< Type for error numb typedef rt_uint32_t rt_time_t; /**< Type for time stamp */ typedef rt_uint32_t rt_tick_t; /**< Type for tick count */ typedef rt_base_t rt_flag_t; /**< Type for flags */ -typedef rt_uint32_t rt_size_t; /**< Type for size number */ typedef rt_ubase_t rt_dev_t; /**< Type for device */ typedef rt_base_t rt_off_t; /**< Type for offset */