ChibiOS/RT Architecture - Reference Manual - Guides |
00001 /* 00002 ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. 00003 00004 This file is part of ChibiOS/RT. 00005 00006 ChibiOS/RT is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 ChibiOS/RT is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 00019 --- 00020 00021 A special exception to the GPL can be applied should you wish to distribute 00022 a combined work that includes ChibiOS/RT, without being obliged to provide 00023 the source code for any proprietary components. See the file exception.txt 00024 for full details of how and when the exception can be applied. 00025 */ 00026 00027 /** 00028 * @file chinline.h 00029 * @brief Kernel inlined functions. 00030 * @details In this file there are a set of inlined functions if the 00031 * @p CH_OPTIMIZE_SPEED is enabled. 00032 */ 00033 00034 #ifndef _CHINLINE_H_ 00035 #define _CHINLINE_H_ 00036 00037 /* If the performance code path has been chosen then all the following 00038 functions are inlined into the various kernel modules.*/ 00039 #if CH_OPTIMIZE_SPEED 00040 static INLINE void prio_insert(Thread *tp, ThreadsQueue *tqp) { 00041 00042 Thread *cp = (Thread *)tqp; 00043 do { 00044 cp = cp->p_next; 00045 } while ((cp != (Thread *)tqp) && (cp->p_prio >= tp->p_prio)); 00046 tp->p_next = cp; 00047 tp->p_prev = cp->p_prev; 00048 tp->p_prev->p_next = cp->p_prev = tp; 00049 } 00050 00051 static INLINE void queue_insert(Thread *tp, ThreadsQueue *tqp) { 00052 00053 tp->p_next = (Thread *)tqp; 00054 tp->p_prev = tqp->p_prev; 00055 tp->p_prev->p_next = tqp->p_prev = tp; 00056 } 00057 00058 static INLINE Thread *fifo_remove(ThreadsQueue *tqp) { 00059 Thread *tp = tqp->p_next; 00060 00061 (tqp->p_next = tp->p_next)->p_prev = (Thread *)tqp; 00062 return tp; 00063 } 00064 00065 static INLINE Thread *lifo_remove(ThreadsQueue *tqp) { 00066 Thread *tp = tqp->p_prev; 00067 00068 (tqp->p_prev = tp->p_prev)->p_next = (Thread *)tqp; 00069 return tp; 00070 } 00071 00072 static INLINE Thread *dequeue(Thread *tp) { 00073 00074 tp->p_prev->p_next = tp->p_next; 00075 tp->p_next->p_prev = tp->p_prev; 00076 return tp; 00077 } 00078 00079 static INLINE void list_insert(Thread *tp, ThreadsList *tlp) { 00080 00081 tp->p_next = tlp->p_next; 00082 tlp->p_next = tp; 00083 } 00084 00085 static INLINE Thread *list_remove(ThreadsList *tlp) { 00086 00087 Thread *tp = tlp->p_next; 00088 tlp->p_next = tp->p_next; 00089 return tp; 00090 } 00091 #endif /* CH_OPTIMIZE_SPEED */ 00092 00093 #endif /* _CHINLINE_H_ */