diff --git a/src/kservice.h b/include/rtservice.h similarity index 90% rename from src/kservice.h rename to include/rtservice.h index 3fa9cd2932ff029c6f0887d4d92cf783b6cb1110..52f823eded4e8b95ecd4e6df2401909ab8278fa3 100644 --- a/src/kservice.h +++ b/include/rtservice.h @@ -1,108 +1,102 @@ -/* - * File : kservice.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 - */ - -#ifndef __RT_SERVICE_H__ -#define __RT_SERVICE_H__ - -#include - -#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 - -#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 + * + * @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 diff --git a/include/rtthread.h b/include/rtthread.h index b491c9e7377fe0e79246d2676bc739cfeb30f05b..4fde569cf28a7907a5eb8edfc107c8aaa3ae128b 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -22,6 +22,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/device.c b/src/device.c index 90d3cb501ced5cf6bebadea3333b96c06600d27f..60335a941f33fa63d6daccade6e22b35296639b0 100644 --- a/src/device.c +++ b/src/device.c @@ -14,7 +14,6 @@ */ #include -#include "kservice.h" #ifdef RT_USING_DEVICE diff --git a/src/idle.c b/src/idle.c index 93ce0352dff89bb7a04b43563397ad79d7bd1acc..19cb35142ae7ee055cec649465e7c73efee9e0f2 100644 --- a/src/idle.c +++ b/src/idle.c @@ -15,7 +15,6 @@ #include #include -#include "kservice.h" #ifndef IDLE_THREAD_STACK_SIZE #if defined (RT_USING_HOOK) || defined(RT_USING_HEAP) diff --git a/src/ipc.c b/src/ipc.c index 0105b1dc001abfe5195faec8acf0535ee90d2b4a..01dded383958606c172a153d7373fa08ffc1d2d2 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -40,8 +40,6 @@ #include #include -#include "kservice.h" - #ifdef RT_USING_HOOK extern void (*rt_object_trytake_hook)(struct rt_object *object); extern void (*rt_object_take_hook)(struct rt_object *object); diff --git a/src/mempool.c b/src/mempool.c index 6eb57c3831b0141c8c3fa5e1f5d5cbadbe9bf094..5ca3b2654a26b92fe6135886478db5475f05417e 100644 --- a/src/mempool.c +++ b/src/mempool.c @@ -22,8 +22,6 @@ #include #include -#include "kservice.h" - #ifdef RT_USING_MEMPOOL #ifdef RT_USING_HOOK diff --git a/src/module.c b/src/module.c index 8853919135a3f0d1d1b0e0c0e551b9601f75a4f5..e4740dcf901a4071317e7079c0160cf57f227a55 100644 --- a/src/module.c +++ b/src/module.c @@ -21,7 +21,6 @@ #include #include "string.h" -#include "kservice.h" #ifdef RT_USING_MODULE #include "module.h" diff --git a/src/object.c b/src/object.c index 78b7fd784d8cd9a8efa3b9b1093c0cbaaefcb164..ce8c437a5773ab5e19526f76f2715a8a736a4b76 100644 --- a/src/object.c +++ b/src/object.c @@ -20,8 +20,6 @@ #include #include -#include "kservice.h" - #define _OBJ_CONTAINER_LIST_INIT(c) \ {&(rt_object_container[c].object_list), &(rt_object_container[c].object_list)} struct rt_object_information rt_object_container[RT_Object_Class_Unknown] = diff --git a/src/scheduler.c b/src/scheduler.c index 9c6aa81850f306938fcfba6c8c06ba3f8a6a5cec..a55cea22836691159432e7bfe4262fc1e81b2d27 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -29,8 +29,6 @@ #include #include -#include "kservice.h" - static rt_int16_t rt_scheduler_lock_nest; extern volatile rt_uint8_t rt_interrupt_nest; diff --git a/src/slab.c b/src/slab.c index 04cfa3c9859d797274d42eaa778279888c4f68d4..63b355a03f3f0a5a31b51a38bdbf033a7d865674 100644 --- a/src/slab.c +++ b/src/slab.c @@ -54,7 +54,6 @@ #include #include -#include "kservice.h" #define RT_MEM_STATS diff --git a/src/thread.c b/src/thread.c index 45082189655131d8a79034533122d0c4cc6cf689..b964099a72a0698964f179346eba5f2a72e3a9a8 100644 --- a/src/thread.c +++ b/src/thread.c @@ -27,7 +27,6 @@ #include #include -#include "kservice.h" extern rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX]; extern struct rt_thread *rt_current_thread; diff --git a/src/timer.c b/src/timer.c index c3fb8a52182bff0fa213382527fadcb9aa3d0c26..03babc49feae143cbf8b72dc12ef6c38a321b020 100644 --- a/src/timer.c +++ b/src/timer.c @@ -22,8 +22,6 @@ #include #include -#include "kservice.h" - /* hard timer list */ static rt_list_t rt_timer_list;