mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 20:56:59 +08:00
libcsupport: Adjust malloc_walk() prototype
The header file <rtems/malloc.h> provides now also the malloc_walk() prototype. The malloc_walk() prototype reflects now the _Protected_heap_Walk() API. The return status helps to print only in case of an error.
This commit is contained in:
@@ -34,7 +34,7 @@ void RTEMS_Malloc_Initialize(
|
||||
);
|
||||
|
||||
extern void malloc_dump(void);
|
||||
extern void malloc_walk(size_t source, size_t printf_enabled);
|
||||
extern bool malloc_walk(int source, bool printf_enabled);
|
||||
void malloc_set_heap_pointer(Heap_Control *new_heap);
|
||||
Heap_Control *malloc_get_heap_pointer( void );
|
||||
extern void libc_init(void);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/bspIo.h>
|
||||
#include <rtems/libcsupport.h> /* for malloc_walk() */
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void malloc_walk(size_t source, size_t printf_enabled)
|
||||
bool malloc_walk(int source, bool printf_enabled)
|
||||
{
|
||||
_Protected_heap_Walk( RTEMS_Malloc_Heap, (int) source, printf_enabled );
|
||||
return _Protected_heap_Walk( RTEMS_Malloc_Heap, source, printf_enabled );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -34,10 +34,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <errno.h>
|
||||
#include <rtems/score/protectedheap.h>
|
||||
|
||||
/* HACK: Blatant visibility violations */
|
||||
extern int malloc_info(Heap_Information_block *the_info);
|
||||
extern void malloc_walk(size_t source, size_t printf_enabled);
|
||||
#include <rtems/malloc.h>
|
||||
|
||||
/*
|
||||
* A simple test of realloc
|
||||
@@ -47,6 +44,7 @@ static void test_realloc(void)
|
||||
void *p1, *p2, *p3, *p4;
|
||||
size_t i;
|
||||
int sc;
|
||||
bool malloc_walk_ok;
|
||||
|
||||
/* Test growing reallocation "in place" */
|
||||
p1 = malloc(1);
|
||||
@@ -103,11 +101,13 @@ static void test_realloc(void)
|
||||
* Walk the C Program Heap
|
||||
*/
|
||||
puts( "malloc_walk - normal path" );
|
||||
malloc_walk( 1234, 0 );
|
||||
malloc_walk_ok = malloc_walk( 1234, false );
|
||||
rtems_test_assert( malloc_walk_ok );
|
||||
|
||||
puts( "malloc_walk - in critical section path" );
|
||||
_Thread_Disable_dispatch();
|
||||
malloc_walk( 1234, 0 );
|
||||
malloc_walk_ok = malloc_walk( 1234, false );
|
||||
rtems_test_assert( malloc_walk_ok );
|
||||
_Thread_Enable_dispatch();
|
||||
|
||||
/*
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* HACK: Blatant visibility violation */
|
||||
extern void malloc_walk(size_t source, size_t printf_enabled);
|
||||
|
||||
#define NUM_PASSES 100
|
||||
|
||||
rtems_task Task_1_through_5(
|
||||
@@ -42,6 +39,8 @@ rtems_task Task_1_through_5(
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
bool malloc_walk_ok;
|
||||
|
||||
if ( passes++ > NUM_PASSES ) {
|
||||
puts("*** END OF MALLOC TEST ***");
|
||||
rtems_test_exit(0);
|
||||
@@ -61,7 +60,8 @@ rtems_task Task_1_through_5(
|
||||
printf("mallocing %d bytes\n",mem_amt);
|
||||
memset( mem_ptr, mem_amt, mem_amt );
|
||||
malloc_report_statistics();
|
||||
malloc_walk(1,FALSE);
|
||||
malloc_walk_ok = malloc_walk( 1, false );
|
||||
rtems_test_assert( malloc_walk_ok );
|
||||
status = rtems_task_wake_after(
|
||||
task_number( tid ) * 1 * rtems_clock_get_ticks_per_second()/4 );
|
||||
for (i=0; i < mem_amt; i++)
|
||||
|
||||
Reference in New Issue
Block a user