From 055c3d3e1d75fedac44ffb41943350d9844f5b7e Mon Sep 17 00:00:00 2001 From: chenjh Date: Fri, 26 Feb 2021 18:23:52 +0800 Subject: [Update] Sync from v4.0.3 --- include/libc/libc_errno.h | 4 ++-- include/libc/libc_fcntl.h | 2 +- include/libc/libc_fdset.h | 2 +- include/libc/libc_signal.h | 5 +++-- include/libc/libc_stat.h | 2 +- include/rtdbg.h | 12 ++++++++++-- include/rtdef.h | 37 +++++++++++++++++++++++-------------- include/rtthread.h | 5 ++++- 8 files changed, 45 insertions(+), 24 deletions(-) (limited to 'include') diff --git a/include/libc/libc_errno.h b/include/libc/libc_errno.h index 0f3bc7635a..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) +#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) +#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 1b7c69b1f4..94705ba1b4 100644 --- a/include/libc/libc_fcntl.h +++ b/include/libc/libc_fcntl.h @@ -16,7 +16,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__ ) && !defined(__ARMCC_VERSION)) #include #ifndef O_NONBLOCK diff --git a/include/libc/libc_fdset.h b/include/libc/libc_fdset.h index ecd965cd22..33a888883c 100644 --- a/include/libc/libc_fdset.h +++ b/include/libc/libc_fdset.h @@ -17,7 +17,7 @@ #include -#if defined(RT_USING_NEWLIB) || defined(_WIN32) +#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_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; }; diff --git a/include/libc/libc_stat.h b/include/libc/libc_stat.h index 9079d1ef15..6497cfe12c 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__ ) && !defined(__ARMCC_VERSION)) /* use header file of newlib */ #include diff --git a/include/rtdbg.h b/include/rtdbg.h index a2dfbd9697..be5a57f312 100644 --- a/include/rtdbg.h +++ b/include/rtdbg.h @@ -32,6 +32,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /* the debug log will force enable when RT_DEBUG macro is defined */ #if defined(RT_DEBUG) && !defined(DBG_ENABLE) #define DBG_ENABLE @@ -91,13 +95,13 @@ #ifdef DBG_COLOR #define _DBG_COLOR(n) rt_kprintf("\033["#n"m") #define _DBG_LOG_HDR(lvl_name, color_n) \ - rt_kprintf("\033["#color_n"m["lvl_name"/"DBG_SECTION_NAME"] ") + rt_kprintf("\033["#color_n"m[" lvl_name "/" DBG_SECTION_NAME "] ") #define _DBG_LOG_X_END \ rt_kprintf("\033[0m\n") #else #define _DBG_COLOR(n) #define _DBG_LOG_HDR(lvl_name, color_n) \ - rt_kprintf("["lvl_name"/"DBG_SECTION_NAME"] ") + rt_kprintf("[" lvl_name "/" DBG_SECTION_NAME "] ") #define _DBG_LOG_X_END \ rt_kprintf("\n") #endif /* DBG_COLOR */ @@ -176,4 +180,8 @@ #endif /* defined(RT_USING_ULOG) && define(DBG_ENABLE) */ +#ifdef __cplusplus +} +#endif + #endif /* RT_DBG_H__ */ diff --git a/include/rtdef.h b/include/rtdef.h index 080fafe6ee..a27854cb39 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -97,6 +97,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 @@ -368,20 +375,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. */ }; /** @@ -427,6 +434,7 @@ struct rt_object_information #define RT_TIMER_CTRL_GET_TIME 0x1 /**< get timer control command */ #define RT_TIMER_CTRL_SET_ONESHOT 0x2 /**< change timer to one shot */ #define RT_TIMER_CTRL_SET_PERIODIC 0x3 /**< change timer to periodic */ +#define RT_TIMER_CTRL_GET_STATE 0x4 /**< get timer run state active or deactive*/ #ifndef RT_TIMER_SKIP_LIST_LEVEL #define RT_TIMER_SKIP_LIST_LEVEL 1 @@ -846,6 +854,7 @@ enum rt_device_class_type #define RT_DEVICE_CTRL_RESUME 0x01 /**< resume device */ #define RT_DEVICE_CTRL_SUSPEND 0x02 /**< suspend device */ #define RT_DEVICE_CTRL_CONFIG 0x03 /**< configure device */ +#define RT_DEVICE_CTRL_CLOSE 0x04 /**< close device */ #define RT_DEVICE_CTRL_SET_INT 0x10 /**< set interrupt */ #define RT_DEVICE_CTRL_CLR_INT 0x11 /**< clear interrupt */ diff --git a/include/rtthread.h b/include/rtthread.h index 32fe011ab2..419f02695b 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -40,6 +40,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); @@ -514,7 +517,7 @@ 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_uint32_t rt_strcasecmp(const char *a, const char *b); +rt_int32_t rt_strcasecmp(const char *a, const char *b); void rt_show_version(void); -- cgit v1.3.1