summaryrefslogtreecommitdiff
path: root/cpukit/rtems/src/workspacegreedy.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-02-17 13:42:51 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-02-17 16:10:17 +0100
commit622d6703d3b332ef56d7691b16d3f74959f6ebf8 (patch)
treec9d81e24446969d5ff51b7bad835c92353b613c3 /cpukit/rtems/src/workspacegreedy.c
parentd6f6dfaa3d90e9c62f4c93ffbda5568de29a1d0f (diff)
Add functions for greedy workspace allocation
Various tests must check program paths that result due to failed memory allocations from the workspace. To avoid tinkering with internal workspace structures throughout the test code these functions should be used.
Diffstat (limited to 'cpukit/rtems/src/workspacegreedy.c')
-rw-r--r--cpukit/rtems/src/workspacegreedy.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/cpukit/rtems/src/workspacegreedy.c b/cpukit/rtems/src/workspacegreedy.c
new file mode 100644
index 0000000000..6d8fd9b937
--- /dev/null
+++ b/cpukit/rtems/src/workspacegreedy.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/rtems/support.h>
+#include <rtems/score/wkspace.h>
+
+void *rtems_workspace_greedy_allocate( size_t remaining_free_space )
+{
+ void *opaque;
+
+ _Thread_Disable_dispatch();
+ opaque = _Heap_Greedy_allocate( &_Workspace_Area, remaining_free_space );
+ _Thread_Enable_dispatch();
+
+ return opaque;
+}
+
+void rtems_workspace_greedy_free( void *opaque )
+{
+ _Thread_Disable_dispatch();
+ _Heap_Greedy_free( &_Workspace_Area, opaque );
+ _Thread_Enable_dispatch();
+}