forked from Imagelibrary/rtems
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user