Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 331738

Summary: Memory needs to supply another way to get the largest type
Product: [Technology] RTSC Reporter: Todd Mullanix <todd_mullanix>
Component: RuntimeAssignee: Sasha Slijepcevic <sascha>
Status: ASSIGNED --- QA Contact:
Severity: normal    
Priority: P3 CC: dfriedland
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Todd Mullanix CLA 2010-12-02 20:34:53 EST
We currently have Memory_getMaxDefaultTypeAlign and Memory_getMaxDefaultTypeAlignMeta, but it would be nice to have a constant and type that we can use in the definition of buffer sizes.  

For example, if a heap states that it has requires alignment at least as big as Memory_getMaxDefaultTypeAlign, what's the best way for the user to insure this?

One approach is the following:

typedef struct FooStruct {
   // fields whose total size is not a multiple of Memory_getMaxDefaultTypeAlign
} FooStruct;

typedef struct Aligned_FooStruct {
   UInt64 filler[( sizeof(FooStruct) + sizeof(UInt64) – 1 ) / sizeof(UInt64)]; 
} Aligned_FooStruct;

#define NUMBLOCKS 31
Aligned_FooStruct buffer[NUMBLOCKS];

heapParams.numBlocks = NUMBLOCKS;
heapParams.blockSize = sizeof(FooStruct);
heapParams.size = sizeof(buffer);
heapParams.buf = buffer;
heap create...

Note I had to guess what the largest type size was UInt64. It would have been nicer to have a constant or even a new type (e.g. LargestType).
Comment 1 Sasha Slijepcevic CLA 2012-12-05 14:17:45 EST
We can easily create the constants for the largest size and the largest alignment along with other xdc_target__sizeof and xdc_target__alignof constants. That would help in HeapStd, where we could use that constant instead of calling the function.