Community
Participate
Working Groups
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).
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.