aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel/include
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-10-17 09:21:59 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-10-17 09:21:59 +0000
commit34fd822f84d409fa649934251fae01994de7888b (patch)
tree095f9c11f7aa2e5f2c0b451c1ba15b08d76f5c47 /os/kernel/include
parenta7cfbdaf10a03aa10236958bdba38479b301fc4f (diff)
downloadChibiOS-34fd822f84d409fa649934251fae01994de7888b.tar.gz
ChibiOS-34fd822f84d409fa649934251fae01994de7888b.tar.bz2
ChibiOS-34fd822f84d409fa649934251fae01994de7888b.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1226 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel/include')
-rw-r--r--os/kernel/include/memcore.h12
-rw-r--r--os/kernel/include/mempools.h22
2 files changed, 26 insertions, 8 deletions
diff --git a/os/kernel/include/memcore.h b/os/kernel/include/memcore.h
index 8f3fe4671..c60d3ad9d 100644
--- a/os/kernel/include/memcore.h
+++ b/os/kernel/include/memcore.h
@@ -27,10 +27,8 @@
#ifndef _MEMCORE_H_
#define _MEMCORE_H_
-#if CH_USE_MEMCORE
-
/**
- * @brief Memory alignment type.
+ * @brief Memory alignment type.
*/
typedef void *align_t;
@@ -42,21 +40,23 @@ typedef void *align_t;
typedef void *(*memgetfunc_t)(size_t size);
/**
- * @brief Alignment mask constant.
+ * @brief Alignment mask constant.
*/
#define MEM_ALIGN_MASK (sizeof(align_t) - 1)
/**
- * @brief Alignment helper macro.
+ * @brief Alignment helper macro.
*/
#define MEM_ALIGN_SIZE(p) (((size_t)(p) + MEM_ALIGN_MASK) & ~MEM_ALIGN_MASK)
/**
* @brief Returns whatever a pointer or memory size is aligned to
- * the type @p align_t.
+ * the type @p align_t.
*/
#define MEM_IS_ALIGNED(p) (((size_t)(p) & MEM_ALIGN_MASK) == 0)
+#if CH_USE_MEMCORE
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/os/kernel/include/mempools.h b/os/kernel/include/mempools.h
index 38279c388..d5e612426 100644
--- a/os/kernel/include/mempools.h
+++ b/os/kernel/include/mempools.h
@@ -40,14 +40,19 @@ struct pool_header {
* @brief Memory pool descriptor.
*/
typedef struct {
- struct pool_header *mp_next; /**< Pointer to the header.*/
- size_t mp_object_size; /**< Memory pool objects size.*/
+ struct pool_header *mp_next; /**< Pointer to the header. */
+ size_t mp_object_size; /**< Memory pool objects size. */
+#if CH_USE_MEMCORE
+ bool_t mp_usecore; /**< Feed from the memory code
+ allocator if empty. */
+#endif
} MemoryPool;
/**
* @brief Data part of a static memory pool initializer.
* @details This macro should be used when statically initializing a
* memory pool that is part of a bigger structure.
+ *
* @param name the name of the memory pool variable
* @param size size of the memory pool contained objects
*/
@@ -57,12 +62,25 @@ typedef struct {
* @brief Static memory pool initializer.
* @details Statically initialized memory pools require no explicit
* initialization using @p chPoolInit().
+ *
* @param name the name of the memory pool variable
* @param size size of the memory pool contained objects
*/
#define MEMORYPOOL_DECL(name, size) \
MemoryPool name = _MEMORYPOOL_DATA(name, size)
+#if CH_USE_MEMCORE || defined(__DOXYGEN__)
+/**
+ * @brief Enables or disables the hungry mode.
+ * @details If enabled, the hungry mode, makes an empty memory pool feed
+ * new objects from the core memory manager.
+ *
+ * @param[in] mp pointer to a @p MemoryPool structure
+ * @param[in] mode hungry mode flag
+ */
+#define chPoolSetHungryMode(mp, mode) ((mp)->mp_usecore = (mode))
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif