diff options
| author | [email protected] <[email protected]> | 2012-04-14 03:52:56 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2012-04-14 03:52:56 +0000 |
| commit | 87195cf84ebc323b813899b19ff95b60ef8bc589 (patch) | |
| tree | f009b0e6036ad38b7f4ba24d9e2685159321f3be /include/rtservice.h | |
| parent | 8061067343e2eda986616bb68aa52fe7fded5456 (diff) | |
Added memory heap object implementation; Added RT_LIST_OBJECT_INIT macro.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2046 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'include/rtservice.h')
| -rw-r--r-- | include/rtservice.h | 209 |
1 files changed, 107 insertions, 102 deletions
diff --git a/include/rtservice.h b/include/rtservice.h index 52f823eded..fb491895ef 100644 --- a/include/rtservice.h +++ b/include/rtservice.h @@ -1,102 +1,107 @@ -/*
- * File : rtservice.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
- *
- * Change Logs:
- * Date Author Notes
- * 2006-03-16 Bernard the first version
- * 2006-09-07 Bernard move the kservice APIs to rtthread.h
- * 2007-06-27 Bernard fix the rt_list_remove bug
- * 2012-03-22 Bernard rename kservice.h to rtservice.h
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup KernelService
- */
-
-/*@{*/
-
-/**
- * @brief initialize a list
- *
- * @param l list to be initialized
- */
-rt_inline void rt_list_init(rt_list_t *l)
-{
- l->next = l->prev = l;
-}
-
-/**
- * @brief insert a node after a list
- *
- * @param l list to insert it
- * @param n new node to be inserted
- */
-rt_inline void rt_list_insert_after(rt_list_t *l, rt_list_t *n)
-{
- l->next->prev = n;
- n->next = l->next;
-
- l->next = n;
- n->prev = l;
-}
-
-/**
- * @brief insert a node before a list
- *
- * @param n new node to be inserted
- * @param l list to insert it
- */
-rt_inline void rt_list_insert_before(rt_list_t *l, rt_list_t *n)
-{
- l->prev->next = n;
- n->prev = l->prev;
-
- l->prev = n;
- n->next = l;
-}
-
-/**
- * @brief remove node from list.
- * @param n the node to remove from the list.
- */
-rt_inline void rt_list_remove(rt_list_t *n)
-{
- n->next->prev = n->prev;
- n->prev->next = n->next;
-
- n->next = n->prev = n;
-}
-
-/**
- * @brief tests whether a list is empty
- * @param l the list to test.
- */
-rt_inline int rt_list_isempty(const rt_list_t *l)
-{
- return l->next == l;
-}
-
-/**
- * @brief get the struct for this entry
- * @param node the entry point
- * @param type the type of structure
- * @param member the name of list in structure
- */
-#define rt_list_entry(node, type, member) \
- ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member)))
-
-/*@}*/
-
-#ifdef __cplusplus
-}
-#endif
+/* + * File : rtservice.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2006-03-16 Bernard the first version + * 2006-09-07 Bernard move the kservice APIs to rtthread.h + * 2007-06-27 Bernard fix the rt_list_remove bug + * 2012-03-22 Bernard rename kservice.h to rtservice.h + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup KernelService + */ + +/*@{*/ + +/** + * @brief initialize a list object + */ +#define RT_LIST_OBJECT_INIT(object) { &(object), &(object) } + +/** + * @brief initialize a list + * + * @param l list to be initialized + */ +rt_inline void rt_list_init(rt_list_t *l) +{ + l->next = l->prev = l; +} + +/** + * @brief insert a node after a list + * + * @param l list to insert it + * @param n new node to be inserted + */ +rt_inline void rt_list_insert_after(rt_list_t *l, rt_list_t *n) +{ + l->next->prev = n; + n->next = l->next; + + l->next = n; + n->prev = l; +} + +/** + * @brief insert a node before a list + * + * @param n new node to be inserted + * @param l list to insert it + */ +rt_inline void rt_list_insert_before(rt_list_t *l, rt_list_t *n) +{ + l->prev->next = n; + n->prev = l->prev; + + l->prev = n; + n->next = l; +} + +/** + * @brief remove node from list. + * @param n the node to remove from the list. + */ +rt_inline void rt_list_remove(rt_list_t *n) +{ + n->next->prev = n->prev; + n->prev->next = n->next; + + n->next = n->prev = n; +} + +/** + * @brief tests whether a list is empty + * @param l the list to test. + */ +rt_inline int rt_list_isempty(const rt_list_t *l) +{ + return l->next == l; +} + +/** + * @brief get the struct for this entry + * @param node the entry point + * @param type the type of structure + * @param member the name of list in structure + */ +#define rt_list_entry(node, type, member) \ + ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member))) + +/*@}*/ + +#ifdef __cplusplus +} +#endif |
