|
QP/C
|
00001 /***************************************************************************** 00002 * Product: QF/C 00003 * Last Updated for Version: 4.4.00 00004 * Date of the Last Update: Jan 06, 2012 00005 * 00006 * Q u a n t u m L e a P s 00007 * --------------------------- 00008 * innovating embedded systems 00009 * 00010 * Copyright (C) 2002-2012 Quantum Leaps, LLC. All rights reserved. 00011 * 00012 * This software may be distributed and modified under the terms of the GNU 00013 * General Public License version 2 (GPL) as published by the Free Software 00014 * Foundation and appearing in the file GPL.TXT included in the packaging of 00015 * this file. Please note that GPL Section 2[b] requires that all works based 00016 * on this software must also be made publicly available under the terms of 00017 * the GPL ("Copyleft"). 00018 * 00019 * Alternatively, this software may be distributed and modified under the 00020 * terms of Quantum Leaps commercial licenses, which expressly supersede 00021 * the GPL and are specifically designed for licensees interested in 00022 * retaining the proprietary status of their code. 00023 * 00024 * Contact information: 00025 * Quantum Leaps Web site: http://www.quantum-leaps.com 00026 * e-mail: info@quantum-leaps.com 00027 *****************************************************************************/ 00028 #ifndef qmpool_h 00029 #define qmpool_h 00030 00040 /****************************************************************************/ 00041 #ifndef QF_MPOOL_SIZ_SIZE 00042 00045 #define QF_MPOOL_SIZ_SIZE 2 00046 #endif 00047 #if (QF_MPOOL_SIZ_SIZE == 1) 00048 00055 typedef uint8_t QMPoolSize; 00056 #elif (QF_MPOOL_SIZ_SIZE == 2) 00057 00058 typedef uint16_t QMPoolSize; 00059 #elif (QF_MPOOL_SIZ_SIZE == 4) 00060 typedef uint32_t QMPoolSize; 00061 #else 00062 #error "QF_MPOOL_SIZ_SIZE defined incorrectly, expected 1, 2, or 4" 00063 #endif 00064 00065 /****************************************************************************/ 00066 #ifndef QF_MPOOL_CTR_SIZE 00067 00070 #define QF_MPOOL_CTR_SIZE 2 00071 #endif 00072 #if (QF_MPOOL_CTR_SIZE == 1) 00073 00080 typedef uint8_t QMPoolCtr; 00081 #elif (QF_MPOOL_CTR_SIZE == 2) 00082 typedef uint16_t QMPoolCtr; 00083 #elif (QF_MPOOL_CTR_SIZE == 4) 00084 typedef uint32_t QMPoolCtr; 00085 #else 00086 #error "QF_MPOOL_CTR_SIZE defined incorrectly, expected 1, 2, or 4" 00087 #endif 00088 00089 /****************************************************************************/ 00103 typedef struct QMPoolTag { 00106 void *free_head; 00107 00110 void *start; 00111 00114 void *end; 00115 00118 QMPoolSize blockSize; 00119 00122 QMPoolCtr nTot; 00123 00126 QMPoolCtr nFree; 00127 00134 QMPoolCtr nMin; 00135 } QMPool; 00136 00137 /* public functions: */ 00138 00157 void QMPool_init(QMPool *me, void *poolSto, 00158 uint32_t poolSize, QMPoolSize blockSize); 00159 00178 void *QMPool_get(QMPool *me); 00179 00197 void QMPool_put(QMPool *me, void *b); 00198 00199 /* friend class QF; */ 00200 00201 #endif /* qmpool_h */ 00202
1.7.6.1