From b1eb3943a3ab1e4b39574d01eb98480afabb29d1 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Fri, 10 Apr 2020 00:01:58 +0800 Subject: [Kernel] Add rt_object_get_length/rt_object_get_pointers APIs. --- include/rtthread.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/rtthread.h b/include/rtthread.h index 70d4f38896..a76601a3bf 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -41,6 +41,9 @@ extern "C" { void rt_system_object_init(void); struct rt_object_information * rt_object_get_information(enum rt_object_class_type type); +int rt_object_get_length(enum rt_object_class_type type); +int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers, int maxlen); + void rt_object_init(struct rt_object *object, enum rt_object_class_type type, const char *name); -- cgit v1.3.1 From 310517b818ac4f0eb0655cf20bf4ba4543a911aa Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Fri, 10 Apr 2020 00:02:57 +0800 Subject: [Kernel] Code cleanup --- include/rtservice.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/rtservice.h b/include/rtservice.h index 81d6c71f17..5bd2b1c23b 100644 --- a/include/rtservice.h +++ b/include/rtservice.h @@ -128,21 +128,21 @@ rt_inline unsigned int rt_list_len(const rt_list_t *l) /** * rt_list_for_each - iterate over a list - * @pos: the rt_list_t * to use as a loop cursor. - * @head: the head for your list. + * @pos: the rt_list_t * to use as a loop cursor. + * @head: the head for your list. */ #define rt_list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) /** * rt_list_for_each_safe - iterate over a list safe against removal of list entry - * @pos: the rt_list_t * to use as a loop cursor. - * @n: another rt_list_t * to use as temporary storage - * @head: the head for your list. + * @pos: the rt_list_t * to use as a loop cursor. + * @n: another rt_list_t * to use as temporary storage + * @head: the head for your list. */ #define rt_list_for_each_safe(pos, n, head) \ - for (pos = (head)->next, n = pos->next; pos != (head); \ - pos = n, n = pos->next) + for (pos = (head)->next, n = pos->next; pos != (head); \ + pos = n, n = pos->next) /** * rt_list_for_each_entry - iterate over list of given type -- cgit v1.3.1 From fe2e9e924e8c08865254f26dd1c763ced4784b1d Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Sat, 6 Jun 2020 13:21:32 +0800 Subject: [libc] fix 64bit issue for pthreads --- components/libc/pthreads/pthread.c | 2 +- include/rtdef.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100755 => 100644 components/libc/pthreads/pthread.c (limited to 'include') diff --git a/components/libc/pthreads/pthread.c b/components/libc/pthreads/pthread.c old mode 100755 new mode 100644 index 5d3bc0796a..19a511b45b --- a/components/libc/pthreads/pthread.c +++ b/components/libc/pthreads/pthread.c @@ -277,7 +277,7 @@ int pthread_create(pthread_t *pid, /* set pthread cleanup function and ptd data */ ptd->tid->cleanup = _pthread_cleanup; - ptd->tid->user_data = (rt_uint32_t)ptd; + ptd->tid->user_data = (rt_ubase_t)ptd; /* start thread */ if (rt_thread_startup(ptd->tid) == RT_EOK) diff --git a/include/rtdef.h b/include/rtdef.h index f2b546f75e..b391ff7685 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -623,7 +623,7 @@ struct rt_thread void *lwp; #endif - rt_uint32_t user_data; /**< private user data beyond this thread */ + rt_ubase_t user_data; /**< private user data beyond this thread */ }; typedef struct rt_thread *rt_thread_t; -- cgit v1.3.1 From 224c3224c7d1bea2f52bb51aca505812a12b9255 Mon Sep 17 00:00:00 2001 From: chenchaoqun Date: Mon, 27 Jul 2020 14:11:35 +0800 Subject: [format] enumeration define two styles: define first or all. --- include/rtdef.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/rtdef.h b/include/rtdef.h index b391ff7685..747643bb82 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -372,20 +372,20 @@ typedef struct rt_object *rt_object_t; /**< Type for kernel obj */ enum rt_object_class_type { - RT_Object_Class_Null = 0, /**< The object is not used. */ - RT_Object_Class_Thread, /**< The object is a thread. */ - RT_Object_Class_Semaphore, /**< The object is a semaphore. */ - RT_Object_Class_Mutex, /**< The object is a mutex. */ - RT_Object_Class_Event, /**< The object is a event. */ - RT_Object_Class_MailBox, /**< The object is a mail box. */ - RT_Object_Class_MessageQueue, /**< The object is a message queue. */ - RT_Object_Class_MemHeap, /**< The object is a memory heap */ - RT_Object_Class_MemPool, /**< The object is a memory pool. */ - RT_Object_Class_Device, /**< The object is a device */ - RT_Object_Class_Timer, /**< The object is a timer. */ - RT_Object_Class_Module, /**< The object is a module. */ - RT_Object_Class_Unknown, /**< The object is unknown. */ - RT_Object_Class_Static = 0x80 /**< The object is a static object. */ + RT_Object_Class_Null = 0x00, /**< The object is not used. */ + RT_Object_Class_Thread = 0x01, /**< The object is a thread. */ + RT_Object_Class_Semaphore = 0x02, /**< The object is a semaphore. */ + RT_Object_Class_Mutex = 0x03, /**< The object is a mutex. */ + RT_Object_Class_Event = 0x04, /**< The object is a event. */ + RT_Object_Class_MailBox = 0x05, /**< The object is a mail box. */ + RT_Object_Class_MessageQueue = 0x06, /**< The object is a message queue. */ + RT_Object_Class_MemHeap = 0x07, /**< The object is a memory heap. */ + RT_Object_Class_MemPool = 0x08, /**< The object is a memory pool. */ + RT_Object_Class_Device = 0x09, /**< The object is a device. */ + RT_Object_Class_Timer = 0x0a, /**< The object is a timer. */ + RT_Object_Class_Module = 0x0b, /**< The object is a module. */ + RT_Object_Class_Unknown = 0x0c, /**< The object is unknown. */ + RT_Object_Class_Static = 0x80 /**< The object is a static object. */ }; /** -- cgit v1.3.1 From 5e92521e0d0e6f73cafe5fe8b5c2e7e0d852863e Mon Sep 17 00:00:00 2001 From: Meco <920369182@qq.com> Date: Mon, 10 Aug 2020 04:35:08 +0800 Subject: struct rt_device_ops 结构体增加宏定义 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rtdef.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/rtdef.h b/include/rtdef.h index 747643bb82..5543b80ab7 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -32,6 +32,7 @@ * 2019-01-27 Bernard change version number to v4.0.1 * 2019-05-17 Bernard change version number to v4.0.2 * 2019-12-20 Bernard change version number to v4.0.3 + * 2020-08-10 Meco Man add macro for struct rt_device_ops */ #ifndef __RT_DEF_H__ @@ -920,6 +921,8 @@ enum rt_device_class_type #define RT_DEVICE_CTRL_RTC_SET_ALARM 0x13 /**< set alarm */ typedef struct rt_device *rt_device_t; + +#ifdef RT_USING_DEVICE_OPS /** * operations set for device object */ @@ -933,6 +936,7 @@ struct rt_device_ops rt_size_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size); rt_err_t (*control)(rt_device_t dev, int cmd, void *args); }; +#endif /** * WaitQueue structure -- cgit v1.3.1 From 74ab1551fd030e4950ae4f773cb19240c7a7a6d3 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Sat, 5 Sep 2020 16:14:21 +0800 Subject: add posix 2008 limit.h --- components/libc/getline/README.md | 2 +- components/libc/getline/posix_getline.c | 2 +- include/libc/libc_limits.h | 24 ++++++++++++++++++++++++ include/rtlibc.h | 1 + 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 include/libc/libc_limits.h (limited to 'include') diff --git a/components/libc/getline/README.md b/components/libc/getline/README.md index 8f52898c82..3ba5a96b3d 100644 --- a/components/libc/getline/README.md +++ b/components/libc/getline/README.md @@ -1,4 +1,4 @@ -# getline/getdelim for RT-Thread POSIX +# getline/getdelim for RT-Thread POSIX(IEEE Std 1003.1-2008) [![Build Status](https://travis-ci.org/ivanrad/getline.svg?branch=master)](https://travis-ci.org/ivanrad/getline) diff --git a/components/libc/getline/posix_getline.c b/components/libc/getline/posix_getline.c index d4a7d3fce6..9853d09439 100644 --- a/components/libc/getline/posix_getline.c +++ b/components/libc/getline/posix_getline.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream) { char *cur_pos, *new_lineptr; diff --git a/include/libc/libc_limits.h b/include/libc/libc_limits.h new file mode 100644 index 0000000000..c2129e5343 --- /dev/null +++ b/include/libc/libc_limits.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * File : libc_limits.h + * + * Change Logs: + * Date Author Notes + * 2020-09-05 Meco Manthe first version + */ + +#ifndef __LIBC_LIMITS_H__ +#define __LIBC_LIMITS_H__ + +#include + +#ifndef SSIZE_MAX +# define SSIZE_MAX LONG_MAX +#endif + +#endif diff --git a/include/rtlibc.h b/include/rtlibc.h index b3a548beb1..73d735250f 100644 --- a/include/rtlibc.h +++ b/include/rtlibc.h @@ -20,6 +20,7 @@ #include "libc/libc_dirent.h" #include "libc/libc_signal.h" #include "libc/libc_fdset.h" +#include "libc/libc_limits.h" #if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__) typedef signed long off_t; -- cgit v1.3.1 From 6fa049ee3dedb7fe1ca321ef5f367fdb4a498181 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Sat, 5 Sep 2020 16:21:00 +0800 Subject: add libc_stdio.h --- include/libc/libc_limits.h | 4 ++-- include/libc/libc_stdio.h | 20 ++++++++++++++++++++ include/rtlibc.h | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 include/libc/libc_stdio.h (limited to 'include') diff --git a/include/libc/libc_limits.h b/include/libc/libc_limits.h index c2129e5343..c2aa429229 100644 --- a/include/libc/libc_limits.h +++ b/include/libc/libc_limits.h @@ -12,8 +12,8 @@ * 2020-09-05 Meco Manthe first version */ -#ifndef __LIBC_LIMITS_H__ -#define __LIBC_LIMITS_H__ +#ifndef LIBC_LIMITS_H__ +#define LIBC_LIMITS_H__ #include diff --git a/include/libc/libc_stdio.h b/include/libc/libc_stdio.h new file mode 100644 index 0000000000..19d5fd4cc5 --- /dev/null +++ b/include/libc/libc_stdio.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * File : libc_stdio.h + * + * Change Logs: + * Date Author Notes + * 2020-09-05 Meco Manthe first version + */ + +#ifndef LIBC_STDIO_H__ +#define LIBC_STDIO_H__ + +#include + +#endif diff --git a/include/rtlibc.h b/include/rtlibc.h index 73d735250f..fb8c782095 100644 --- a/include/rtlibc.h +++ b/include/rtlibc.h @@ -21,6 +21,7 @@ #include "libc/libc_signal.h" #include "libc/libc_fdset.h" #include "libc/libc_limits.h" +#include "libc/libc_stdio.h" #if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__) typedef signed long off_t; -- cgit v1.3.1 From d5d8b345f4d9caacfd4dabce0d8ce374f7e7b81e Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Sat, 5 Sep 2020 16:59:53 +0800 Subject: 修改libc_signal.h 该文件中不能用rt_数据类型,否则会引起编译器递归编译 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/getline/posix_getline.h | 1 + include/libc/libc_signal.h | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/components/libc/getline/posix_getline.h b/components/libc/getline/posix_getline.h index 1b3e43da1e..3de84cdfe6 100644 --- a/components/libc/getline/posix_getline.h +++ b/components/libc/getline/posix_getline.h @@ -14,6 +14,7 @@ #define POSIX_GETLINE_H #include +#include ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream); ssize_t getline(char **lineptr, size_t *n, FILE *stream); diff --git a/include/libc/libc_signal.h b/include/libc/libc_signal.h index 898fe13f43..539685de3e 100644 --- a/include/libc/libc_signal.h +++ b/include/libc/libc_signal.h @@ -15,6 +15,7 @@ extern "C" { #endif +#include #ifdef HAVE_CCONFIG_H #include #endif @@ -46,8 +47,8 @@ struct sigevent #ifndef HAVE_SIGINFO struct siginfo { - rt_uint16_t si_signo; - rt_uint16_t si_code; + uint16_t si_signo; + uint16_t si_code; union sigval si_value; }; -- cgit v1.3.1 From cf00e7f0a1c5d76fd990f37e72f165391ff2d595 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Sat, 5 Sep 2020 18:10:30 +0800 Subject: 增加 RT_USING_POSIX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/libc/libc_limits.h | 4 ++++ include/libc/libc_stdio.h | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'include') diff --git a/include/libc/libc_limits.h b/include/libc/libc_limits.h index c2aa429229..32f7df1b1a 100644 --- a/include/libc/libc_limits.h +++ b/include/libc/libc_limits.h @@ -17,8 +17,12 @@ #include +#ifdef RT_USING_POSIX + #ifndef SSIZE_MAX # define SSIZE_MAX LONG_MAX #endif #endif + +#endif diff --git a/include/libc/libc_stdio.h b/include/libc/libc_stdio.h index 19d5fd4cc5..6201b85ea4 100644 --- a/include/libc/libc_stdio.h +++ b/include/libc/libc_stdio.h @@ -15,6 +15,10 @@ #ifndef LIBC_STDIO_H__ #define LIBC_STDIO_H__ +#ifdef RT_USING_POSIX + #include #endif + +#endif -- cgit v1.3.1 From 443978eb784e68c33b469e04f4105e87fdf2fa55 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Sat, 5 Sep 2020 19:47:34 +0800 Subject: 增加RT_USING_POSIX_GETLINE用于单独控制是否启用getline函数,并修改Kconfig增加对应选项 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/Kconfig | 8 ++++++-- components/libc/getline/SConscript | 2 +- include/libc/libc_stdio.h | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/components/libc/Kconfig b/components/libc/Kconfig index 26e156522b..65c8d44225 100644 --- a/components/libc/Kconfig +++ b/components/libc/Kconfig @@ -22,11 +22,15 @@ if RT_USING_LIBC && RT_USING_DFS if RT_USING_POSIX config RT_USING_POSIX_MMAP - bool "Enable mmap() api" + bool "Enable mmap() API" default n config RT_USING_POSIX_TERMIOS - bool "Enable termios feature" + bool "Enable termios APIs" + default n + + config RT_USING_POSIX_GETLINE + bool "Enable getline()/getdelim() APIs" default n config RT_USING_POSIX_AIO diff --git a/components/libc/getline/SConscript b/components/libc/getline/SConscript index 7bede9f31b..fa4c8618c1 100644 --- a/components/libc/getline/SConscript +++ b/components/libc/getline/SConscript @@ -7,7 +7,7 @@ src = Glob('*.c') + Glob('*.cpp') CPPPATH = [cwd] group = DefineGroup('libc', src, - depend = ['RT_USING_LIBC', 'RT_USING_POSIX'], + depend = ['RT_USING_LIBC', 'RT_USING_POSIX','RT_USING_POSIX_GETLINE'], CPPPATH = CPPPATH) Return('group') diff --git a/include/libc/libc_stdio.h b/include/libc/libc_stdio.h index 6201b85ea4..4a09f5c3d7 100644 --- a/include/libc/libc_stdio.h +++ b/include/libc/libc_stdio.h @@ -15,7 +15,7 @@ #ifndef LIBC_STDIO_H__ #define LIBC_STDIO_H__ -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_GETLINE #include -- cgit v1.3.1 From 0d7d1fbbf78d5b6f75b28781d3c8c326da6b713b Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Sat, 5 Sep 2020 22:05:16 +0800 Subject: 修改include/libc头文件版权信息格式 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/libc/libc_fcntl.h | 4 ---- include/libc/libc_fdset.h | 4 ---- include/libc/libc_ioctl.h | 4 ---- include/libc/libc_limits.h | 4 ---- include/libc/libc_stdio.h | 4 ---- 5 files changed, 20 deletions(-) (limited to 'include') diff --git a/include/libc/libc_fcntl.h b/include/libc/libc_fcntl.h index 1b7c69b1f4..385ac7cd9f 100644 --- a/include/libc/libc_fcntl.h +++ b/include/libc/libc_fcntl.h @@ -2,10 +2,6 @@ * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - */ - -/* - * File : libc_fcntl.h * * Change Logs: * Date Author Notes diff --git a/include/libc/libc_fdset.h b/include/libc/libc_fdset.h index ecd965cd22..b4d2e2189a 100644 --- a/include/libc/libc_fdset.h +++ b/include/libc/libc_fdset.h @@ -2,10 +2,6 @@ * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - */ - -/* - * File : libc_errno.h * * Change Logs: * Date Author Notes diff --git a/include/libc/libc_ioctl.h b/include/libc/libc_ioctl.h index ef5a5257a8..42a21a2cea 100644 --- a/include/libc/libc_ioctl.h +++ b/include/libc/libc_ioctl.h @@ -2,10 +2,6 @@ * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - */ - -/* - * File : libc_ioctl.h * * Change Logs: * Date Author Notes diff --git a/include/libc/libc_limits.h b/include/libc/libc_limits.h index 32f7df1b1a..2b49db97d9 100644 --- a/include/libc/libc_limits.h +++ b/include/libc/libc_limits.h @@ -2,10 +2,6 @@ * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - */ - -/* - * File : libc_limits.h * * Change Logs: * Date Author Notes diff --git a/include/libc/libc_stdio.h b/include/libc/libc_stdio.h index 4a09f5c3d7..0550583630 100644 --- a/include/libc/libc_stdio.h +++ b/include/libc/libc_stdio.h @@ -2,10 +2,6 @@ * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - */ - -/* - * File : libc_stdio.h * * Change Logs: * Date Author Notes -- cgit v1.3.1 From 0eadf69f81b2f77eed0cf7a35acdf50c03cc48a4 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Sun, 6 Sep 2020 12:31:42 +0800 Subject: 增加rtconfig.h头文件 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/libc/libc_limits.h | 1 + include/libc/libc_stdio.h | 2 ++ 2 files changed, 3 insertions(+) (limited to 'include') diff --git a/include/libc/libc_limits.h b/include/libc/libc_limits.h index 2b49db97d9..b8368160df 100644 --- a/include/libc/libc_limits.h +++ b/include/libc/libc_limits.h @@ -12,6 +12,7 @@ #define LIBC_LIMITS_H__ #include +#include #ifdef RT_USING_POSIX diff --git a/include/libc/libc_stdio.h b/include/libc/libc_stdio.h index 0550583630..85ba509852 100644 --- a/include/libc/libc_stdio.h +++ b/include/libc/libc_stdio.h @@ -11,6 +11,8 @@ #ifndef LIBC_STDIO_H__ #define LIBC_STDIO_H__ +#include + #ifdef RT_USING_POSIX_GETLINE #include -- cgit v1.3.1 From ff097f0467fb0041817846f2472343b7b9c098c4 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Tue, 8 Sep 2020 13:16:49 +0800 Subject: 增加 __GNUC__宏定义 和sconscript的平台识别以避免重复定义 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/common/SConscript | 3 ++- components/libc/compilers/minilibc/SConscript | 2 +- include/libc/libc_errno.h | 4 ++-- include/libc/libc_fcntl.h | 2 +- include/libc/libc_fdset.h | 2 +- include/libc/libc_stat.h | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index 718f05743c..a5f4a3fda6 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -16,6 +16,7 @@ else: if GetDepend('RT_USING_POSIX') == False: SrcRemove(src, ['unistd.c']) -group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) +if not GetDepend('RT_USING_MINILIBC') and GetDepend('RT_USING_LIBC'): + group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) Return('group') diff --git a/components/libc/compilers/minilibc/SConscript b/components/libc/compilers/minilibc/SConscript index 518d800571..dec657028f 100644 --- a/components/libc/compilers/minilibc/SConscript +++ b/components/libc/compilers/minilibc/SConscript @@ -8,7 +8,7 @@ group = [] CPPPATH = [cwd] CPPDEFINES = ['RT_USING_MINILIBC'] -if rtconfig.PLATFORM == 'gcc' and rtconfig.ARCH != 'sim' and not GetDepend('RT_USING_LIBC'): +if rtconfig.PLATFORM == 'gcc' and rtconfig.ARCH != 'sim' and not GetDepend('RT_USING_LIBC') and GetDepend('RT_USING_MINILIBC'): group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) diff --git a/include/libc/libc_errno.h b/include/libc/libc_errno.h index 0f3bc7635a..00c1f733d3 100644 --- a/include/libc/libc_errno.h +++ b/include/libc/libc_errno.h @@ -13,7 +13,7 @@ #include -#if defined(RT_USING_NEWLIB) || defined(_WIN32) +#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ ) /* use errno.h file in toolchains */ #include #endif @@ -45,7 +45,7 @@ defined in armcc/errno.h #define ERROR_BASE_NO 0 #endif -#if !defined(RT_USING_NEWLIB) && !defined(_WIN32) +#if !defined(RT_USING_NEWLIB) && !defined(_WIN32) && !defined(__GNUC__ ) #define EPERM (ERROR_BASE_NO + 1) #define ENOENT (ERROR_BASE_NO + 2) diff --git a/include/libc/libc_fcntl.h b/include/libc/libc_fcntl.h index 385ac7cd9f..39740b7d85 100644 --- a/include/libc/libc_fcntl.h +++ b/include/libc/libc_fcntl.h @@ -12,7 +12,7 @@ #ifndef LIBC_FCNTL_H__ #define LIBC_FCNTL_H__ -#if defined(RT_USING_NEWLIB) || defined(_WIN32) +#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ ) #include #ifndef O_NONBLOCK diff --git a/include/libc/libc_fdset.h b/include/libc/libc_fdset.h index b4d2e2189a..4a778b51c1 100644 --- a/include/libc/libc_fdset.h +++ b/include/libc/libc_fdset.h @@ -13,7 +13,7 @@ #include -#if defined(RT_USING_NEWLIB) || defined(_WIN32) +#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ ) #include #if defined(HAVE_SYS_SELECT_H) #include diff --git a/include/libc/libc_stat.h b/include/libc/libc_stat.h index 9079d1ef15..9388688572 100644 --- a/include/libc/libc_stat.h +++ b/include/libc/libc_stat.h @@ -9,7 +9,7 @@ #include -#if defined(RT_USING_NEWLIB) +#if defined(RT_USING_NEWLIB) || defined( __GNUC__ ) /* use header file of newlib */ #include -- cgit v1.3.1 From c7aa6f0619318a3730fc4f4689d2cd2e72efed52 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Fri, 2 Oct 2020 12:00:52 +0800 Subject: [fix bug] #3902 --- components/libc/compilers/common/readme.md | 11 ++++++++++- components/net/lwip-1.4.1/src/arch/include/arch/cc.h | 11 ++++++++--- components/net/lwip-2.0.2/src/arch/include/arch/cc.h | 11 ++++++++--- components/net/lwip-2.1.2/src/arch/include/arch/cc.h | 11 ++++++++--- include/libc/libc_errno.h | 4 ++-- include/libc/libc_fcntl.h | 2 +- include/libc/libc_fdset.h | 2 +- include/libc/libc_stat.h | 2 +- 8 files changed, 39 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/components/libc/compilers/common/readme.md b/components/libc/compilers/common/readme.md index cb91d95f45..0cd56272ff 100644 --- a/components/libc/compilers/common/readme.md +++ b/components/libc/compilers/common/readme.md @@ -1 +1,10 @@ -This folder is "common" for armlibc newlibc and dlib. It's not "common" for minilibc. \ No newline at end of file +# Attention : + +1. This folder is "common" for armlibc newlibc and dlib. It's not "common" for minilibc. + +2. If you want to add new .c files, please do not forget to fix SConscript file too. eg: + +```python +if GetDepend('RT_USING_POSIX') == False: + SrcRemove(src, ['unistd.c']) +``` \ No newline at end of file diff --git a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h index 604477dab8..80e9007459 100644 --- a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h +++ b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h @@ -66,7 +66,7 @@ typedef uintptr_t mem_ptr_t; #endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */ #endif -#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || defined ( __GNUC__) +#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include #define LWIP_TIMEVAL_PRIVATE 0 #else @@ -78,10 +78,15 @@ typedef uintptr_t mem_ptr_t; #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) #define PACK_STRUCT_BEGIN #define PACK_STRUCT_END -#elif defined(__IAR_SYSTEMS_ICC__) /* IAR Compiler */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /*Arm Compiler 6*/ +#define PACK_STRUCT_FIELD(x) x +#define PACK_STRUCT_STRUCT __attribute__((packed)) #define PACK_STRUCT_BEGIN -#define PACK_STRUCT_STRUCT #define PACK_STRUCT_END +#elif defined(__IAR_SYSTEMS_ICC__) /* IAR Compiler */ +#define PACK_STRUCT_BEGIN #pragma pack(1) +#define PACK_STRUCT_STRUCT +#define PACK_STRUCT_END #pragma pack() #define PACK_STRUCT_FIELD(x) x #define PACK_STRUCT_USE_INCLUDES #elif defined(__GNUC__) /* GNU GCC Compiler */ diff --git a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h index 00536a8419..8888995bcc 100644 --- a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h +++ b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h @@ -45,7 +45,7 @@ #define S32_F "ld" #define X32_F "lx" -#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || defined ( __GNUC__) +#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include #define LWIP_TIMEVAL_PRIVATE 0 #else @@ -57,10 +57,15 @@ #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) #define PACK_STRUCT_BEGIN #define PACK_STRUCT_END -#elif defined(__IAR_SYSTEMS_ICC__) /* IAR Compiler */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /*Arm Compiler 6*/ +#define PACK_STRUCT_FIELD(x) x +#define PACK_STRUCT_STRUCT __attribute__((packed)) #define PACK_STRUCT_BEGIN -#define PACK_STRUCT_STRUCT #define PACK_STRUCT_END +#elif defined(__IAR_SYSTEMS_ICC__) /* IAR Compiler */ +#define PACK_STRUCT_BEGIN #pragma pack(1) +#define PACK_STRUCT_STRUCT +#define PACK_STRUCT_END #pragma pack() #define PACK_STRUCT_FIELD(x) x #define PACK_STRUCT_USE_INCLUDES #elif defined(__GNUC__) /* GNU GCC Compiler */ diff --git a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h index 6905ecd442..61086b96d3 100644 --- a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h +++ b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h @@ -59,7 +59,7 @@ #endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */ #endif /* RT_USING_LIBC */ -#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || defined ( __GNUC__) +#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include #define LWIP_TIMEVAL_PRIVATE 0 #else @@ -71,10 +71,15 @@ #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) #define PACK_STRUCT_BEGIN #define PACK_STRUCT_END -#elif defined(__IAR_SYSTEMS_ICC__) /* IAR Compiler */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /*Arm Compiler 6*/ +#define PACK_STRUCT_FIELD(x) x +#define PACK_STRUCT_STRUCT __attribute__((packed)) #define PACK_STRUCT_BEGIN -#define PACK_STRUCT_STRUCT #define PACK_STRUCT_END +#elif defined(__IAR_SYSTEMS_ICC__) /* IAR Compiler */ +#define PACK_STRUCT_BEGIN #pragma pack(1) +#define PACK_STRUCT_STRUCT +#define PACK_STRUCT_END #pragma pack() #define PACK_STRUCT_FIELD(x) x #define PACK_STRUCT_USE_INCLUDES #elif defined(__GNUC__) /* GNU GCC Compiler */ diff --git a/include/libc/libc_errno.h b/include/libc/libc_errno.h index 00c1f733d3..9143c841f2 100644 --- a/include/libc/libc_errno.h +++ b/include/libc/libc_errno.h @@ -13,7 +13,7 @@ #include -#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ ) +#if defined(RT_USING_NEWLIB) || defined(_WIN32) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) /* use errno.h file in toolchains */ #include #endif @@ -45,7 +45,7 @@ defined in armcc/errno.h #define ERROR_BASE_NO 0 #endif -#if !defined(RT_USING_NEWLIB) && !defined(_WIN32) && !defined(__GNUC__ ) +#if !defined(RT_USING_NEWLIB) && !defined(_WIN32) && !(defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #define EPERM (ERROR_BASE_NO + 1) #define ENOENT (ERROR_BASE_NO + 2) diff --git a/include/libc/libc_fcntl.h b/include/libc/libc_fcntl.h index 39740b7d85..d149d86964 100644 --- a/include/libc/libc_fcntl.h +++ b/include/libc/libc_fcntl.h @@ -12,7 +12,7 @@ #ifndef LIBC_FCNTL_H__ #define LIBC_FCNTL_H__ -#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ ) +#if defined(RT_USING_NEWLIB) || defined(_WIN32) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include #ifndef O_NONBLOCK diff --git a/include/libc/libc_fdset.h b/include/libc/libc_fdset.h index 4a778b51c1..9700c7e83e 100644 --- a/include/libc/libc_fdset.h +++ b/include/libc/libc_fdset.h @@ -13,7 +13,7 @@ #include -#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ ) +#if defined(RT_USING_NEWLIB) || defined(_WIN32) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include #if defined(HAVE_SYS_SELECT_H) #include diff --git a/include/libc/libc_stat.h b/include/libc/libc_stat.h index 9388688572..6497cfe12c 100644 --- a/include/libc/libc_stat.h +++ b/include/libc/libc_stat.h @@ -9,7 +9,7 @@ #include -#if defined(RT_USING_NEWLIB) || defined( __GNUC__ ) +#if defined(RT_USING_NEWLIB) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) /* use header file of newlib */ #include -- cgit v1.3.1 From 98f0cfbf6e37a072ddf3aa2ae6a600c5dee964aa Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Fri, 23 Oct 2020 01:04:06 +0800 Subject: define maximum value of ipc type --- include/rtdef.h | 8 ++++++++ src/ipc.c | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/rtdef.h b/include/rtdef.h index 5543b80ab7..0690371c6d 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -33,6 +33,7 @@ * 2019-05-17 Bernard change version number to v4.0.2 * 2019-12-20 Bernard change version number to v4.0.3 * 2020-08-10 Meco Man add macro for struct rt_device_ops + * 2020-10-23 Meco Man define maximum value of ipc type */ #ifndef __RT_DEF_H__ @@ -102,6 +103,13 @@ typedef rt_base_t rt_off_t; /**< Type for offset */ #define RT_UINT32_MAX 0xffffffff /**< Maxium number of UINT32 */ #define RT_TICK_MAX RT_UINT32_MAX /**< Maxium number of tick */ +/* maximum value of ipc type */ +#define RT_SEM_VALUE_MAX RT_UINT16_MAX /**< Maxium number of semaphore .value */ +#define RT_MUTEX_VALUE_MAX RT_UINT16_MAX /**< Maxium number of mutex .value */ +#define RT_MUTEX_HOLD_MAX RT_UINT8_MAX /**< Maxium number of mutex .hold */ +#define RT_MB_ENTRY_MAX RT_UINT16_MAX /**< Maxium number of mailbox .entry */ +#define RT_MQ_ENTRY_MAX RT_UINT16_MAX /**< Maxium number of message queue .entry */ + #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #define __CLANG_ARM #endif diff --git a/src/ipc.c b/src/ipc.c index 9cd2b8846d..454fcb5439 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -465,7 +465,7 @@ rt_err_t rt_sem_release(rt_sem_t sem) } else { - if(sem->value < 65535u) + if(sem->value < RT_SEM_VALUE_MAX) { sem->value ++; /* increase value */ } @@ -696,7 +696,7 @@ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time) if (mutex->owner == thread) { - if(mutex->hold < 255u) + if(mutex->hold < RT_MUTEX_HOLD_MAX) { /* it's the same thread */ mutex->hold ++; @@ -723,7 +723,7 @@ __again: /* set mutex owner and original priority */ mutex->owner = thread; mutex->original_priority = thread->current_priority; - if(mutex->hold < 255u) + if(mutex->hold < RT_MUTEX_HOLD_MAX) { mutex->hold ++; } @@ -888,7 +888,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) /* set new owner and priority */ mutex->owner = thread; mutex->original_priority = thread->current_priority; - if(mutex->hold < 255u) + if(mutex->hold < RT_MUTEX_HOLD_MAX) { mutex->hold ++; } @@ -905,7 +905,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) } else { - if(mutex->value < 65535u) + if(mutex->value < RT_MUTEX_VALUE_MAX) { /* increase value */ mutex->value ++; @@ -1607,7 +1607,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, if (mb->in_offset >= mb->size) mb->in_offset = 0; - if(mb->entry < 65535u) + if(mb->entry < RT_MB_ENTRY_MAX) { /* increase message entry */ mb->entry ++; @@ -2179,7 +2179,7 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq, if (mq->msg_queue_head == RT_NULL) mq->msg_queue_head = msg; - if(mq->entry < 65535u) + if(mq->entry < RT_MQ_ENTRY_MAX) { /* increase message entry */ mq->entry ++; @@ -2287,7 +2287,7 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size) if (mq->msg_queue_tail == RT_NULL) mq->msg_queue_tail = msg; - if(mq->entry < 65535u) + if(mq->entry < RT_MQ_ENTRY_MAX) { /* increase message entry */ mq->entry ++; -- cgit v1.3.1