From 4c09f4b3fefc7ba5c5868a97ad00c1ee14a06677 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 2 Oct 2008 20:56:55 +0000 Subject: 2008-10-02 Joel Sherrill * libcsupport/src/malloc_statistics_helpers.c, libcsupport/src/realloc.c, rtems/include/rtems/rtems/region.h, rtems/include/rtems/rtems/support.h, rtems/src/regiongetsegmentsize.c, rtems/src/regionresizesegment.c, rtems/src/workspace.c, sapi/include/confdefs.h, score/include/rtems/score/heap.h, score/include/rtems/score/protectedheap.h, score/include/rtems/score/wkspace.h, score/src/heap.c, score/src/heapallocate.c, score/src/heapallocatealigned.c, score/src/heapextend.c, score/src/heapresizeblock.c, score/src/heapsizeofuserarea.c, score/src/pheapgetblocksize.c, score/src/wkspace.c: Change size_t to ssize_t on all Heap, Workspace and Region calls. On 16-bit architectures, size_t can be 16-bits which would limit sizes to 64K. --- cpukit/ChangeLog | 17 +++++++++++++++++ cpukit/libcsupport/src/malloc_statistics_helpers.c | 4 ++-- cpukit/libcsupport/src/realloc.c | 6 +++--- cpukit/rtems/include/rtems/rtems/region.h | 6 +++--- cpukit/rtems/include/rtems/rtems/support.h | 4 ++-- cpukit/rtems/src/regiongetsegmentsize.c | 2 +- cpukit/rtems/src/regionresizesegment.c | 4 ++-- cpukit/rtems/src/workspace.c | 4 ++-- cpukit/sapi/include/confdefs.h | 2 +- cpukit/score/include/rtems/score/heap.h | 18 ++++++++++-------- cpukit/score/include/rtems/score/protectedheap.h | 4 ++-- cpukit/score/include/rtems/score/wkspace.h | 6 +++--- cpukit/score/src/heap.c | 11 +++++------ cpukit/score/src/heapallocate.c | 2 +- cpukit/score/src/heapallocatealigned.c | 2 +- cpukit/score/src/heapextend.c | 2 +- cpukit/score/src/heapresizeblock.c | 2 +- cpukit/score/src/heapsizeofuserarea.c | 2 +- cpukit/score/src/pheapgetblocksize.c | 2 +- cpukit/score/src/wkspace.c | 6 +++--- 20 files changed, 62 insertions(+), 44 deletions(-) diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 75a0917e88..72c41c57b5 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,20 @@ +2008-10-02 Joel Sherrill + + * libcsupport/src/malloc_statistics_helpers.c, + libcsupport/src/realloc.c, rtems/include/rtems/rtems/region.h, + rtems/include/rtems/rtems/support.h, + rtems/src/regiongetsegmentsize.c, rtems/src/regionresizesegment.c, + rtems/src/workspace.c, sapi/include/confdefs.h, + score/include/rtems/score/heap.h, + score/include/rtems/score/protectedheap.h, + score/include/rtems/score/wkspace.h, score/src/heap.c, + score/src/heapallocate.c, score/src/heapallocatealigned.c, + score/src/heapextend.c, score/src/heapresizeblock.c, + score/src/heapsizeofuserarea.c, score/src/pheapgetblocksize.c, + score/src/wkspace.c: Change size_t to ssize_t on all Heap, Workspace + and Region calls. On 16-bit architectures, size_t can be 16-bits + which would limit sizes to 64K. + 2008-10-02 Joel Sherrill * libmisc/shell/main_cp.c, libmisc/shell/main_ls.c, diff --git a/cpukit/libcsupport/src/malloc_statistics_helpers.c b/cpukit/libcsupport/src/malloc_statistics_helpers.c index 5d02f8b822..e65ab81cc2 100644 --- a/cpukit/libcsupport/src/malloc_statistics_helpers.c +++ b/cpukit/libcsupport/src/malloc_statistics_helpers.c @@ -35,7 +35,7 @@ void rtems_malloc_statistics_at_malloc( void *pointer ) { - size_t actual_size = 0; + ssize_t actual_size = 0; uint32_t current_depth; rtems_malloc_statistics_t *s = &rtems_malloc_statistics; @@ -59,7 +59,7 @@ void rtems_malloc_statistics_at_free( void *pointer ) { - size_t size; + ssize_t size; if (_Protected_heap_Get_block_size(RTEMS_Malloc_Heap, pointer, &size) ) { MSBUMP(lifetime_freed, size); diff --git a/cpukit/libcsupport/src/realloc.c b/cpukit/libcsupport/src/realloc.c index 9e96948994..cff5725f3c 100644 --- a/cpukit/libcsupport/src/realloc.c +++ b/cpukit/libcsupport/src/realloc.c @@ -25,9 +25,9 @@ void *realloc( size_t size ) { - size_t old_size; - char *new_area; - size_t resize; + ssize_t old_size; + char *new_area; + ssize_t resize; MSBUMP(realloc_calls, 1); diff --git a/cpukit/rtems/include/rtems/rtems/region.h b/cpukit/rtems/include/rtems/rtems/region.h index 7f071bfcb5..20da771121 100644 --- a/cpukit/rtems/include/rtems/rtems/region.h +++ b/cpukit/rtems/include/rtems/rtems/region.h @@ -240,7 +240,7 @@ rtems_status_code rtems_region_get_segment( rtems_status_code rtems_region_get_segment_size( Objects_Id id, void *segment, - size_t *size + ssize_t *size ); /** @@ -282,8 +282,8 @@ rtems_status_code rtems_region_return_segment( rtems_status_code rtems_region_resize_segment( Objects_Id id, void *segment, - size_t size, - size_t *old_size + ssize_t size, + ssize_t *old_size ); #ifndef __RTEMS_APPLICATION__ diff --git a/cpukit/rtems/include/rtems/rtems/support.h b/cpukit/rtems/include/rtems/rtems/support.h index 25f6ebf08d..8364bdca91 100644 --- a/cpukit/rtems/include/rtems/rtems/support.h +++ b/cpukit/rtems/include/rtems/rtems/support.h @@ -79,8 +79,8 @@ bool rtems_workspace_get_information( * @return TRUE if successful */ bool rtems_workspace_allocate( - size_t bytes, - void **pointer + ssize_t bytes, + void **pointer ); /** diff --git a/cpukit/rtems/src/regiongetsegmentsize.c b/cpukit/rtems/src/regiongetsegmentsize.c index 7d70b6188b..53c91808aa 100644 --- a/cpukit/rtems/src/regiongetsegmentsize.c +++ b/cpukit/rtems/src/regiongetsegmentsize.c @@ -45,7 +45,7 @@ rtems_status_code rtems_region_get_segment_size( Objects_Id id, void *segment, - size_t *size + ssize_t *size ) { Objects_Locations location; diff --git a/cpukit/rtems/src/regionresizesegment.c b/cpukit/rtems/src/regionresizesegment.c index 43cb302afd..0f031a737a 100644 --- a/cpukit/rtems/src/regionresizesegment.c +++ b/cpukit/rtems/src/regionresizesegment.c @@ -46,8 +46,8 @@ rtems_status_code rtems_region_resize_segment( Objects_Id id, void *segment, - size_t size, - size_t *old_size + ssize_t size, + ssize_t *old_size ) { uint32_t avail_size; diff --git a/cpukit/rtems/src/workspace.c b/cpukit/rtems/src/workspace.c index f573440475..c7405bcf32 100644 --- a/cpukit/rtems/src/workspace.c +++ b/cpukit/rtems/src/workspace.c @@ -39,8 +39,8 @@ bool rtems_workspace_get_information( * _Workspace_Allocate */ bool rtems_workspace_allocate( - size_t bytes, - void **pointer + ssize_t bytes, + void **pointer ) { *pointer = _Heap_Allocate( &_Workspace_Area, bytes ); diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h index 35404162dc..d96f2bb3ef 100644 --- a/cpukit/sapi/include/confdefs.h +++ b/cpukit/sapi/include/confdefs.h @@ -449,7 +449,7 @@ rtems_fs_init_functions_t rtems_fs_init_helper = * may be applied. */ #define _Configure_From_workspace(_size) \ - ((_size) + (2 * sizeof(uint32_t)) + CPU_ALIGNMENT) + (ssize_t)((_size) + (2 * sizeof(uint32_t)) + CPU_ALIGNMENT) /** * This macro accounts for how memory for a set of configured objects is diff --git a/cpukit/score/include/rtems/score/heap.h b/cpukit/score/include/rtems/score/heap.h index 0587852d78..78c15522fd 100644 --- a/cpukit/score/include/rtems/score/heap.h +++ b/cpukit/score/include/rtems/score/heap.h @@ -31,6 +31,8 @@ #ifndef _RTEMS_SCORE_HEAP_H #define _RTEMS_SCORE_HEAP_H +#include + /** * @defgroup ScoreHeap Heap Handler * @@ -262,7 +264,7 @@ typedef struct { uint32_t _Heap_Initialize( Heap_Control *the_heap, void *starting_address, - size_t size, + ssize_t size, uint32_t page_size ); @@ -281,7 +283,7 @@ uint32_t _Heap_Initialize( Heap_Extend_status _Heap_Extend( Heap_Control *the_heap, void *starting_address, - size_t size, + ssize_t size, uint32_t *amount_extended ); @@ -296,7 +298,7 @@ Heap_Extend_status _Heap_Extend( */ void *_Heap_Allocate( Heap_Control *the_heap, - size_t size + ssize_t size ); /** @@ -315,7 +317,7 @@ void *_Heap_Allocate( */ void *_Heap_Allocate_aligned( Heap_Control *the_heap, - size_t size, + ssize_t size, uint32_t alignment ); @@ -336,7 +338,7 @@ void *_Heap_Allocate_aligned( bool _Heap_Size_of_user_area( Heap_Control *the_heap, void *starting_address, - size_t *size + ssize_t *size ); /** @@ -364,7 +366,7 @@ bool _Heap_Size_of_user_area( Heap_Resize_status _Heap_Resize_block( Heap_Control *the_heap, void *starting_address, - size_t size, + ssize_t size, uint32_t *old_mem_size, uint32_t *avail_mem_size ); @@ -449,8 +451,8 @@ void _Heap_Get_free_information( * * @return This method returns block size on success, 0 if overflow occured. */ -extern size_t _Heap_Calc_block_size( - size_t size, +extern ssize_t _Heap_Calc_block_size( + ssize_t size, uint32_t page_size, uint32_t min_size ); diff --git a/cpukit/score/include/rtems/score/protectedheap.h b/cpukit/score/include/rtems/score/protectedheap.h index 78c2abc3d2..508e548354 100644 --- a/cpukit/score/include/rtems/score/protectedheap.h +++ b/cpukit/score/include/rtems/score/protectedheap.h @@ -54,7 +54,7 @@ extern "C" { static inline uint32_t _Protected_heap_Initialize( Heap_Control *the_heap, void *starting_address, - size_t size, + ssize_t size, uint32_t page_size ) { @@ -128,7 +128,7 @@ void *_Protected_heap_Allocate_aligned( bool _Protected_heap_Get_block_size( Heap_Control *the_heap, void *starting_address, - size_t *size + ssize_t *size ); /** diff --git a/cpukit/score/include/rtems/score/wkspace.h b/cpukit/score/include/rtems/score/wkspace.h index b4047c56fa..36fa34b420 100644 --- a/cpukit/score/include/rtems/score/wkspace.h +++ b/cpukit/score/include/rtems/score/wkspace.h @@ -52,7 +52,7 @@ SCORE_EXTERN Heap_Control _Workspace_Area; /* executive heap header */ */ void _Workspace_Handler_initialization( void *starting_address, - size_t size + ssize_t size ); /** @brief Allocate Memory from Workspace @@ -66,7 +66,7 @@ void _Workspace_Handler_initialization( * @return a pointer to the requested memory or NULL. */ void *_Workspace_Allocate( - size_t size + ssize_t size ); /** @brief Free Memory to the Workspace @@ -94,7 +94,7 @@ bool _Workspace_Free( * @return If successful, the starting address of the allocated memory */ void *_Workspace_Allocate_or_fatal_error( - size_t size + ssize_t size ); #ifndef __RTEMS_APPLICATION__ diff --git a/cpukit/score/src/heap.c b/cpukit/score/src/heap.c index 042dc6d604..8c55b06ecd 100644 --- a/cpukit/score/src/heap.c +++ b/cpukit/score/src/heap.c @@ -111,11 +111,10 @@ static uint32_t instance = 0; * +--------------------------------+ <- end = begin + size * */ - uint32_t _Heap_Initialize( Heap_Control *the_heap, void *starting_address, - size_t size, + ssize_t size, uint32_t page_size ) { @@ -207,10 +206,10 @@ uint32_t _Heap_Initialize( * Convert user requested 'size' of memory block to the block size. * Return block size on success, 0 if overflow occured */ -size_t _Heap_Calc_block_size( - size_t size, - uint32_t page_size, - uint32_t min_size) +ssize_t _Heap_Calc_block_size( + ssize_t size, + uint32_t page_size, + uint32_t min_size) { uint32_t block_size = size + HEAP_BLOCK_USED_OVERHEAD; _Heap_Align_up(&block_size, page_size); diff --git a/cpukit/score/src/heapallocate.c b/cpukit/score/src/heapallocate.c index 418ee758fc..6432556fc5 100644 --- a/cpukit/score/src/heapallocate.c +++ b/cpukit/score/src/heapallocate.c @@ -36,7 +36,7 @@ void *_Heap_Allocate( Heap_Control *the_heap, - size_t size + ssize_t size ) { uint32_t the_size; diff --git a/cpukit/score/src/heapallocatealigned.c b/cpukit/score/src/heapallocatealigned.c index 3fda404490..6ac1425063 100644 --- a/cpukit/score/src/heapallocatealigned.c +++ b/cpukit/score/src/heapallocatealigned.c @@ -131,7 +131,7 @@ Heap_Block *block_allocate( void *_Heap_Allocate_aligned( Heap_Control *the_heap, - size_t size, + ssize_t size, uint32_t alignment ) { diff --git a/cpukit/score/src/heapextend.c b/cpukit/score/src/heapextend.c index 73eb91f127..0e0329f4e6 100644 --- a/cpukit/score/src/heapextend.c +++ b/cpukit/score/src/heapextend.c @@ -38,7 +38,7 @@ Heap_Extend_status _Heap_Extend( Heap_Control *the_heap, void *starting_address, - size_t size, + ssize_t size, uint32_t *amount_extended ) { diff --git a/cpukit/score/src/heapresizeblock.c b/cpukit/score/src/heapresizeblock.c index 49460f9767..760d49bc39 100644 --- a/cpukit/score/src/heapresizeblock.c +++ b/cpukit/score/src/heapresizeblock.c @@ -47,7 +47,7 @@ Heap_Resize_status _Heap_Resize_block( Heap_Control *the_heap, void *starting_address, - size_t size, + ssize_t size, uint32_t *old_mem_size, uint32_t *avail_mem_size ) diff --git a/cpukit/score/src/heapsizeofuserarea.c b/cpukit/score/src/heapsizeofuserarea.c index c1555d2ccc..136389e878 100644 --- a/cpukit/score/src/heapsizeofuserarea.c +++ b/cpukit/score/src/heapsizeofuserarea.c @@ -42,7 +42,7 @@ bool _Heap_Size_of_user_area( Heap_Control *the_heap, void *starting_address, - size_t *size + ssize_t *size ) { Heap_Block *the_block; diff --git a/cpukit/score/src/pheapgetblocksize.c b/cpukit/score/src/pheapgetblocksize.c index 029ef7b2c7..6baa8f5632 100644 --- a/cpukit/score/src/pheapgetblocksize.c +++ b/cpukit/score/src/pheapgetblocksize.c @@ -19,7 +19,7 @@ bool _Protected_heap_Get_block_size( Heap_Control *the_heap, void *starting_address, - size_t *size + ssize_t *size ) { bool status; diff --git a/cpukit/score/src/wkspace.c b/cpukit/score/src/wkspace.c index ebb71f3297..591427cb64 100644 --- a/cpukit/score/src/wkspace.c +++ b/cpukit/score/src/wkspace.c @@ -27,7 +27,7 @@ */ void _Workspace_Handler_initialization( void *starting_address, - size_t size + ssize_t size ) { uint32_t memory_available; @@ -61,7 +61,7 @@ void _Workspace_Handler_initialization( * _Workspace_Allocate */ void *_Workspace_Allocate( - size_t size + ssize_t size ) { return _Heap_Allocate( &_Workspace_Area, size ); @@ -81,7 +81,7 @@ bool _Workspace_Free( * _Workspace_Allocate_or_fatal_error */ void *_Workspace_Allocate_or_fatal_error( - size_t size + ssize_t size ) { void *memory; -- cgit v1.2.3