|
QP/C++
|
00001 00002 // Product: QF/C++ 00003 // Last Updated for Version: 4.5.04 00004 // Date of the Last Update: Feb 09, 2013 00005 // 00006 // Q u a n t u m L e a P s 00007 // --------------------------- 00008 // innovating embedded systems 00009 // 00010 // Copyright (C) 2002-2013 Quantum Leaps, LLC. All rights reserved. 00011 // 00012 // This program is open source software: you can redistribute it and/or 00013 // modify it under the terms of the GNU General Public License as published 00014 // by the Free Software Foundation, either version 2 of the License, or 00015 // (at your option) any later version. 00016 // 00017 // Alternatively, this program may be distributed and modified under the 00018 // terms of Quantum Leaps commercial licenses, which expressly supersede 00019 // the GNU General Public License and are specifically designed for 00020 // licensees interested in retaining the proprietary status of their code. 00021 // 00022 // This program is distributed in the hope that it will be useful, 00023 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 // GNU General Public License for more details. 00026 // 00027 // You should have received a copy of the GNU General Public License 00028 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00029 // 00030 // Contact information: 00031 // Quantum Leaps Web sites: http://www.quantum-leaps.com 00032 // http://www.state-machine.com 00033 // e-mail: info@quantum-leaps.com 00035 #ifndef qf_pkg_h 00036 #define qf_pkg_h 00037 00041 00042 #include "qf_port.h" // QF port 00043 00044 #ifndef qpset_h 00045 #include "qpset.h" // for lookup tables 00046 #endif 00047 00049 #define QF_EVT_CONST_CAST_(e_) const_cast<QEvt *>(e_) 00050 00051 QP_BEGIN_ 00052 // QF-specific critical section 00053 #ifndef QF_CRIT_STAT_TYPE 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 #define QF_CRIT_STAT_ 00065 00075 #define QF_CRIT_ENTRY_() QF_CRIT_ENTRY(dummy) 00076 00086 #define QF_CRIT_EXIT_() QF_CRIT_EXIT(dummy) 00087 00088 #else 00089 #define QF_CRIT_STAT_ QF_CRIT_STAT_TYPE critStat_; 00090 #define QF_CRIT_ENTRY_() QF_CRIT_ENTRY(critStat_) 00091 #define QF_CRIT_EXIT_() QF_CRIT_EXIT(critStat_) 00092 #endif 00093 00094 // package-scope objects ----------------------------------------------------- 00095 extern QTimeEvt *QF_timeEvtListHead_; 00096 extern QF_EPOOL_TYPE_ QF_pool_[QF_MAX_EPOOL]; 00097 extern uint8_t QF_maxPool_; 00098 extern QSubscrList *QF_subscrList_; 00099 extern enum_t QF_maxSignal_; 00100 00101 //............................................................................ 00104 struct QFreeBlock { 00105 QFreeBlock *m_next; 00106 }; 00107 00109 // internal helper inline functions 00110 00112 inline uint8_t QF_EVT_POOL_ID_(QEvt const * const e) { return e->poolId_; } 00113 00115 inline uint8_t QF_EVT_REF_CTR_(QEvt const * const e) { return e->refCtr_; } 00116 00118 inline void QF_EVT_REF_CTR_INC_(QEvt const * const e) { 00119 ++(QF_EVT_CONST_CAST_(e))->refCtr_; 00120 } 00121 00123 inline void QF_EVT_REF_CTR_DEC_(QEvt const * const e) { 00124 --(QF_EVT_CONST_CAST_(e))->refCtr_; 00125 } 00126 00128 // internal frequently used srongly-typed constants 00129 00130 uint8_t const u8_0 = static_cast<uint8_t>(0); 00131 uint8_t const u8_1 = static_cast<uint8_t>(1); 00132 int8_t const s8_0 = static_cast<int8_t>(0); 00133 int8_t const s8_1 = static_cast<int8_t>(1); 00134 QTimeEvtCtr const tc_0 = static_cast<QTimeEvtCtr>(0); 00135 00136 void * const null_void = static_cast<void *>(0); 00137 QEvt const * const null_evt = static_cast<QEvt const *>(0); 00138 QTimeEvt * const null_tevt = static_cast<QTimeEvt *>(0); 00139 QActive * const null_act = static_cast<QActive *>(0); 00140 00141 QP_END_ 00142 00144 #define QF_PTR_AT_(base_, i_) (base_[i_]) 00145 00147 #ifdef Q_SPY // QS software tracing enabled? 00148 00149 #include "qs_port.h" // include QS port 00150 00151 #if (QF_EQUEUE_CTR_SIZE == 1) 00152 00156 #define QS_EQC_(ctr_) QS::u8_(ctr_) 00157 #elif (QF_EQUEUE_CTR_SIZE == 2) 00158 #define QS_EQC_(ctr_) QS::u16_(ctr_) 00159 #elif (QF_EQUEUE_CTR_SIZE == 4) 00160 #define QS_EQC_(ctr_) QS::u32_(ctr_) 00161 #else 00162 #error "QF_EQUEUE_CTR_SIZE not defined" 00163 #endif 00164 00165 00166 #if (QF_EVENT_SIZ_SIZE == 1) 00167 00171 #define QS_EVS_(size_) QS::u8_(size_) 00172 #elif (QF_EVENT_SIZ_SIZE == 2) 00173 #define QS_EVS_(size_) QS::u16_(size_) 00174 #elif (QF_EVENT_SIZ_SIZE == 4) 00175 #define QS_EVS_(size_) QS::u32_(size_) 00176 #endif 00177 00178 00179 #if (QF_MPOOL_SIZ_SIZE == 1) 00180 00184 #define QS_MPS_(size_) QS::u8_(size_) 00185 #elif (QF_MPOOL_SIZ_SIZE == 2) 00186 #define QS_MPS_(size_) QS::u16_(size_) 00187 #elif (QF_MPOOL_SIZ_SIZE == 4) 00188 #define QS_MPS_(size_) QS::u32_(size_) 00189 #endif 00190 00191 #if (QF_MPOOL_CTR_SIZE == 1) 00192 00196 #define QS_MPC_(ctr_) QS::u8_(ctr_) 00197 #elif (QF_MPOOL_CTR_SIZE == 2) 00198 #define QS_MPC_(ctr_) QS::u16_(ctr_) 00199 #elif (QF_MPOOL_CTR_SIZE == 4) 00200 #define QS_MPC_(ctr_) QS::u32_(ctr_) 00201 #endif 00202 00203 00204 #if (QF_TIMEEVT_CTR_SIZE == 1) 00205 00209 #define QS_TEC_(ctr_) QS::u8_(ctr_) 00210 #elif (QF_TIMEEVT_CTR_SIZE == 2) 00211 #define QS_TEC_(ctr_) QS::u16_(ctr_) 00212 #elif (QF_TIMEEVT_CTR_SIZE == 4) 00213 #define QS_TEC_(ctr_) QS::u32_(ctr_) 00214 #endif 00215 00216 #else 00217 00218 #include "qs_dummy.h" // disable the QS software tracing 00219 00220 #endif // Q_SPY 00221 00222 #endif // qf_pkg_h
1.7.6.1