2008-11-20 Joel Sherrill <joel.sherrill@oarcorp.com>

* 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: Revert use of ssize_t. This type is not
	guaranteed to be able to represent a positive number greater than the
	size of a single allocatable object. We needed a type that is able to
	represent the size of a pool of multiple allocatable objects or
	potentially nearly all memory.
This commit is contained in:
Joel Sherrill
2008-11-20 20:01:13 +00:00
parent bd59b348c6
commit 7ff6115b8b
12 changed files with 42 additions and 29 deletions

View File

@@ -1,3 +1,17 @@
2008-11-20 Joel Sherrill <joel.sherrill@oarcorp.com>
* 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: Revert use of ssize_t. This type is not
guaranteed to be able to represent a positive number greater than the
size of a single allocatable object. We needed a type that is able to
represent the size of a pool of multiple allocatable objects or
potentially nearly all memory.
2008-11-20 Joel Sherrill <joel.sherrill@oarcorp.com> 2008-11-20 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/src/newlibc_exit.c, score/src/threadhandler.c: Do not * libcsupport/src/newlibc_exit.c, score/src/threadhandler.c: Do not

View File

@@ -31,8 +31,6 @@
#ifndef _RTEMS_SCORE_HEAP_H #ifndef _RTEMS_SCORE_HEAP_H
#define _RTEMS_SCORE_HEAP_H #define _RTEMS_SCORE_HEAP_H
#include <sys/types.h>
/** /**
* @defgroup ScoreHeap Heap Handler * @defgroup ScoreHeap Heap Handler
* *
@@ -264,7 +262,7 @@ typedef struct {
uint32_t _Heap_Initialize( uint32_t _Heap_Initialize(
Heap_Control *the_heap, Heap_Control *the_heap,
void *starting_address, void *starting_address,
ssize_t size, size_t size,
uint32_t page_size uint32_t page_size
); );
@@ -283,7 +281,7 @@ uint32_t _Heap_Initialize(
Heap_Extend_status _Heap_Extend( Heap_Extend_status _Heap_Extend(
Heap_Control *the_heap, Heap_Control *the_heap,
void *starting_address, void *starting_address,
ssize_t size, size_t size,
uint32_t *amount_extended uint32_t *amount_extended
); );
@@ -298,7 +296,7 @@ Heap_Extend_status _Heap_Extend(
*/ */
void *_Heap_Allocate( void *_Heap_Allocate(
Heap_Control *the_heap, Heap_Control *the_heap,
ssize_t size size_t size
); );
/** /**
@@ -317,7 +315,7 @@ void *_Heap_Allocate(
*/ */
void *_Heap_Allocate_aligned( void *_Heap_Allocate_aligned(
Heap_Control *the_heap, Heap_Control *the_heap,
ssize_t size, size_t size,
uint32_t alignment uint32_t alignment
); );
@@ -338,7 +336,7 @@ void *_Heap_Allocate_aligned(
bool _Heap_Size_of_user_area( bool _Heap_Size_of_user_area(
Heap_Control *the_heap, Heap_Control *the_heap,
void *starting_address, void *starting_address,
ssize_t *size size_t *size
); );
/** /**
@@ -366,7 +364,7 @@ bool _Heap_Size_of_user_area(
Heap_Resize_status _Heap_Resize_block( Heap_Resize_status _Heap_Resize_block(
Heap_Control *the_heap, Heap_Control *the_heap,
void *starting_address, void *starting_address,
ssize_t size, size_t size,
uint32_t *old_mem_size, uint32_t *old_mem_size,
uint32_t *avail_mem_size uint32_t *avail_mem_size
); );
@@ -451,8 +449,8 @@ void _Heap_Get_free_information(
* *
* @return This method returns block size on success, 0 if overflow occured. * @return This method returns block size on success, 0 if overflow occured.
*/ */
extern ssize_t _Heap_Calc_block_size( extern size_t _Heap_Calc_block_size(
ssize_t size, size_t size,
uint32_t page_size, uint32_t page_size,
uint32_t min_size uint32_t min_size
); );

View File

@@ -54,7 +54,7 @@ extern "C" {
static inline uint32_t _Protected_heap_Initialize( static inline uint32_t _Protected_heap_Initialize(
Heap_Control *the_heap, Heap_Control *the_heap,
void *starting_address, void *starting_address,
ssize_t size, size_t size,
uint32_t page_size uint32_t page_size
) )
{ {
@@ -128,7 +128,7 @@ void *_Protected_heap_Allocate_aligned(
bool _Protected_heap_Get_block_size( bool _Protected_heap_Get_block_size(
Heap_Control *the_heap, Heap_Control *the_heap,
void *starting_address, void *starting_address,
ssize_t *size size_t *size
); );
/** /**

View File

@@ -52,7 +52,7 @@ SCORE_EXTERN Heap_Control _Workspace_Area; /* executive heap header */
*/ */
void _Workspace_Handler_initialization( void _Workspace_Handler_initialization(
void *starting_address, void *starting_address,
ssize_t size size_t size
); );
/** @brief Allocate Memory from Workspace /** @brief Allocate Memory from Workspace
@@ -66,7 +66,7 @@ void _Workspace_Handler_initialization(
* @return a pointer to the requested memory or NULL. * @return a pointer to the requested memory or NULL.
*/ */
void *_Workspace_Allocate( void *_Workspace_Allocate(
ssize_t size size_t size
); );
/** @brief Free Memory to the Workspace /** @brief Free Memory to the Workspace
@@ -94,7 +94,7 @@ bool _Workspace_Free(
* @return If successful, the starting address of the allocated memory * @return If successful, the starting address of the allocated memory
*/ */
void *_Workspace_Allocate_or_fatal_error( void *_Workspace_Allocate_or_fatal_error(
ssize_t size size_t size
); );
#ifndef __RTEMS_APPLICATION__ #ifndef __RTEMS_APPLICATION__

View File

@@ -111,10 +111,11 @@ static uint32_t instance = 0;
* +--------------------------------+ <- end = begin + size * +--------------------------------+ <- end = begin + size
* *
*/ */
uint32_t _Heap_Initialize( uint32_t _Heap_Initialize(
Heap_Control *the_heap, Heap_Control *the_heap,
void *starting_address, void *starting_address,
ssize_t size, size_t size,
uint32_t page_size uint32_t page_size
) )
{ {
@@ -206,10 +207,10 @@ uint32_t _Heap_Initialize(
* Convert user requested 'size' of memory block to the block size. * Convert user requested 'size' of memory block to the block size.
* Return block size on success, 0 if overflow occured * Return block size on success, 0 if overflow occured
*/ */
ssize_t _Heap_Calc_block_size( size_t _Heap_Calc_block_size(
ssize_t size, size_t size,
uint32_t page_size, uint32_t page_size,
uint32_t min_size) uint32_t min_size)
{ {
uint32_t block_size = size + HEAP_BLOCK_USED_OVERHEAD; uint32_t block_size = size + HEAP_BLOCK_USED_OVERHEAD;
_Heap_Align_up(&block_size, page_size); _Heap_Align_up(&block_size, page_size);

View File

@@ -36,7 +36,7 @@
void *_Heap_Allocate( void *_Heap_Allocate(
Heap_Control *the_heap, Heap_Control *the_heap,
ssize_t size size_t size
) )
{ {
uint32_t the_size; uint32_t the_size;

View File

@@ -131,7 +131,7 @@ Heap_Block *block_allocate(
void *_Heap_Allocate_aligned( void *_Heap_Allocate_aligned(
Heap_Control *the_heap, Heap_Control *the_heap,
ssize_t size, size_t size,
uint32_t alignment uint32_t alignment
) )
{ {

View File

@@ -38,7 +38,7 @@
Heap_Extend_status _Heap_Extend( Heap_Extend_status _Heap_Extend(
Heap_Control *the_heap, Heap_Control *the_heap,
void *starting_address, void *starting_address,
ssize_t size, size_t size,
uint32_t *amount_extended uint32_t *amount_extended
) )
{ {

View File

@@ -47,7 +47,7 @@
Heap_Resize_status _Heap_Resize_block( Heap_Resize_status _Heap_Resize_block(
Heap_Control *the_heap, Heap_Control *the_heap,
void *starting_address, void *starting_address,
ssize_t size, size_t size,
uint32_t *old_mem_size, uint32_t *old_mem_size,
uint32_t *avail_mem_size uint32_t *avail_mem_size
) )

View File

@@ -42,7 +42,7 @@
bool _Heap_Size_of_user_area( bool _Heap_Size_of_user_area(
Heap_Control *the_heap, Heap_Control *the_heap,
void *starting_address, void *starting_address,
ssize_t *size size_t *size
) )
{ {
Heap_Block *the_block; Heap_Block *the_block;

View File

@@ -19,7 +19,7 @@
bool _Protected_heap_Get_block_size( bool _Protected_heap_Get_block_size(
Heap_Control *the_heap, Heap_Control *the_heap,
void *starting_address, void *starting_address,
ssize_t *size size_t *size
) )
{ {
bool status; bool status;

View File

@@ -27,7 +27,7 @@
*/ */
void _Workspace_Handler_initialization( void _Workspace_Handler_initialization(
void *starting_address, void *starting_address,
ssize_t size size_t size
) )
{ {
uint32_t memory_available; uint32_t memory_available;
@@ -61,7 +61,7 @@ void _Workspace_Handler_initialization(
* _Workspace_Allocate * _Workspace_Allocate
*/ */
void *_Workspace_Allocate( void *_Workspace_Allocate(
ssize_t size size_t size
) )
{ {
return _Heap_Allocate( &_Workspace_Area, size ); return _Heap_Allocate( &_Workspace_Area, size );
@@ -81,7 +81,7 @@ bool _Workspace_Free(
* _Workspace_Allocate_or_fatal_error * _Workspace_Allocate_or_fatal_error
*/ */
void *_Workspace_Allocate_or_fatal_error( void *_Workspace_Allocate_or_fatal_error(
ssize_t size size_t size
) )
{ {
void *memory; void *memory;