2007-12-19 Joel Sherrill <joel.sherrill@OARcorp.com>

* malloctest/init.c, malloctest/task1.c: Add test for posix_memalign.
This commit is contained in:
Joel Sherrill
2007-12-19 16:05:32 +00:00
parent 8e30a269a2
commit e1a22c112c
3 changed files with 47 additions and 3 deletions

View File

@@ -1,3 +1,7 @@
2007-12-19 Joel Sherrill <joel.sherrill@OARcorp.com>
* malloctest/init.c, malloctest/task1.c: Add test for posix_memalign.
2007-12-14 Joel Sherrill <joel.sherrill@OARcorp.com>
* rtmonuse/init.c, rtmonuse/task1.c: Add period which is unused to

View File

@@ -24,6 +24,9 @@
#define TEST_INIT
#include "system.h"
#include <stdlib.h>
#include <errno.h>
/*
* A simple test of realloc
*/
@@ -39,6 +42,41 @@ void test_realloc(void)
free(p2);
}
/*
* A simple test of posix_memalign
*/
void test_posix_memalign(void)
{
void *p1, *p2;
int i;
int sc;
puts( "posix_memalign - NULL return pointer -- EINVAL" );
sc = posix_memalign( NULL, 32, 8 );
fatal_posix_service_status( sc, EINVAL, "posix_memalign NULL pointer" );
puts( "posix_memalign - alignment of 0 -- EINVAL" );
sc = posix_memalign( &p1, 0, 8 );
fatal_posix_service_status( sc, EINVAL, "posix_memalign alignment of 0" );
puts( "posix_memalign - alignment of 2-- EINVAL" );
sc = posix_memalign( &p1, 2, 8 );
fatal_posix_service_status( sc, EINVAL, "posix_memalign alignment of 2" );
for ( i=2 ; i<32 ; i++ ) {
printf( "posix_memalign - alignment of %d -- OK\n", 1 << i );
sc = posix_memalign( &p1, 1 << i, 8 );
if ( sc == ENOMEM ) {
printf( "posix_memalign - ran out of memory trying %d\n", 1<<i );
break;
}
posix_service_failed( sc, "posix_memalign alignment OK" );
free( p1 );
}
}
rtems_task Init(
rtems_task_argument argument
)
@@ -54,6 +92,8 @@ rtems_task Init(
test_realloc();
test_posix_memalign();
Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );

View File

@@ -14,8 +14,8 @@
*/
#include "system.h"
#include <rtems/libcsupport.h> /* for malloc_dump, malloc_walk */
#include <string.h> /* for memset */
#include <rtems/malloc.h>
#include <string.h>
#include <stdlib.h>
#define NUM_PASSES 100
@@ -55,7 +55,7 @@ rtems_task Task_1_through_5(
}
printf("mallocing %d bytes\n",mem_amt);
memset( mem_ptr, mem_amt, mem_amt );
malloc_dump();
malloc_report_statistics();
malloc_walk(1,FALSE);
status = rtems_task_wake_after( task_number( tid ) * 1 * TICKS_PER_SECOND/4 );
for (i=0; i < mem_amt; i++)