|
ChibiOS/RT
2.5.1 |
00001 /* 00002 ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, 00003 2011,2012 Giovanni Di Sirio. 00004 00005 This file is part of ChibiOS/RT. 00006 00007 ChibiOS/RT is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 ChibiOS/RT is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 /** 00022 * @file chmemcore.h 00023 * @brief Core memory manager macros and structures. 00024 * 00025 * @addtogroup memcore 00026 * @{ 00027 */ 00028 00029 #ifndef _CHMEMCORE_H_ 00030 #define _CHMEMCORE_H_ 00031 00032 /** 00033 * @brief Memory get function. 00034 * @note This type must be assignment compatible with the @p chMemAlloc() 00035 * function. 00036 */ 00037 typedef void *(*memgetfunc_t)(size_t size); 00038 00039 /** 00040 * @name Alignment support macros 00041 */ 00042 /** 00043 * @brief Alignment size constant. 00044 */ 00045 #define MEM_ALIGN_SIZE sizeof(stkalign_t) 00046 00047 /** 00048 * @brief Alignment mask constant. 00049 */ 00050 #define MEM_ALIGN_MASK (MEM_ALIGN_SIZE - 1) 00051 00052 /** 00053 * @brief Alignment helper macro. 00054 */ 00055 #define MEM_ALIGN_PREV(p) ((size_t)(p) & ~MEM_ALIGN_MASK) 00056 00057 /** 00058 * @brief Alignment helper macro. 00059 */ 00060 #define MEM_ALIGN_NEXT(p) MEM_ALIGN_PREV((size_t)(p) + MEM_ALIGN_MASK) 00061 00062 /** 00063 * @brief Returns whatever a pointer or memory size is aligned to 00064 * the type @p align_t. 00065 */ 00066 #define MEM_IS_ALIGNED(p) (((size_t)(p) & MEM_ALIGN_MASK) == 0) 00067 /** @} */ 00068 00069 #if CH_USE_MEMCORE || defined(__DOXYGEN__) 00070 00071 #ifdef __cplusplus 00072 extern "C" { 00073 #endif 00074 void _core_init(void); 00075 void *chCoreAlloc(size_t size); 00076 void *chCoreAllocI(size_t size); 00077 size_t chCoreStatus(void); 00078 #ifdef __cplusplus 00079 } 00080 #endif 00081 00082 #endif /* CH_USE_MEMCORE */ 00083 00084 #endif /* _CHMEMCORE_H_ */ 00085 00086 /** @} */