From 00cebaacace8d3c77655bc7ce751a0aa5abd0784 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 28 Feb 2021 05:07:02 +0800 Subject: add RT_KERVICE_USING_STDLIB --- include/rtthread.h | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'include/rtthread.h') diff --git a/include/rtthread.h b/include/rtthread.h index 1e0094e73b..9d537d6e4d 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -14,6 +14,7 @@ * 2013-06-24 Bernard add rt_kprintf re-define when not use RT_USING_CONSOLE. * 2016-08-09 ArdaFu add new thread and interrupt hook. * 2018-11-22 Jesven add all cpu's lock and ipi handler + * 2021-02-28 Meco Man add RT_KERVICE_USING_STDLIB */ #ifndef __RT_THREAD_H__ @@ -516,7 +517,9 @@ void rt_components_board_init(void); #else void rt_kprintf(const char *fmt, ...); void rt_kputs(const char *str); +rt_int32_t rt_sscanf(const char *buf, const char *fmt, ...); #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, ...); @@ -541,23 +544,35 @@ int __rt_ffs(int value); void *rt_memset(void *src, int c, rt_ubase_t n); void *rt_memcpy(void *dest, const void *src, rt_ubase_t n); +#ifndef RT_KERVICE_USING_STDLIB +void *rt_memmove(void *dest, const void *src, rt_ubase_t n); +rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count); +char *rt_strstr(const char *str1, const char *str2); +rt_int32_t rt_strcasecmp(const char *a, const char *b); +char *rt_strncpy(char *dest, const char *src, rt_ubase_t n); rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count); rt_int32_t rt_strcmp(const char *cs, const char *ct); -rt_size_t rt_strlen(const char *src); rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen); +rt_size_t rt_strlen(const char *src); +#else +#include +#define rt_memmove(dest, src, n) memmove(dest, src, n) +#define rt_memcmp(cs, ct, count) memcmp(cs, ct, count) +#define rt_strstr(str1, str2) strstr(str1, str2) +#define rt_strcasecmp(a, b) strcasecmp(a, b) +#define rt_strncpy(dest, src, n) strncpy(dest, src, n) +#define rt_strncmp(cs, ct, count) strncmp(cs, ct, count) +#define rt_strcmp(cs, ct) strcmp(cs, ct) +#define rt_strnlen(s, maxlen) strnlen(s, maxlen) +#define rt_strlen(src) strlen(src) +#endif /*RT_KERVICE_USING_STDLIB*/ + char *rt_strdup(const char *s); #if defined(__CC_ARM) || defined(__CLANG_ARM) -/* leak strdup interface */ +/* lack strdup interface */ char* strdup(const char* str); #endif -char *rt_strstr(const char *str1, const char *str2); -rt_int32_t rt_sscanf(const char *buf, const char *fmt, ...); -char *rt_strncpy(char *dest, const char *src, rt_ubase_t n); -void *rt_memmove(void *dest, const void *src, rt_ubase_t n); -rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count); -rt_int32_t rt_strcasecmp(const char *a, const char *b); - void rt_show_version(void); #ifdef RT_DEBUG -- cgit v1.3.1 From ced9b44e63e31793f3ba5321f12838e266ebd4fc Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 28 Feb 2021 19:05:14 +0800 Subject: update --- include/rtthread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/rtthread.h') diff --git a/include/rtthread.h b/include/rtthread.h index 9d537d6e4d..7e6c9568b0 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -517,13 +517,13 @@ void rt_components_board_init(void); #else void rt_kprintf(const char *fmt, ...); void rt_kputs(const char *str); -rt_int32_t rt_sscanf(const char *buf, const char *fmt, ...); #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, ...); +rt_int32_t rt_sscanf(const char *buf, const char *fmt, ...); #if defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE) rt_device_t rt_console_set_device(const char *name); -- cgit v1.3.1 From 58f000bdce1879154df911069e644f197ca893c7 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 1 Mar 2021 23:58:04 +0800 Subject: 修改拼写错误 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rtthread.h | 6 +++--- src/Kconfig | 2 +- src/kservice.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'include/rtthread.h') diff --git a/include/rtthread.h b/include/rtthread.h index 7e6c9568b0..8efda713e5 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -14,7 +14,7 @@ * 2013-06-24 Bernard add rt_kprintf re-define when not use RT_USING_CONSOLE. * 2016-08-09 ArdaFu add new thread and interrupt hook. * 2018-11-22 Jesven add all cpu's lock and ipi handler - * 2021-02-28 Meco Man add RT_KERVICE_USING_STDLIB + * 2021-02-28 Meco Man add RT_KSERVICE_USING_STDLIB */ #ifndef __RT_THREAD_H__ @@ -544,7 +544,7 @@ int __rt_ffs(int value); void *rt_memset(void *src, int c, rt_ubase_t n); void *rt_memcpy(void *dest, const void *src, rt_ubase_t n); -#ifndef RT_KERVICE_USING_STDLIB +#ifndef RT_KSERVICE_USING_STDLIB void *rt_memmove(void *dest, const void *src, rt_ubase_t n); rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count); char *rt_strstr(const char *str1, const char *str2); @@ -565,7 +565,7 @@ rt_size_t rt_strlen(const char *src); #define rt_strcmp(cs, ct) strcmp(cs, ct) #define rt_strnlen(s, maxlen) strnlen(s, maxlen) #define rt_strlen(src) strlen(src) -#endif /*RT_KERVICE_USING_STDLIB*/ +#endif /*RT_KSERVICE_USING_STDLIB*/ char *rt_strdup(const char *s); #if defined(__CC_ARM) || defined(__CLANG_ARM) diff --git a/src/Kconfig b/src/Kconfig index 5bc9adda52..7659915f57 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -116,7 +116,7 @@ config RT_TIMER_THREAD_STACK_SIZE endif -config RT_KERVICE_USING_STDLIB +config RT_KSERVICE_USING_STDLIB bool "Enable kservice to use standard C library" default n diff --git a/src/kservice.c b/src/kservice.c index 29097bafac..446fec96a1 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -17,7 +17,7 @@ * 2013-06-24 Bernard remove rt_kprintf if RT_USING_CONSOLE is not defined. * 2013-09-24 aozima make sure the device is in STREAM mode when used by rt_kprintf. * 2015-07-06 Bernard Add rt_assert_handler routine. - * 2021-02-28 Meco Man add RT_KERVICE_USING_STDLIB + * 2021-02-28 Meco Man add RT_KSERVICE_USING_STDLIB */ #include @@ -281,7 +281,7 @@ RT_WEAK void *rt_memcpy(void *dst, const void *src, rt_ubase_t count) } RTM_EXPORT(rt_memcpy); -#ifndef RT_KERVICE_USING_STDLIB +#ifndef RT_KSERVICE_USING_STDLIB /** * This function will move memory content from source address to destination @@ -509,7 +509,7 @@ rt_size_t rt_strlen(const char *s) } RTM_EXPORT(rt_strlen); -#endif /*RT_KERVICE_USING_STDLIB*/ +#endif /*RT_KSERVICE_USING_STDLIB*/ #ifdef RT_USING_HEAP /** -- cgit v1.3.1 From 2fd265406edc642dc083ecc76b286611b4585c64 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 8 Mar 2021 17:22:21 +0800 Subject: [include] auto formatted --- include/libc/libc_dirent.h | 5 ++++- include/libc/libc_errno.h | 4 ++-- include/libc/libc_fcntl.h | 4 ++-- include/libc/libc_fdset.h | 2 +- include/libc/libc_ioctl.h | 2 +- include/libc/libc_limits.h | 6 +++--- include/libc/libc_signal.h | 8 ++++---- include/libc/libc_stat.h | 5 ++++- include/libc/libc_stdio.h | 6 +++--- include/rtdbg.h | 2 +- include/rtdebug.h | 5 ++++- include/rtdef.h | 2 +- include/rthw.h | 4 ++-- include/rtlibc.h | 2 +- include/rtm.h | 5 ++++- include/rtservice.h | 2 +- include/rtthread.h | 2 +- 17 files changed, 39 insertions(+), 27 deletions(-) (limited to 'include/rtthread.h') diff --git a/include/libc/libc_dirent.h b/include/libc/libc_dirent.h index c3a19878ec..a86332e633 100644 --- a/include/libc/libc_dirent.h +++ b/include/libc/libc_dirent.h @@ -1,7 +1,10 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes */ #ifndef LIBC_DIRENT_H__ diff --git a/include/libc/libc_errno.h b/include/libc/libc_errno.h index 9143c841f2..30d6092e33 100644 --- a/include/libc/libc_errno.h +++ b/include/libc/libc_errno.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -161,7 +161,7 @@ defined in armcc/errno.h #define EPROTONOSUPPORT (ERROR_BASE_NO + 93) #define ESOCKTNOSUPPORT (ERROR_BASE_NO + 94) #define EOPNOTSUPP (ERROR_BASE_NO + 95) -#define ENOTSUP EOPNOTSUPP +#define ENOTSUP EOPNOTSUPP #define EPFNOSUPPORT (ERROR_BASE_NO + 96) #define EAFNOSUPPORT (ERROR_BASE_NO + 97) #define EADDRINUSE (ERROR_BASE_NO + 98) diff --git a/include/libc/libc_fcntl.h b/include/libc/libc_fcntl.h index d149d86964..945e674d35 100644 --- a/include/libc/libc_fcntl.h +++ b/include/libc/libc_fcntl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -38,7 +38,7 @@ #ifdef _O_BINARY #define O_BINARY _O_BINARY #else -#define O_BINARY 0 +#define O_BINARY 0 #endif #endif diff --git a/include/libc/libc_fdset.h b/include/libc/libc_fdset.h index 9700c7e83e..c542e6855c 100644 --- a/include/libc/libc_fdset.h +++ b/include/libc/libc_fdset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/include/libc/libc_ioctl.h b/include/libc/libc_ioctl.h index 516c56b1f4..05f0daa238 100644 --- a/include/libc/libc_ioctl.h +++ b/include/libc/libc_ioctl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/include/libc/libc_limits.h b/include/libc/libc_limits.h index b8368160df..36b8dbb202 100644 --- a/include/libc/libc_limits.h +++ b/include/libc/libc_limits.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: - * Date Author Notes - * 2020-09-05 Meco Manthe first version + * Date Author Notes + * 2020-09-05 Meco Man the first version */ #ifndef LIBC_LIMITS_H__ diff --git a/include/libc/libc_signal.h b/include/libc/libc_signal.h index 539685de3e..8a4cc0d738 100644 --- a/include/libc/libc_signal.h +++ b/include/libc/libc_signal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -57,11 +57,11 @@ typedef struct siginfo siginfo_t; #define SI_USER 0x01 /* Signal sent by kill(). */ #define SI_QUEUE 0x02 /* Signal sent by sigqueue(). */ -#define SI_TIMER 0x03 /* Signal generated by expiration of a +#define SI_TIMER 0x03 /* Signal generated by expiration of a timer set by timer_settime(). */ -#define SI_ASYNCIO 0x04 /* Signal generated by completion of an +#define SI_ASYNCIO 0x04 /* Signal generated by completion of an asynchronous I/O request. */ -#define SI_MESGQ 0x05 /* Signal generated by arrival of a +#define SI_MESGQ 0x05 /* Signal generated by arrival of a message on an empty message queue. */ #if !defined(RT_USING_NEWLIB) diff --git a/include/libc/libc_stat.h b/include/libc/libc_stat.h index 6497cfe12c..f680de4e06 100644 --- a/include/libc/libc_stat.h +++ b/include/libc/libc_stat.h @@ -1,7 +1,10 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes */ #ifndef LIBC_STAT_H__ diff --git a/include/libc/libc_stdio.h b/include/libc/libc_stdio.h index 85ba509852..565e1bfd32 100644 --- a/include/libc/libc_stdio.h +++ b/include/libc/libc_stdio.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: - * Date Author Notes - * 2020-09-05 Meco Manthe first version + * Date Author Notes + * 2020-09-05 Meco Man the first version */ #ifndef LIBC_STDIO_H__ diff --git a/include/rtdbg.h b/include/rtdbg.h index be5a57f312..c0a4e68222 100644 --- a/include/rtdbg.h +++ b/include/rtdbg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/include/rtdebug.h b/include/rtdebug.h index b66cd6fc69..8c7d450ad4 100644 --- a/include/rtdebug.h +++ b/include/rtdebug.h @@ -1,7 +1,10 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes */ #ifndef __RTDEBUG_H__ diff --git a/include/rtdef.h b/include/rtdef.h index 44328b5447..a0d964bcb5 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/include/rthw.h b/include/rthw.h index 89877faf90..5672a8f992 100644 --- a/include/rthw.h +++ b/include/rthw.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -181,7 +181,7 @@ void rt_hw_secondary_cpu_up(void); void rt_hw_secondary_cpu_idle_exec(void); #else -#define RT_DEFINE_SPINLOCK(x) +#define RT_DEFINE_SPINLOCK(x) #define RT_DECLARE_SPINLOCK(x) rt_ubase_t x #define rt_hw_spin_lock(lock) *(lock) = rt_hw_interrupt_disable() diff --git a/include/rtlibc.h b/include/rtlibc.h index fb8c782095..5a260d250d 100644 --- a/include/rtlibc.h +++ b/include/rtlibc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/include/rtm.h b/include/rtm.h index 9da3a6b8b2..ec05662416 100644 --- a/include/rtm.h +++ b/include/rtm.h @@ -1,7 +1,10 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes */ #ifndef __RTM_H__ diff --git a/include/rtservice.h b/include/rtservice.h index 5bd2b1c23b..d0bad85de1 100644 --- a/include/rtservice.h +++ b/include/rtservice.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/include/rtthread.h b/include/rtthread.h index 1e0094e73b..9bcf05820c 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * -- cgit v1.3.1 From 846102efa1ba3af5d8431db09adabe38af0e28a7 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Fri, 19 Mar 2021 03:01:07 +0800 Subject: [kernel][device] remove rt_device_init_all() --- bsp/frdm-k64f/applications/startup.c | 3 --- bsp/mb9bf500r/startup.c | 5 ----- include/rtthread.h | 2 -- src/device.c | 14 +------------- 4 files changed, 1 insertion(+), 23 deletions(-) (limited to 'include/rtthread.h') diff --git a/bsp/frdm-k64f/applications/startup.c b/bsp/frdm-k64f/applications/startup.c index d16aefddb2..e558cd8cbf 100644 --- a/bsp/frdm-k64f/applications/startup.c +++ b/bsp/frdm-k64f/applications/startup.c @@ -73,9 +73,6 @@ void rtthread_startup(void) /* init scheduler system */ rt_system_scheduler_init(); - /* init all device */ - rt_device_init_all(); - /* init application */ rt_application_init(); diff --git a/bsp/mb9bf500r/startup.c b/bsp/mb9bf500r/startup.c index bc96eb5dca..a8718750fc 100644 --- a/bsp/mb9bf500r/startup.c +++ b/bsp/mb9bf500r/startup.c @@ -61,11 +61,6 @@ void rtthread_startup(void) /* init scheduler system */ rt_system_scheduler_init(); -#ifdef RT_USING_DEVICE - /* init all device */ - rt_device_init_all(); -#endif - /* init application */ rt_application_init(); diff --git a/include/rtthread.h b/include/rtthread.h index 9bcf05820c..e80257a6e5 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -437,8 +437,6 @@ rt_err_t rt_device_unregister(rt_device_t dev); rt_device_t rt_device_create(int type, int attach_size); void rt_device_destroy(rt_device_t device); -rt_err_t rt_device_init_all(void); - rt_err_t rt_device_set_rx_indicate(rt_device_t dev, rt_err_t (*rx_ind)(rt_device_t dev, rt_size_t size)); diff --git a/src/device.c b/src/device.c index 388c2ecf12..50b83c7692 100644 --- a/src/device.c +++ b/src/device.c @@ -12,6 +12,7 @@ * 2012-12-25 Bernard return RT_EOK if the device interface not exist. * 2013-07-09 Grissiom add ref_count support * 2016-04-02 Bernard fix the open_flag initialization issue. + * 2021-03-19 Meco Man remove rt_device_init_all() */ #include @@ -89,19 +90,6 @@ rt_err_t rt_device_unregister(rt_device_t dev) } RTM_EXPORT(rt_device_unregister); -/** - * This function initializes all registered device driver - * - * @return the error code, RT_EOK on successfully. - * - * @deprecated since 1.2.x, this function is not needed because the initialization - * of a device is performed when application opens it. - */ -rt_err_t rt_device_init_all(void) -{ - return RT_EOK; -} - /** * This function finds a device driver by specified name. * -- cgit v1.3.1