diff options
| author | guochuangjian <[email protected]> | 2018-08-05 15:08:50 +0800 |
|---|---|---|
| committer | guochuangjian <[email protected]> | 2018-08-05 15:08:50 +0800 |
| commit | 3de51fe25688f0b6c7cb9f9d424861654fb09e49 (patch) | |
| tree | dcf4a170b00deace7860187e3ff9c2e6495e0923 /include | |
| parent | 650f06aa1943d439ac049f6bc276b216999e6a56 (diff) | |
| parent | 03bf99a56de255d41655bc8486d50cadbcae22f0 (diff) | |
fix usRcvBufferPos == MB_SER_PDU_SIZE_MAX bug
Diffstat (limited to 'include')
| -rw-r--r-- | include/libc/libc_fdset.h | 2 | ||||
| -rw-r--r-- | include/libc/libc_signal.h | 16 | ||||
| -rw-r--r-- | include/rtdbg.h | 45 | ||||
| -rw-r--r-- | include/rtdebug.h | 6 | ||||
| -rw-r--r-- | include/rtdef.h | 49 | ||||
| -rw-r--r-- | include/rtservice.h | 38 | ||||
| -rw-r--r-- | include/rtthread.h | 9 |
7 files changed, 136 insertions, 29 deletions
diff --git a/include/libc/libc_fdset.h b/include/libc/libc_fdset.h index 057cc7fed2..74c4ba1cb2 100644 --- a/include/libc/libc_fdset.h +++ b/include/libc/libc_fdset.h @@ -35,7 +35,7 @@ #else -#ifdef RT_USING_DFS_NET +#ifdef SAL_USING_POSIX #ifdef FD_SETSIZE #undef FD_SETSIZE diff --git a/include/libc/libc_signal.h b/include/libc/libc_signal.h index dabcad1a34..d3050bfb54 100644 --- a/include/libc/libc_signal.h +++ b/include/libc/libc_signal.h @@ -25,12 +25,15 @@ #ifndef LIBC_SIGNAL_H__ #define LIBC_SIGNAL_H__ - #ifdef __cplusplus extern "C" { #endif -#ifndef HAVE_SYS_SIGNALS +#ifdef HAVE_CCONFIG_H +#include <cconfig.h> +#endif + +#ifndef HAVE_SIGVAL /* Signal Generation and Delivery, P1003.1b-1993, p. 63 NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and sigev_notify_attributes to the sigevent structure. */ @@ -40,7 +43,9 @@ union sigval int sival_int; /* Integer signal value */ void *sival_ptr; /* Pointer signal value */ }; +#endif +#ifndef HAVE_SIGEVENT struct sigevent { int sigev_notify; /* Notification type */ @@ -50,12 +55,13 @@ struct sigevent /* Notification function */ void *sigev_notify_attributes; /* Notification Attributes, really pthread_attr_t */ }; +#endif +#ifndef HAVE_SIGINFO struct siginfo { - rt_uint8_t si_signo; - rt_uint8_t si_code; - rt_int16_t si_errno; + rt_uint16_t si_signo; + rt_uint16_t si_code; union sigval si_value; }; diff --git a/include/rtdbg.h b/include/rtdbg.h index 26e289eff6..f53aba8de9 100644 --- a/include/rtdbg.h +++ b/include/rtdbg.h @@ -20,6 +20,7 @@ * Change Logs: * Date Author Notes * 2016-11-12 Bernard The first version + * 2018-05-25 armink Add simple API, such as LOG_D, LOG_E */ /* @@ -31,7 +32,7 @@ * In your C/C++ file, enable/disable DEBUG_ENABLE macro, and then include this * header file. * - * #define DBG_SECTION_NAME "[ MOD]" + * #define DBG_SECTION_NAME "MOD" * #define DBG_ENABLE // enable debug macro * #define DBG_LEVEL DBG_INFO * #include <rtdbg.h> // must after of DEBUG_ENABLE or some other options @@ -39,7 +40,11 @@ * Then in your C/C++ file, you can use dbg_log macro to print out logs: * dbg_log(DBG_INFO, "this is a log!\n"); * - * Or if you want to use different color for different kinds log, you can + * Or if you want to using the simple API, you can + * LOG_D("this is a debug log!"); + * LOG_E("this is a error log!"); + * + * If you want to use different color for different kinds log, you can * #define DBG_COLOR */ @@ -55,7 +60,7 @@ #define DBG_ERROR 3 #ifndef DBG_SECTION_NAME -#define DBG_SECTION_NAME "[ DBG]" +#define DBG_SECTION_NAME "DBG" #endif #ifdef DBG_ENABLE @@ -76,10 +81,14 @@ * WHITE 37 */ #ifdef DBG_COLOR -#define _DBG_COLOR(n) rt_kprintf("\033["#n"m") +#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"] ") #else #define _DBG_COLOR(n) -#endif +#define _DBG_LOG_HDR(lvl_name, color_n) \ + rt_kprintf("["lvl_name"/"DBG_SECTION_NAME"] ") +#endif /* DBG_COLOR */ /* * static debug routine @@ -89,12 +98,13 @@ { \ switch(level) \ { \ - case DBG_ERROR: _DBG_COLOR(31); break; \ - case DBG_WARNING: _DBG_COLOR(33); break; \ - case DBG_INFO: _DBG_COLOR(32); break; \ + case DBG_ERROR: _DBG_LOG_HDR("E", 31); break; \ + case DBG_WARNING: _DBG_LOG_HDR("W", 33); break; \ + case DBG_INFO: _DBG_LOG_HDR("I", 32); break; \ + case DBG_LOG: _DBG_LOG_HDR("D", 0); break; \ default: break; \ } \ - rt_kprintf(DBG_SECTION_NAME fmt, ##__VA_ARGS__); \ + rt_kprintf(fmt, ##__VA_ARGS__); \ _DBG_COLOR(0); \ } @@ -120,12 +130,27 @@ _DBG_COLOR(0); \ } +#define dbg_log_line(level, ...) \ + dbg_log(level, __VA_ARGS__); \ + if ((level) >= DBG_LEVEL) { \ + rt_kprintf("\n"); \ + } + +#define dbg_raw(...) rt_kprintf(__VA_ARGS__); + #else #define dbg_log(level, fmt, ...) #define dbg_here #define dbg_enter #define dbg_exit +#define dbg_log_line(level, ...) +#define dbg_raw(...) #endif -#endif +#define LOG_D(...) dbg_log_line(DBG_LOG , __VA_ARGS__) +#define LOG_I(...) dbg_log_line(DBG_INFO , __VA_ARGS__) +#define LOG_W(...) dbg_log_line(DBG_WARNING, __VA_ARGS__) +#define LOG_E(...) dbg_log_line(DBG_ERROR , __VA_ARGS__) +#define LOG_RAW(...) dbg_raw(__VA_ARGS__) +#endif /* RT_DBG_H__ */ diff --git a/include/rtdebug.h b/include/rtdebug.h index a9c0c0372f..e403d51e06 100644 --- a/include/rtdebug.h +++ b/include/rtdebug.h @@ -29,10 +29,6 @@ #error "POSIX poll/select, stdin need file system(RT_USING_DFS) and device file system(RT_USING_DFS_DEVFS)" #endif -#if defined(RT_USING_LWIP) && !defined(RT_USING_DFS_NET) -#error "POSIX poll/select, stdin need file BSD socket API(RT_USING_DFS_NET)" -#endif - #if !defined(RT_USING_LIBC) #error "POSIX layer need standard C library(RT_USING_LIBC)" #endif @@ -117,7 +113,7 @@ do \ level = rt_hw_interrupt_disable(); \ if (rt_interrupt_get_nest() != 0) \ { \ - rt_kprintf("Function[%s] shall not ne used in ISR\n", __FUNCTION__); \ + rt_kprintf("Function[%s] shall not be used in ISR\n", __FUNCTION__); \ RT_ASSERT(0) \ } \ rt_hw_interrupt_enable(level); \ diff --git a/include/rtdef.h b/include/rtdef.h index 9f0083853a..f8d90ceadb 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -35,6 +35,7 @@ * 2017-12-27 Bernard change version number to v3.0.2 * 2018-02-24 Bernard change version number to v3.0.3 * 2018-04-25 Bernard change version number to v3.0.4 + * 2018-05-31 Bernard change version number to v3.1.0 */ #ifndef __RT_DEF_H__ @@ -55,8 +56,8 @@ extern "C" { /* RT-Thread version information */ #define RT_VERSION 3L /**< major version number */ -#define RT_SUBVERSION 0L /**< minor version number */ -#define RT_REVISION 4L /**< revise version number */ +#define RT_SUBVERSION 1L /**< minor version number */ +#define RT_REVISION 0L /**< revise version number */ /* RT-Thread version */ #define RTTHREAD_VERSION ((RT_VERSION * 10000) + \ @@ -495,6 +496,10 @@ typedef siginfo_t rt_siginfo_t; #define RT_THREAD_CTRL_CHANGE_PRIORITY 0x02 /**< Change thread priority. */ #define RT_THREAD_CTRL_INFO 0x03 /**< Get thread information. */ +#ifdef RT_USING_LWP +struct rt_lwp; +#endif + /** * Thread structure */ @@ -555,7 +560,11 @@ struct rt_thread void (*cleanup)(struct rt_thread *tid); /**< cleanup function when thread exit */ - rt_uint32_t user_data; /**< private user data beyond this thread */ + rt_uint32_t user_data; /**< private user data beyond this thread */ + +#ifdef RT_USING_LWP + struct rt_lwp *lwp; /**< if NULL it's a kernel thread */ +#endif }; typedef struct rt_thread *rt_thread_t; @@ -848,6 +857,30 @@ enum rt_device_class_type typedef struct rt_device *rt_device_t; /** + * operations set for device object + */ +struct rt_device_ops +{ + /* common device interface */ + rt_err_t (*init) (rt_device_t dev); + rt_err_t (*open) (rt_device_t dev, rt_uint16_t oflag); + rt_err_t (*close) (rt_device_t dev); + rt_size_t (*read) (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size); + 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); +}; + +/** + * WaitQueue structure + */ +struct rt_wqueue +{ + rt_uint32_t flag; + rt_list_t waiting_list; +}; +typedef struct rt_wqueue rt_wqueue_t; + +/** * Device structure */ struct rt_device @@ -865,6 +898,9 @@ struct rt_device rt_err_t (*rx_indicate)(rt_device_t dev, rt_size_t size); rt_err_t (*tx_complete)(rt_device_t dev, void *buffer); +#ifdef RT_USING_DEVICE_OPS + const struct rt_device_ops *ops; +#else /* common device interface */ rt_err_t (*init) (rt_device_t dev); rt_err_t (*open) (rt_device_t dev, rt_uint16_t oflag); @@ -872,10 +908,11 @@ struct rt_device rt_size_t (*read) (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size); 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 #if defined(RT_USING_POSIX) const struct dfs_file_ops *fops; - rt_list_t wait_queue; + struct rt_wqueue wait_queue; #endif void *user_data; /**< device private data */ @@ -1029,8 +1066,8 @@ struct rt_module rt_uint32_t user_data; /**< arch data in the module */ - /* object in this module, module object is the last basic object type */ - struct rt_object_information module_object[RT_Object_Class_Unknown]; + void (*module_init)(void); + void (*module_cleanup)(void); }; typedef struct rt_module *rt_module_t; diff --git a/include/rtservice.h b/include/rtservice.h index 7c7982da00..0bfa424338 100644 --- a/include/rtservice.h +++ b/include/rtservice.h @@ -141,6 +141,24 @@ rt_inline unsigned int rt_list_len(const rt_list_t *l) rt_container_of(node, type, member) /** + * 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. + */ +#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. + */ +#define rt_list_for_each_safe(pos, n, head) \ + 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 * @pos: the type * to use as a loop cursor. * @head: the head for your list. @@ -230,6 +248,16 @@ rt_inline rt_slist_t *rt_slist_remove(rt_slist_t *l, rt_slist_t *n) return l; } +rt_inline rt_slist_t *rt_slist_first(rt_slist_t *l) +{ + return l->next; +} + +rt_inline rt_slist_t *rt_slist_next(rt_slist_t *n) +{ + return n->next; +} + rt_inline int rt_slist_isempty(rt_slist_t *l) { return l->next == RT_NULL; @@ -245,12 +273,20 @@ rt_inline int rt_slist_isempty(rt_slist_t *l) rt_container_of(node, type, member) /** + * rt_slist_for_each - iterate over a single list + * @pos: the rt_slist_t * to use as a loop cursor. + * @head: the head for your single list. + */ +#define rt_slist_for_each(pos, head) \ + for (pos = (head)->next; pos != RT_NULL; pos = pos->next) + +/** * rt_slist_for_each_entry - iterate over single list of given type * @pos: the type * to use as a loop cursor. * @head: the head for your single list. * @member: the name of the list_struct within the struct. */ -#define rt_slist_fore_each_entry(pos, head, member) \ +#define rt_slist_for_each_entry(pos, head, member) \ for (pos = rt_slist_entry((head)->next, typeof(*pos), member); \ &pos->member != (RT_NULL); \ pos = rt_slist_entry(pos->member.next, typeof(*pos), member)) diff --git a/include/rtthread.h b/include/rtthread.h index 9378b83cf7..86a1664f83 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -62,6 +62,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name); void rt_object_delete(rt_object_t object); rt_bool_t rt_object_is_systemobject(rt_object_t object); +rt_uint8_t rt_object_get_type(rt_object_t object); rt_object_t rt_object_find(const char *name, rt_uint8_t type); #ifdef RT_USING_HOOK @@ -149,6 +150,7 @@ rt_err_t rt_thread_delete(rt_thread_t thread); rt_err_t rt_thread_yield(void); rt_err_t rt_thread_delay(rt_tick_t tick); +rt_err_t rt_thread_mdelay(rt_int32_t ms); rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg); rt_err_t rt_thread_suspend(rt_thread_t thread); rt_err_t rt_thread_resume(rt_thread_t thread); @@ -171,7 +173,8 @@ void rt_thread_inited_sethook (void (*hook)(rt_thread_t thread)); */ void rt_thread_idle_init(void); #if defined(RT_USING_HOOK) || defined(RT_USING_IDLE_HOOK) -void rt_thread_idle_sethook(void (*hook)(void)); +rt_err_t rt_thread_idle_sethook(void (*hook)(void)); +rt_err_t rt_thread_idle_delhook(void (*hook)(void)); #endif void rt_thread_idle_excute(void); rt_thread_t rt_thread_idle_gethandler(void); @@ -546,6 +549,10 @@ 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); char *rt_strdup(const char *s); +#ifdef __CC_ARM +/* leak 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, ...); |
