From 7c411bda5ba29eb8fb5be3841626a485c0d650cb Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 14 Sep 2009 14:48:38 +0000 Subject: 2009-09-14 Sebastian Huber * score/src/wkspace.c: Removed work space area consistency checks. * libblock/include/rtems/ide_part_table.h: Functions are now deprecated. * libcsupport/include/rtems/libcsupport.h, libcsupport/src/calloc.c, libcsupport/src/malloc_boundary.c, libcsupport/src/malloc_initialize.c, libcsupport/src/malloc_report_statistics_plugin.c, libcsupport/src/malloc_statistics_helpers.c, libcsupport/src/malloc_walk.c, libcsupport/src/realloc.c, rtems/inline/rtems/rtems/region.inl: Update for heap API changes. 2009-09-14 Christian Mauderer * libcsupport/src/vprintk.c: Fixed warnings. Print nothing in case the pointer to the string is NULL. --- cpukit/ChangeLog | 36 ++++++++++++ cpukit/libblock/include/rtems/ide_part_table.h | 25 +++++++-- cpukit/libcsupport/include/rtems/libcsupport.h | 6 +- cpukit/libcsupport/src/calloc.c | 4 +- cpukit/libcsupport/src/malloc_boundary.c | 16 +++--- cpukit/libcsupport/src/malloc_initialize.c | 65 ++++++++++++---------- .../src/malloc_report_statistics_plugin.c | 5 +- cpukit/libcsupport/src/malloc_statistics_helpers.c | 14 ++--- cpukit/libcsupport/src/malloc_walk.c | 2 +- cpukit/libcsupport/src/realloc.c | 6 +- cpukit/libcsupport/src/vprintk.c | 45 ++++++++------- cpukit/rtems/inline/rtems/rtems/region.inl | 4 +- cpukit/score/src/wkspace.c | 16 +----- 13 files changed, 148 insertions(+), 96 deletions(-) (limited to 'cpukit') diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index ee8574a1ee..b4bfdfe676 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,39 @@ +2009-09-14 Sebastian Huber + + * score/src/wkspace.c: Removed work space area consistency checks. + * libblock/include/rtems/ide_part_table.h: Functions are now + deprecated. + * libcsupport/include/rtems/libcsupport.h, libcsupport/src/calloc.c, + libcsupport/src/malloc_boundary.c, + libcsupport/src/malloc_initialize.c, + libcsupport/src/malloc_report_statistics_plugin.c, + libcsupport/src/malloc_statistics_helpers.c, + libcsupport/src/malloc_walk.c, libcsupport/src/realloc.c, + rtems/inline/rtems/rtems/region.inl: Update for heap API changes. + +2009-09-14 Christian Mauderer + + * libcsupport/src/vprintk.c: Fixed warnings. Print nothing in case the + pointer to the string is NULL. + +2009-09-14 Sebastian Huber + + * score/src/wkspace.c: Removed work space area consistency checks. + * libblock/include/rtems/ide_part_table.h: Functions are now + deprecated. + * libcsupport/include/rtems/libcsupport.h, libcsupport/src/calloc.c, + libcsupport/src/malloc_boundary.c, + libcsupport/src/malloc_initialize.c, + libcsupport/src/malloc_report_statistics_plugin.c, + libcsupport/src/malloc_statistics_helpers.c, + libcsupport/src/malloc_walk.c, libcsupport/src/realloc.c, + rtems/inline/rtems/rtems/region.inl: Update for heap API changes. + +2009-09-14 Christian Mauderer + + * libcsupport/src/vprintk.c: Fixed warnings. Print nothing in case the + pointer to the string is NULL. + 2009-09-13 Joel Sherrill * posix/src/nanosleep.c: Disable EINTR case when POSIX is disabled diff --git a/cpukit/libblock/include/rtems/ide_part_table.h b/cpukit/libblock/include/rtems/ide_part_table.h index b07465b005..ee4dc77ca8 100644 --- a/cpukit/libblock/include/rtems/ide_part_table.h +++ b/cpukit/libblock/include/rtems/ide_part_table.h @@ -165,8 +165,12 @@ extern "C" { * RETURNS: * N/A */ -void -rtems_ide_part_table_free(rtems_disk_desc_t *disk_desc); +/** + * @deprecated Use the @ref rtems_bdpart "block device partition module" instead. + */ +void rtems_ide_part_table_free( + rtems_disk_desc_t *disk_desc +) RTEMS_COMPILER_DEPRECATED_ATTRIBUTE; /* @@ -181,8 +185,13 @@ rtems_ide_part_table_free(rtems_disk_desc_t *disk_desc); * RETURNS: * RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else */ -rtems_status_code -rtems_ide_part_table_get(const char *dev_name, rtems_disk_desc_t *disk_desc); +/** + * @deprecated Use the @ref rtems_bdpart "block device partition module" instead. + */ +rtems_status_code rtems_ide_part_table_get( + const char *dev_name, + rtems_disk_desc_t *disk_desc +) RTEMS_COMPILER_DEPRECATED_ATTRIBUTE; /* @@ -195,8 +204,12 @@ rtems_ide_part_table_get(const char *dev_name, rtems_disk_desc_t *disk_desc); * RETURNS: * RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else */ -rtems_status_code -rtems_ide_part_table_initialize(char *dev_name); +/** + * @deprecated Use the @ref rtems_bdpart "block device partition module" instead. + */ +rtems_status_code rtems_ide_part_table_initialize( + char *dev_name +) RTEMS_COMPILER_DEPRECATED_ATTRIBUTE; #ifdef __cplusplus } diff --git a/cpukit/libcsupport/include/rtems/libcsupport.h b/cpukit/libcsupport/include/rtems/libcsupport.h index 7197df5708..434e56d974 100644 --- a/cpukit/libcsupport/include/rtems/libcsupport.h +++ b/cpukit/libcsupport/include/rtems/libcsupport.h @@ -29,9 +29,9 @@ extern "C" { #include void RTEMS_Malloc_Initialize( - void *start, - size_t length, - size_t sbrk_amount + void *heap_begin, + uintptr_t heap_size, + size_t sbrk_amount ); extern void malloc_dump(void); diff --git a/cpukit/libcsupport/src/calloc.c b/cpukit/libcsupport/src/calloc.c index 2a43736d71..4f51210f91 100644 --- a/cpukit/libcsupport/src/calloc.c +++ b/cpukit/libcsupport/src/calloc.c @@ -25,7 +25,7 @@ void *calloc( ) { register char *cptr; - int length; + size_t length; MSBUMP(calloc_calls, 1); @@ -34,7 +34,7 @@ void *calloc( if ( cptr ) memset( cptr, '\0', length ); - MSBUMP(malloc_calls, -1); /* subtract off the malloc */ + MSBUMP(malloc_calls, (uint32_t) -1); /* subtract off the malloc */ return cptr; } diff --git a/cpukit/libcsupport/src/malloc_boundary.c b/cpukit/libcsupport/src/malloc_boundary.c index 4dd9bb6916..51d6fcc615 100644 --- a/cpukit/libcsupport/src/malloc_boundary.c +++ b/cpukit/libcsupport/src/malloc_boundary.c @@ -57,18 +57,18 @@ struct mallocNode { struct mallocNode mallocNodeHead; -void rtems_malloc_boundary_initialize(void) +static void rtems_malloc_boundary_initialize(void) { mallocNodeHead.back = &mallocNodeHead; mallocNodeHead.forw = &mallocNodeHead; } -uint32_t rtems_malloc_boundary_overhead(void) +static uint32_t rtems_malloc_boundary_overhead(void) { return sizeof(struct mallocNode) + SENTINELSIZE; } -void rtems_malloc_boundary_at_malloc( +static void rtems_malloc_boundary_at_malloc( void *pointer, size_t size ) @@ -99,9 +99,9 @@ void rtems_malloc_boundary_at_malloc( _RTEMS_Unlock_allocator(); } -void reportMallocError(const char *msg, struct mallocNode *mp); +static void reportMallocError(const char *msg, struct mallocNode *mp); -void rtems_malloc_boundary_at_free( +static void rtems_malloc_boundary_at_free( void *pointer ) { @@ -127,7 +127,7 @@ void rtems_malloc_boundary_at_free( _RTEMS_Unlock_allocator(); } -void rtems_malloc_boundary_at_realloc( +static void rtems_malloc_boundary_at_realloc( void *pointer, size_t size ) @@ -149,7 +149,7 @@ rtems_malloc_boundary_functions_t rtems_malloc_boundary_functions_table = { rtems_malloc_boundary_functions_t *rtems_malloc_boundary_helpers = NULL; /* &rtems_malloc_boundary_functions_table; */ -void reportMallocError(const char *msg, struct mallocNode *mp) +static void reportMallocError(const char *msg, struct mallocNode *mp) { unsigned char *sp = (unsigned char *)mp->memory + mp->size; int i, ind = 0; @@ -178,7 +178,7 @@ void reportMallocError(const char *msg, struct mallocNode *mp) printk("\n\n%s\n\n", cbuf); } -void checkMallocArena(void) +static void checkMallocArena(void) { struct mallocNode *mp; diff --git a/cpukit/libcsupport/src/malloc_initialize.c b/cpukit/libcsupport/src/malloc_initialize.c index 0c7c664856..913daf1a27 100644 --- a/cpukit/libcsupport/src/malloc_initialize.c +++ b/cpukit/libcsupport/src/malloc_initialize.c @@ -1,7 +1,10 @@ -/* - * RTEMS Malloc Family Implementation --Initialization - * +/** + * @file * + * @brief Malloc initialization implementation. + */ + +/* * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * @@ -24,9 +27,9 @@ /* FIXME: Dummy function */ #ifndef RTEMS_NEWLIB void RTEMS_Malloc_Initialize( - void *start, - size_t length, - size_t sbrk_amount + void *heap_begin, + uintptr_t heap_size, + size_t sbrk_amount ) { } @@ -35,43 +38,43 @@ rtems_malloc_statistics_t rtems_malloc_statistics; extern bool rtems_unified_work_area; void RTEMS_Malloc_Initialize( - void *start, - size_t length, - size_t sbrk_amount + void *heap_begin, + uintptr_t heap_size, + size_t sbrk_amount ) { - uint32_t status; - void *starting_address; - #if defined(RTEMS_MALLOC_BOUNDARY_HELPERS) /* * If configured, initialize the boundary support */ - if (rtems_malloc_boundary_helpers) + if ( rtems_malloc_boundary_helpers != NULL ) { (*rtems_malloc_boundary_helpers->initialize)(); + } #endif /* * If configured, initialize the statistics support */ - if ( rtems_malloc_statistics_helpers ) + if ( rtems_malloc_statistics_helpers != NULL ) { (*rtems_malloc_statistics_helpers->initialize)(); + } /* * Initialize the garbage collection list to start with nothing on it. */ malloc_deferred_frees_initialize(); - starting_address = start; - /* * Initialize the optional sbrk support for extending the heap */ - if (rtems_malloc_sbrk_helpers) { - starting_address = (*rtems_malloc_sbrk_helpers->initialize)( - start, + if ( rtems_malloc_sbrk_helpers != NULL ) { + void *new_heap_begin = (*rtems_malloc_sbrk_helpers->initialize)( + heap_begin, sbrk_amount ); + + heap_size -= (uintptr_t) new_heap_begin - (uintptr_t) heap_begin; + heap_begin = new_heap_begin; } /* @@ -92,9 +95,12 @@ void RTEMS_Malloc_Initialize( * left over from another process. This would be a security violation. */ - if ( !rtems_unified_work_area && - rtems_configuration_get_do_zero_of_workspace() ) - memset( starting_address, 0, length ); + if ( + !rtems_unified_work_area + && rtems_configuration_get_do_zero_of_workspace() + ) { + memset( heap_begin, 0, heap_size ); + } /* * Unfortunately we cannot use assert if this fails because if this @@ -103,14 +109,15 @@ void RTEMS_Malloc_Initialize( */ if ( !rtems_unified_work_area ) { - status = _Protected_heap_Initialize( + uintptr_t status = _Protected_heap_Initialize( RTEMS_Malloc_Heap, - starting_address, - length, + heap_begin, + heap_size, CPU_HEAP_ALIGNMENT ); - if ( !status ) - rtems_fatal_error_occurred( status ); + if ( status == 0 ) { + rtems_fatal_error_occurred( RTEMS_NO_MEMORY ); + } } MSBUMP( space_available, _Protected_heap_Get_size(RTEMS_Malloc_Heap) ); @@ -118,9 +125,9 @@ void RTEMS_Malloc_Initialize( #if defined(RTEMS_HEAP_DEBUG) if ( _Protected_heap_Walk( RTEMS_Malloc_Heap, 0, false ) ) { printk( "Malloc heap not initialized correctly\n" ); - rtems_print_buffer( start, 32 ); + rtems_print_buffer( heap_begin, 32 ); printk( "\n" ); - rtems_print_buffer( (start + length) - 48, 48 ); + rtems_print_buffer( (heap_begin + heap_size) - 48, 48 ); rtems_fatal_error_occurred( RTEMS_NO_MEMORY ); } #endif diff --git a/cpukit/libcsupport/src/malloc_report_statistics_plugin.c b/cpukit/libcsupport/src/malloc_report_statistics_plugin.c index c89cc46da6..637587190a 100644 --- a/cpukit/libcsupport/src/malloc_report_statistics_plugin.c +++ b/cpukit/libcsupport/src/malloc_report_statistics_plugin.c @@ -25,7 +25,7 @@ void malloc_report_statistics_with_plugin( ) { rtems_malloc_statistics_t *s; - uint32_t allocated; + uintmax_t allocated; s = &rtems_malloc_statistics; @@ -48,9 +48,10 @@ void malloc_report_statistics_with_plugin( ); (*print)( context, - " Call counts: malloc:%"PRIu32" free:%"PRIu32 + " Call counts: malloc:%"PRIu32" memalign:%"PRIu32" free:%"PRIu32 " realloc:%"PRIu32" calloc:%"PRIu32"\n", s->malloc_calls, + s->memalign_calls, s->free_calls, s->realloc_calls, s->calloc_calls diff --git a/cpukit/libcsupport/src/malloc_statistics_helpers.c b/cpukit/libcsupport/src/malloc_statistics_helpers.c index f02a966da2..fcd9a5cbde 100644 --- a/cpukit/libcsupport/src/malloc_statistics_helpers.c +++ b/cpukit/libcsupport/src/malloc_statistics_helpers.c @@ -23,7 +23,7 @@ #include -void rtems_malloc_statistics_initialize( void ) +static void rtems_malloc_statistics_initialize( void ) { /* * Zero all the statistics @@ -31,12 +31,12 @@ void rtems_malloc_statistics_initialize( void ) (void) memset(&rtems_malloc_statistics, 0, sizeof(rtems_malloc_statistics)); } -void rtems_malloc_statistics_at_malloc( +static void rtems_malloc_statistics_at_malloc( void *pointer ) { - intptr_t actual_size = 0; - uint32_t current_depth; + uintptr_t actual_size = 0; + uint32_t current_depth; rtems_malloc_statistics_t *s = &rtems_malloc_statistics; if ( !pointer ) @@ -46,7 +46,7 @@ void rtems_malloc_statistics_at_malloc( MSBUMP(lifetime_allocated, actual_size); - current_depth = s->lifetime_allocated - s->lifetime_freed; + current_depth = (uint32_t) (s->lifetime_allocated - s->lifetime_freed); if (current_depth > s->max_depth) s->max_depth = current_depth; } @@ -55,11 +55,11 @@ void rtems_malloc_statistics_at_malloc( * If the pointer is not in the heap, then we won't be able to get its * size and thus we skip updating the statistics. */ -void rtems_malloc_statistics_at_free( +static void rtems_malloc_statistics_at_free( void *pointer ) { - intptr_t size; + uintptr_t size; if (_Protected_heap_Get_block_size(RTEMS_Malloc_Heap, pointer, &size) ) { MSBUMP(lifetime_freed, size); diff --git a/cpukit/libcsupport/src/malloc_walk.c b/cpukit/libcsupport/src/malloc_walk.c index 9f78a26716..6b6602b2ff 100644 --- a/cpukit/libcsupport/src/malloc_walk.c +++ b/cpukit/libcsupport/src/malloc_walk.c @@ -22,7 +22,7 @@ void malloc_walk(size_t source, size_t printf_enabled) { - _Protected_heap_Walk( RTEMS_Malloc_Heap, source, printf_enabled ); + _Protected_heap_Walk( RTEMS_Malloc_Heap, (int) source, printf_enabled ); } #endif diff --git a/cpukit/libcsupport/src/realloc.c b/cpukit/libcsupport/src/realloc.c index 5a38ac5c91..0f8ec1ee84 100644 --- a/cpukit/libcsupport/src/realloc.c +++ b/cpukit/libcsupport/src/realloc.c @@ -25,9 +25,9 @@ void *realloc( size_t size ) { - intptr_t old_size; + uintptr_t old_size; char *new_area; - intptr_t resize; + uintptr_t resize; MSBUMP(realloc_calls, 1); @@ -88,7 +88,7 @@ void *realloc( new_area = malloc( size ); - MSBUMP(malloc_calls, -1); /* subtract off the malloc */ + MSBUMP(malloc_calls, (uint32_t) -1); /* subtract off the malloc */ if ( !new_area ) { return (void *) 0; diff --git a/cpukit/libcsupport/src/vprintk.c b/cpukit/libcsupport/src/vprintk.c index e7d5d1a59e..883ca387e7 100644 --- a/cpukit/libcsupport/src/vprintk.c +++ b/cpukit/libcsupport/src/vprintk.c @@ -25,11 +25,11 @@ #include static void printNum( - long unsigned int num, - int base, - int sign, - int maxwidth, - int lead + long num, + int base, + int sign, + int maxwidth, + int lead ); /* @@ -46,7 +46,7 @@ void vprintk( va_list ap ) { - char c, *str; + char c; int lflag, base, sign, width, lead, minus; for (; *fmt != '\0'; fmt++) { @@ -80,15 +80,20 @@ void vprintk( c = *++fmt; } if ( c == 'c' ) { - BSP_output_char(va_arg(ap, int)); + char chr = (char) va_arg(ap, int); + BSP_output_char(chr); continue; } if ( c == 's' ) { int i, len; - char *s; + char *s, *str; str = va_arg(ap, char *); + if ( str == NULL ) { + str = ""; + } + /* calculate length of string */ for ( len=0, s=str ; *s ; len++, s++ ) ; @@ -133,7 +138,7 @@ void vprintk( } printNum( - lflag ? va_arg(ap, long int) : (long int)va_arg(ap, int), + lflag ? va_arg(ap, long) : (long) va_arg(ap, int), base, sign, width, @@ -149,16 +154,16 @@ void vprintk( * base - base used to print the number. */ static void printNum( - long unsigned int num, - int base, - int sign, - int maxwidth, - int lead + long num, + int base, + int sign, + int maxwidth, + int lead ) { - long unsigned int n; - int count; - char toPrint[20]; + long n; + int count; + char toPrint[20]; if ( (sign == 1) && ((long)num < 0) ) { BSP_output_char('-'); @@ -168,13 +173,13 @@ static void printNum( count = 0; while ((n = num / base) > 0) { - toPrint[count++] = (num - (n*base)); + toPrint[count++] = (char) (num - (n*base)); num = n; } - toPrint[count++] = num; + toPrint[count++] = (char) num; for (n=maxwidth ; n > count; n-- ) - BSP_output_char(lead); + BSP_output_char((char) lead); for (n = 0; n < count; n++) { BSP_output_char("0123456789ABCDEF"[(int)(toPrint[count-(n+1)])]); diff --git a/cpukit/rtems/inline/rtems/rtems/region.inl b/cpukit/rtems/inline/rtems/rtems/region.inl index be651dc10a..e70891378d 100644 --- a/cpukit/rtems/inline/rtems/rtems/region.inl +++ b/cpukit/rtems/inline/rtems/rtems/region.inl @@ -78,10 +78,10 @@ RTEMS_INLINE_ROUTINE Region_Control *_Region_Get ( */ RTEMS_INLINE_ROUTINE void *_Region_Allocate_segment ( Region_Control *the_region, - intptr_t size + uintptr_t size ) { - return _Heap_Allocate( &the_region->Memory, size ); + return _Heap_Allocate( &the_region->Memory, size ); } /** diff --git a/cpukit/score/src/wkspace.c b/cpukit/score/src/wkspace.c index fe6a4889c0..771b93c2d2 100644 --- a/cpukit/score/src/wkspace.c +++ b/cpukit/score/src/wkspace.c @@ -33,19 +33,9 @@ */ void _Workspace_Handler_initialization(void) { - uint32_t memory_available; - void *starting_address; - size_t size; - - starting_address = Configuration.work_space_start; - size = Configuration.work_space_size; - - if ( !starting_address || !_Addresses_Is_aligned( starting_address ) ) - _Internal_error_Occurred( - INTERNAL_ERROR_CORE, - true, - INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS - ); + uintptr_t memory_available = 0; + void *starting_address = Configuration.work_space_start; + uintptr_t size = Configuration.work_space_size; if ( Configuration.do_zero_of_workspace ) memset( starting_address, 0, size ); -- cgit v1.2.3