diff options
| author | bernard <[email protected]> | 2017-10-21 23:26:45 +0800 |
|---|---|---|
| committer | bernard <[email protected]> | 2017-10-21 23:26:45 +0800 |
| commit | 1181c5b308e8aa253459469e8276d48dce76285d (patch) | |
| tree | 2753f329a1419ab8c823e54d1b9c8c047b43336e /include | |
| parent | 252432baf0d744b081c2416eee7c9959b0fb149e (diff) | |
| parent | 67ffce7af2ce9778966afccd10560b56d887d1e3 (diff) | |
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
Diffstat (limited to 'include')
| -rw-r--r-- | include/libc/libc_fcntl.h | 1 | ||||
| -rw-r--r-- | include/rtlibc.h | 5 | ||||
| -rw-r--r-- | include/rtservice.h | 30 |
3 files changed, 36 insertions, 0 deletions
diff --git a/include/libc/libc_fcntl.h b/include/libc/libc_fcntl.h index 6d6f8ee6d7..68b714b855 100644 --- a/include/libc/libc_fcntl.h +++ b/include/libc/libc_fcntl.h @@ -25,6 +25,7 @@ #define O_DSYNC 010000 #define O_SYNC 04010000 #define O_RSYNC 04010000 +#define O_BINARY 0100000 #define O_DIRECTORY 0200000 #define O_NOFOLLOW 0400000 #define O_CLOEXEC 02000000 diff --git a/include/rtlibc.h b/include/rtlibc.h index 5d6b5a78e3..757329a22c 100644 --- a/include/rtlibc.h +++ b/include/rtlibc.h @@ -38,5 +38,10 @@ typedef signed long off_t; #endif +#if defined(__MINGW32__) +typedef signed long off_t; +typedef int mode_t; +#endif + #endif diff --git a/include/rtservice.h b/include/rtservice.h index 0ace555cdc..2c6682076d 100644 --- a/include/rtservice.h +++ b/include/rtservice.h @@ -105,6 +105,23 @@ rt_inline int rt_list_isempty(const rt_list_t *l) } /** + * @brief get the list length + * @param l the list to get. + */ +rt_inline unsigned int rt_list_len(const rt_list_t *l) +{ + unsigned int len = 0; + const rt_list_t *p = l; + while (p->next != l) + { + p = p->next; + len ++; + } + + return len; +} + +/** * @brief get the struct for this entry * @param node the entry point * @param type the type of structure @@ -177,6 +194,19 @@ rt_inline rt_slist_t *rt_slist_remove(rt_slist_t *l, rt_slist_t *n) return l; } +rt_inline unsigned int rt_slist_len(const rt_slist_t *l) +{ + unsigned int len = 0; + const rt_slist_t *list = l->next; + while (list != RT_NULL) + { + list = list->next; + len ++; + } + + return len; +} + /** * @brief get the struct for this single list node * @param node the entry point |
