mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-25 23:24:59 +08:00
2007-05-03 Joel Sherrill <joel@OARcorp.com>
* ChangeLog, libcsupport/src/malloc.c, libcsupport/src/mallocfreespace.c, sapi/include/confdefs.h, score/Makefile.am, score/preinstall.am: malloc never blocks so the Region Manager is quite heavy for implementing this. This patch implements the C Program Heap directly in terms of the new Protected Heap handler. This handler is a direct use of a SuperCore Heap in conjunction with the Allocator Mutex used internally by RTEMS. This saves 3184 bytes on most SPARC test executables. * score/include/rtems/score/protectedheap.h, score/src/pheapallocate.c, score/src/pheapallocatealigned.c, score/src/pheapextend.c, score/src/pheapfree.c, score/src/pheapgetblocksize.c, score/src/pheapgetfreeinfo.c, score/src/pheapgetinfo.c, score/src/pheapinit.c, score/src/pheapresizeblock.c, score/src/pheapwalk.c: New files.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
|
||||
#include <rtems.h>
|
||||
#include <rtems/libcsupport.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -27,7 +28,7 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
extern rtems_id RTEMS_Malloc_Heap;
|
||||
extern Heap_Control RTEMS_Malloc_Heap;
|
||||
|
||||
/*
|
||||
* Find amount of free heap remaining
|
||||
@@ -35,10 +36,8 @@ extern rtems_id RTEMS_Malloc_Heap;
|
||||
|
||||
size_t malloc_free_space( void )
|
||||
{
|
||||
region_information_block heap_info;
|
||||
Heap_Information info;
|
||||
|
||||
if ( !rtems_region_get_free_information( RTEMS_Malloc_Heap, &heap_info ) ) {
|
||||
return (size_t) heap_info.Free.largest;
|
||||
}
|
||||
return (size_t) -1;
|
||||
_Protected_heap_Get_free_information( &RTEMS_Malloc_Heap, &info );
|
||||
return (size_t) info.largest;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user