diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-08-28 15:10:54 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-08-28 15:10:54 +0000 |
commit | 7ffd1d5e5b41393b518ad0a3b6e94056d9044e26 (patch) | |
tree | 90e9f89b83930f4c6331443d44d663642c20284d /src/chheap.c | |
parent | 7768c51b7b1ef0becc4090705a9bd2f14aa28d00 (diff) | |
download | ChibiOS-7ffd1d5e5b41393b518ad0a3b6e94056d9044e26.tar.gz ChibiOS-7ffd1d5e5b41393b518ad0a3b6e94056d9044e26.tar.bz2 ChibiOS-7ffd1d5e5b41393b518ad0a3b6e94056d9044e26.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@413 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/chheap.c')
-rw-r--r-- | src/chheap.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/chheap.c b/src/chheap.c index dbab1dbd5..0cda7f268 100644 --- a/src/chheap.c +++ b/src/chheap.c @@ -49,7 +49,7 @@ static struct { Mutex hmtx;
#elif defined(CH_USE_SEMAPHORES)
#define H_LOCK() chSemWait(&heap.hsem)
-#define H_UNLOCK() chMtxSignal(&heap.hsem)
+#define H_UNLOCK() chSemSignal(&heap.hsem)
Semaphore hsem;
#else
#error "The heap allocator requires mutexes or semaphores to be enabled"
@@ -181,6 +181,23 @@ void chHeapFree(void *p) { }
}
+/**
+ * Checks if the heap is non-empty and non-fragmented.
+ * @return \p TRUE if the condition is satisfied
+ * @note This function is meant to be used in the test suite, it should not be
+ * really useful for the application code.
+ */
+bool_t chHeapNotFragmented(void) {
+ bool_t b;
+
+ H_LOCK();
+
+ b = (heap.free.h_next != NULL) && (heap.free.h_next->h_next == NULL);
+
+ H_UNLOCK();
+ return b;
+}
+
#else /* CH_USE_MALLOC_HEAP */
#include <stdlib.h>
@@ -191,7 +208,7 @@ void chHeapFree(void *p) { static Mutex hmtx;
#elif defined(CH_USE_SEMAPHORES)
#define H_LOCK() chSemWait(&hsem)
-#define H_UNLOCK() chMtxSignal(&hsem)
+#define H_UNLOCK() chSemSignal(&hsem)
static Semaphore hsem;
#else
#error "The heap allocator requires mutexes or semaphores to be enabled"
@@ -226,6 +243,11 @@ void chHeapFree(void *p) { H_UNLOCK();
}
+bool_t chHeapNotFragmented(void) {
+
+ return FALSE;
+}
+
#endif /* CH_USE_MALLOC_HEAP */
#endif /* CH_USE_HEAP */
|