Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331738 - Memory needs to supply another way to get the largest type
Summary: Memory needs to supply another way to get the largest type
Status: ASSIGNED
Alias: None
Product: RTSC
Classification: Technology
Component: Runtime (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Sasha Slijepcevic CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-02 20:34 EST by Todd Mullanix CLA
Modified: 2012-12-05 14:17 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.