summaryrefslogtreecommitdiffstats
path: root/cpukit/libdl/rtl-alloc-heap.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2019-02-18 11:46:22 +1100
committerChris Johns <chrisj@rtems.org>2019-02-20 09:08:14 +1100
commit22afb03411133bcf928aeb85233648a94f259b44 (patch)
treee03f9e303646d3efbbce250db37d9566d50ec1c6 /cpukit/libdl/rtl-alloc-heap.c
parentbsps/arm: Move device tree copy (diff)
downloadrtems-22afb03411133bcf928aeb85233648a94f259b44.tar.bz2
libdl/alloc: Add a locking interface to the allocator.
- Allow an allocator to lock the allocations. This is needed to lock the heap allocator so the text and trampoline table are as close together as possible to allow for the largest possible object file size. - Update the default heap allocator to lock the heap allocator. - Update ELF loading to lock the allocator. Updates #3685
Diffstat (limited to 'cpukit/libdl/rtl-alloc-heap.c')
-rw-r--r--cpukit/libdl/rtl-alloc-heap.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/cpukit/libdl/rtl-alloc-heap.c b/cpukit/libdl/rtl-alloc-heap.c
index 4ffdaf23b1..f1bdcca507 100644
--- a/cpukit/libdl/rtl-alloc-heap.c
+++ b/cpukit/libdl/rtl-alloc-heap.c
@@ -17,17 +17,30 @@
#include "rtl-alloc-heap.h"
+#include <rtems/score/apimutex.h>
+
void
rtems_rtl_alloc_heap (rtems_rtl_alloc_cmd cmd,
rtems_rtl_alloc_tag tag,
void** address,
size_t size)
{
- if (cmd == RTEMS_RTL_ALLOC_NEW)
- *address = malloc (size);
- else if (cmd == RTEMS_RTL_ALLOC_DEL)
+ switch (cmd)
{
- free (*address);
- *address = NULL;
+ case RTEMS_RTL_ALLOC_NEW:
+ *address = malloc (size);
+ break;
+ case RTEMS_RTL_ALLOC_DEL:
+ free (*address);
+ *address = NULL;
+ break;
+ case RTEMS_RTL_ALLOC_LOCK:
+ _RTEMS_Lock_allocator();
+ break;
+ case RTEMS_RTL_ALLOC_UNLOCK:
+ _RTEMS_Unlock_allocator();
+ break;
+ default:
+ break;
}
}