module xdc.runtime.HeapStd

Malloc/free based heap implementation

This heap is based on the ANSI C Standard Library functions malloc() and free() and assumes that these functions are thread-safe. Please refer to the target specific documentation of the ANSI C Standard Library for details. [ more ... ]
C synopsis target-domain sourced in xdc/runtime/HeapStd.xdc
#include <xdc/runtime/HeapStd.h>
Functions
Void
Void
Void
Void
Functions common to all IHeap modules
Ptr 
Void 
Void 
Bool 
Functions common to all target instances
Functions common to all target modules
Defines
#define
Typedefs
typedef HeapStd_Object *
typedef struct
typedef struct
typedef struct
Constants
extern const Assert_Id 
extern const Assert_Id 
extern const Assert_Id 
extern const Error_Id 
 
DETAILS
This heap is based on the ANSI C Standard Library functions malloc() and free() and assumes that these functions are thread-safe. Please refer to the target specific documentation of the ANSI C Standard Library for details.
The largest free block that can be returned form malloc() cannot be determined. Therefore, the property largestFreeSize in Memory.Stats returned from getStats() always returns 0.
CONSTRAINTS
The alloc() function only supports alignment requests up to value returned from Memory.getMaxDefaultTypeAlign().
 
const HeapStd_HEAP_MAX

Maximum heap size of HeapStd

C synopsis target-domain
#define HeapStd_HEAP_MAX (SizeT)~0U
 
DETAILS
This parameter defines maximum heap size that can be allocated to a HeapStd instance. Using this parameter to create HeapStd instances will disable the internal size checks in HeapStd module.
 
config HeapStd_A_align  // module-wide

Assert that the size is a power of 2

C synopsis target-domain
extern const Assert_Id HeapStd_A_align;
 
 
config HeapStd_A_invalidTotalFreeSize  // module-wide

Assert that remaining size is less than or equal to starting size

C synopsis target-domain
extern const Assert_Id HeapStd_A_invalidTotalFreeSize;
 
DETAILS
If this assertion is raised, it means that either incorrect sizes were passed to free or multiple calls to free were made with the same buffer.
 
config HeapStd_A_zeroSize  // module-wide

Assert that the size is non-zero on the create

C synopsis target-domain
extern const Assert_Id HeapStd_A_zeroSize;
 
 
config HeapStd_E_noRTSMemory  // module-wide

Error raised if all the RTS heap is used up

C synopsis target-domain
extern const Error_Id HeapStd_E_noRTSMemory;
 
DETAILS
The total size of all HeapStd instance allocations added together cannot exceed the malloc/free heap size determined by xdc.cfg.Program.heap.
Module-Wide Built-Ins

C synopsis target-domain
Types_ModuleId HeapStd_Module_id();
// Get this module's unique id
 
Bool HeapStd_Module_startupDone();
// Test if this module has completed startup
 
IHeap_Handle HeapStd_Module_heap();
// The heap from which this module allocates memory
 
Bool HeapStd_Module_hasMask();
// Test whether this module has a diagnostics mask
 
Bits16 HeapStd_Module_getMask();
// Returns the diagnostics mask for this module
 
Void HeapStd_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
Instance Object Types

C synopsis target-domain
typedef struct HeapStd_Object HeapStd_Object;
// Opaque internal representation of an instance object
 
typedef HeapStd_Object *HeapStd_Handle;
// Client reference to an instance object
 
typedef struct HeapStd_Struct HeapStd_Struct;
// Opaque client structure large enough to hold an instance object
 
HeapStd_Handle HeapStd_handle(HeapStd_Struct *structP);
// Convert this instance structure pointer into an instance handle
 
HeapStd_Struct *HeapStd_struct(HeapStd_Handle handle);
// Convert this instance handle into an instance structure pointer
Instance Config Parameters

C synopsis target-domain
typedef struct HeapStd_Params {
// Instance config-params structure
    IInstance_Params *instance;
    // Common per-instance configs
    Memory_Size size;
    // Size (in MAUs) of the heap
} HeapStd_Params;
 
Void HeapStd_Params_init(HeapStd_Params *params);
// Initialize this config-params structure with supplier-specified defaults before instance creation
 
config HeapStd_Params.size  // instance

Size (in MAUs) of the heap

C synopsis target-domain
struct HeapStd_Params {
      ...
    Memory_Size size;
 
DETAILS
This parameter specifies the size of the heap managed by a HeapStd instance. HeapStd is built upon the ANSI C Standard Library functions malloc() and free().
The total size of all HeapStd instance allocations added together cannot exceed the malloc/free heap size determined by Program.heap.
This is a required parameter. It must be set by the caller. Failure to do so, will result in a build error for the static create or an assert for the runtime create.
Runtime Instance Creation

C synopsis target-domain
HeapStd_Handle HeapStd_create(const HeapStd_Params *params, Error_Block *eb);
// Allocate and initialize a new instance object and return its handle
 
Void HeapStd_construct(HeapStd_Struct *structP, const HeapStd_Params *params, Error_Block *eb);
// Initialize a new instance object inside the provided structure
ARGUMENTS
params — per-instance config params, or NULL to select default values (target-domain only)
eb — active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
This heap uses the ANSI C Standard Library functions malloc() and free() to manage memory and assumes that these functions are thread-safe.
SEE
Instance Deletion

C synopsis target-domain
Void HeapStd_delete(HeapStd_Handle *handleP);
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
 
Void HeapStd_destruct(HeapStd_Struct *structP);
// Finalize the instance object inside the provided structure
 
HeapStd_alloc()  // instance

Allocates a block of memory from the heap

C synopsis target-domain
Ptr HeapStd_alloc(HeapStd_Handle handle, SizeT size, SizeT align, Error_Block *eb);
 
ARGUMENTS
handle — handle of a previously-created HeapStd instance object
size — size (in MADUs) of the block
align — alignment (in MADUs) of the block
eb — pointer to error block
DETAILS
This method returns a block of memory from the heap. It is called by the xdc.runtime.Memory.alloc() function.
RETURNS
Returns the address of the allocated memory.
CONSTRAINTS
The only alignment currently supported is the default alignment returned by the underlying malloc() implementation. The align value must be less than or equal to the value returned from Memory.getMaxDefaultTypeAlign().
SEE
 
HeapStd_free()  // instance

Free a block of memory back to the heap

C synopsis target-domain
Void HeapStd_free(HeapStd_Handle handle, Ptr block, SizeT size);
 
ARGUMENTS
handle — handle of a previously-created HeapStd instance object
block — non-NULL address of allocated block to free
size — size (in MADUs) of the block of memory to free
DETAILS
This method gives back a block of memory to a heap. It is called by the xdc.runtime.Memory.free() function.
 
HeapStd_getStats()  // instance

Retrieve the statistics from the heap

C synopsis target-domain
Void HeapStd_getStats(HeapStd_Handle handle, Memory_Stats *stats);
 
ARGUMENTS
handle — handle of a previously-created HeapStd instance object
stats — non-NULL pointer to an output buffer
DETAILS
The caller passes in a pointer to a xdc.runtime.Memory.Stats structure and getStats fills in this structure.
This function is called by the xdc.runtime.Memory.getStats() function.
 
HeapStd_isBlocking()  // instance

Returns whether the heap may block during an HeapStd_alloc() or HeapStd_free()

C synopsis target-domain
Bool HeapStd_isBlocking(HeapStd_Handle handle);
 
ARGUMENTS
handle — handle of a previously-created HeapStd instance object
RETURNS
If the heap might block, TRUE is returned. If the heap does not block, FALSE is returned.
Since the implementation of the underlaying ANSI C Standard Library is not known, this function always returns the more restrictive case which is TRUE.
Instance Convertors

C synopsis target-domain
IHeap_Handle HeapStd_Handle_upCast(HeapStd_Handle handle);
// unconditionally move one level up the inheritance hierarchy
 
HeapStd_Handle HeapStd_Handle_downCast(IHeap_Handle handle);
// conditionally move one level down the inheritance hierarchy; NULL upon failure
Instance Built-Ins

C synopsis target-domain
Int HeapStd_Object_count();
// The number of statically-created instance objects
 
HeapStd_Handle HeapStd_Object_get(HeapStd_Object *array, Int i);
// The handle of the i-th statically-created instance object (array == NULL)
 
HeapStd_Handle HeapStd_Object_first();
// The handle of the first dynamically-created instance object, or NULL
 
HeapStd_Handle HeapStd_Object_next(HeapStd_Handle handle);
// The handle of the next dynamically-created instance object, or NULL
 
IHeap_Handle HeapStd_Object_heap();
// The heap used to allocate dynamically-created instance objects
 
Types_Label *HeapStd_Handle_label(HeapStd_Handle handle, Types_Label *buf);
// The label associated with this instance object
 
String HeapStd_Handle_name(HeapStd_Handle handle);
// The name of this instance object
 
Configuration settings sourced in xdc/runtime/HeapStd.xdc
var HeapStd = xdc.useModule('xdc.runtime.HeapStd');
module-wide constants & types
module-wide config parameters
        msg: "HeapStd_alloc alignment must be a power of 2"
    };
        msg: "HeapStd instance totalFreeSize is greater than starting size"
    };
        msg: "HeapStd_create cannot have a zero size value"
    };
        msg: "The RTS heap is used up. Examine Program.heap."
    };
 
per-instance config parameters
    var params = new HeapStd.Params// Instance config-params object;
        params.size// Size (in MAUs) of the heap = UArg 0;
per-instance creation
    var inst = HeapStd.create// Create an instance-object(params);
 
 
const HeapStd.HEAP_MAX

Maximum heap size of HeapStd

Configuration settings
const HeapStd.HEAP_MAX = ~0U;
 
DETAILS
This parameter defines maximum heap size that can be allocated to a HeapStd instance. Using this parameter to create HeapStd instances will disable the internal size checks in HeapStd module.
C SYNOPSIS
 
config HeapStd.A_align  // module-wide

Assert that the size is a power of 2

Configuration settings
HeapStd.A_align = Assert.Desc {
    msg: "HeapStd_alloc alignment must be a power of 2"
};
 
C SYNOPSIS
 
config HeapStd.A_invalidTotalFreeSize  // module-wide

Assert that remaining size is less than or equal to starting size

Configuration settings
HeapStd.A_invalidTotalFreeSize = Assert.Desc {
    msg: "HeapStd instance totalFreeSize is greater than starting size"
};
 
DETAILS
If this assertion is raised, it means that either incorrect sizes were passed to free or multiple calls to free were made with the same buffer.
C SYNOPSIS
 
config HeapStd.A_zeroSize  // module-wide

Assert that the size is non-zero on the create

Configuration settings
HeapStd.A_zeroSize = Assert.Desc {
    msg: "HeapStd_create cannot have a zero size value"
};
 
C SYNOPSIS
 
config HeapStd.E_noRTSMemory  // module-wide

Error raised if all the RTS heap is used up

Configuration settings
HeapStd.E_noRTSMemory = Error.Desc {
    msg: "The RTS heap is used up. Examine Program.heap."
};
 
DETAILS
The total size of all HeapStd instance allocations added together cannot exceed the malloc/free heap size determined by xdc.cfg.Program.heap.
C SYNOPSIS
 
metaonly config HeapStd.common$  // module-wide

Common module configuration parameters

Configuration settings
HeapStd.common$ = Types.Common$ undefined;
 
DETAILS
All modules have this configuration parameter. Its name contains the '$' character to ensure it does not conflict with configuration parameters declared by the module. This allows new configuration parameters to be added in the future without any chance of breaking existing modules.
Instance Config Parameters

Configuration settings
var params = new HeapStd.Params;
// Instance config-params object
    params.size = UArg 0;
    // Size (in MAUs) of the heap
 
config HeapStd.Params.size  // instance

Size (in MAUs) of the heap

Configuration settings
var params = new HeapStd.Params;
  ...
params.size = UArg 0;
 
DETAILS
This parameter specifies the size of the heap managed by a HeapStd instance. HeapStd is built upon the ANSI C Standard Library functions malloc() and free().
The total size of all HeapStd instance allocations added together cannot exceed the malloc/free heap size determined by Program.heap.
This is a required parameter. It must be set by the caller. Failure to do so, will result in a build error for the static create or an assert for the runtime create.
C SYNOPSIS
Static Instance Creation

Configuration settings
var params = new HeapStd.Params;
// Allocate instance config-params
params.config =   ...
// Assign individual configs
 
var inst = HeapStd.create(params);
// Create an instance-object
ARGUMENTS
params — per-instance config params, or NULL to select default values (target-domain only)
eb — active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
This heap uses the ANSI C Standard Library functions malloc() and free() to manage memory and assumes that these functions are thread-safe.
SEE
generated on Thu, 23 May 2019 00:24:45 GMT