module xdcruntime.heaps.HeapStdAlign

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 xdcruntime/heaps/HeapStdAlign.xdc
#include <xdcruntime/heaps/HeapStdAlign.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
Typedefs
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().
config HeapStdAlign_A_align  // module-wide

Assert raised when the requested alignment is not a power of 2

C synopsis target-domain
extern const Assert_Id HeapStdAlign_A_align;
config HeapStdAlign_A_invalidTotalFreeSize  // module-wide

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

C synopsis target-domain
extern const Assert_Id HeapStdAlign_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 HeapStdAlign_A_zeroSize  // module-wide

Assert that the size is non-zero on the create

C synopsis target-domain
extern const Assert_Id HeapStdAlign_A_zeroSize;
config HeapStdAlign_E_noRTSMemory  // module-wide

Error raised if all the RTS heap is used up

C synopsis target-domain
extern const Error_Id HeapStdAlign_E_noRTSMemory;
DETAILS
The total size of all HeapStdAlign 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 HeapStdAlign_Module_id();
// Get this module's unique id
 
Bool HeapStdAlign_Module_startupDone();
// Test if this module has completed startup
 
IHeap_Handle HeapStdAlign_Module_heap();
// The heap from which this module allocates memory
 
Bool HeapStdAlign_Module_hasMask();
// Test whether this module has a diagnostics mask
 
Bits16 HeapStdAlign_Module_getMask();
// Returns the diagnostics mask for this module
 
Void HeapStdAlign_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
Instance Object Types

C synopsis target-domain
typedef struct HeapStdAlign_Object HeapStdAlign_Object;
// Opaque internal representation of an instance object
 
typedef HeapStdAlign_Object *HeapStdAlign_Handle;
// Client reference to an instance object
 
typedef struct HeapStdAlign_Struct HeapStdAlign_Struct;
// Opaque client structure large enough to hold an instance object
 
HeapStdAlign_Handle HeapStdAlign_handle(HeapStdAlign_Struct *structP);
// Convert this instance structure pointer into an instance handle
 
HeapStdAlign_Struct *HeapStdAlign_struct(HeapStdAlign_Handle handle);
// Convert this instance handle into an instance structure pointer
Instance Config Parameters

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

Size (in MAUs) of the heap

C synopsis target-domain
      ...
    Memory_Size size;
DETAILS
This parameter specifies the size of the heap managed by a HeapStdAlign instance. HeapStdAlign is built upon the ANSI C Standard Library functions malloc() and free().
The total size of all HeapStdAlign 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.
Instance Creation

C synopsis target-domain
HeapStdAlign_Handle HeapStdAlign_create(const HeapStdAlign_Params *params, Error_Block *eb);
// Allocate and initialize a new instance object and return its handle
 
Void HeapStdAlign_construct(HeapStdAlign_Struct *structP, const HeapStdAlign_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 HeapStdAlign_delete(HeapStdAlign_Handle *handleP);
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
 
Void HeapStdAlign_destruct(HeapStdAlign_Struct *structP);
// Finalize the instance object inside the provided structure
HeapStdAlign_alloc()  // instance

Allocates a block of memory from the heap

C synopsis target-domain
Ptr HeapStdAlign_alloc(HeapStdAlign_Handle handle, SizeT size, SizeT align, Error_Block *eb);
ARGUMENTS
handle — handle of a previously-created HeapStdAlign 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
HeapStdAlign_free()  // instance

Free a block of memory back to the heap

C synopsis target-domain
Void HeapStdAlign_free(HeapStdAlign_Handle handle, Ptr block, SizeT size);
ARGUMENTS
handle — handle of a previously-created HeapStdAlign 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.
HeapStdAlign_getStats()  // instance

Retrieve the statistics from the heap

C synopsis target-domain
Void HeapStdAlign_getStats(HeapStdAlign_Handle handle, Memory_Stats *stats);
ARGUMENTS
handle — handle of a previously-created HeapStdAlign 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.
HeapStdAlign_isBlocking()  // instance

Returns whether the heap may block during an HeapStdAlign_alloc() or HeapStdAlign_free()

C synopsis target-domain
Bool HeapStdAlign_isBlocking(HeapStdAlign_Handle handle);
ARGUMENTS
handle — handle of a previously-created HeapStdAlign 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 HeapStdAlign_Handle_upCast(HeapStdAlign_Handle handle);
// unconditionally move one level up the inheritance hierarchy
 
HeapStdAlign_Handle HeapStdAlign_Handle_downCast(IHeap_Handle handle);
// conditionally move one level down the inheritance hierarchy; NULL upon failure
Instance Built-Ins

C synopsis target-domain
Int HeapStdAlign_Object_count();
// The number of statically-created instance objects
 
HeapStdAlign_Handle HeapStdAlign_Object_get(HeapStdAlign_Object *array, Int i);
// The handle of the i-th statically-created instance object (array == NULL)
 
HeapStdAlign_Handle HeapStdAlign_Object_first();
// The handle of the first dynamically-created instance object, or NULL
 
HeapStdAlign_Handle HeapStdAlign_Object_next(HeapStdAlign_Handle handle);
// The handle of the next dynamically-created instance object, or NULL
 
IHeap_Handle HeapStdAlign_Object_heap();
// The heap used to allocate dynamically-created instance objects
 
Types_Label *HeapStdAlign_Handle_label(HeapStdAlign_Handle handle, Types_Label *buf);
// The label associated with this instance object
 
String HeapStdAlign_Handle_name(HeapStdAlign_Handle handle);
// The name of this instance object
 
XDCscript usage meta-domain sourced in xdcruntime/heaps/HeapStdAlign.xdc
var HeapStdAlign = xdc.useModule('xdcruntime.heaps.HeapStdAlign');
module-wide config parameters
        msg: "A_align: Requested align is not a power of 2"
    };
        msg: "HeapStdAlign instance totalFreeSize > than starting size"
    };
        msg: "HeapStdAlign_create cannot have a zero size value"
    };
        msg: "The RTS heap is used up. Examine Program.heap."
    };
per-instance config parameters
    var params = new HeapStdAlign.Params// Instance config-params object;
        params.size// Size (in MAUs) of the heap = UArg 0;
per-instance creation
    var inst = HeapStdAlign.create// Create an instance-object(params);
 
config HeapStdAlign.A_align  // module-wide

Assert raised when the requested alignment is not a power of 2

XDCscript usage meta-domain
HeapStdAlign.A_align = Assert.Desc {
    msg: "A_align: Requested align is not a power of 2"
};
C SYNOPSIS
config HeapStdAlign.A_invalidTotalFreeSize  // module-wide

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

XDCscript usage meta-domain
HeapStdAlign.A_invalidTotalFreeSize = Assert.Desc {
    msg: "HeapStdAlign instance totalFreeSize > 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 HeapStdAlign.A_zeroSize  // module-wide

Assert that the size is non-zero on the create

XDCscript usage meta-domain
HeapStdAlign.A_zeroSize = Assert.Desc {
    msg: "HeapStdAlign_create cannot have a zero size value"
};
C SYNOPSIS
config HeapStdAlign.E_noRTSMemory  // module-wide

Error raised if all the RTS heap is used up

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

Common module configuration parameters

XDCscript usage meta-domain
HeapStdAlign.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

XDCscript usage meta-domain
var params = new HeapStdAlign.Params;
// Instance config-params object
    params.size = UArg 0;
    // Size (in MAUs) of the heap
config HeapStdAlign.size  // instance

Size (in MAUs) of the heap

XDCscript usage meta-domain
var params = new HeapStdAlign.Params;
  ...
params.size = UArg 0;
DETAILS
This parameter specifies the size of the heap managed by a HeapStdAlign instance. HeapStdAlign is built upon the ANSI C Standard Library functions malloc() and free().
The total size of all HeapStdAlign 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
Instance Creation

XDCscript usage meta-domain
var params = new HeapStdAlign.Params;
// Allocate instance config-params
params.config =   ...
// Assign individual configs
 
var inst = HeapStdAlign.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 Fri, 29 Oct 2010 00:26:50 GMT