Perhaps I do not understand the proper usage, but I am wondering if the __attrrbute__((aligned(x))) is broken with regards to structures.
Given the following (and also with the attribute explicitly declared [both before and after the variable, and also for the whole structure] instead of a macro) I do not see the alignment I expect.
#define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
#define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
ULONG POINTER_ALIGNMENT InputBufferLength;
ULONG POINTER_ALIGNMENT IoControlCode;
Regardless of the way I try to do it, I get addresses for the variable members similar to:
d41370e4:d41370e8:d41370ec:d41370f0 for the 4 member variables respectively. While InputBufferLength and Type3InputBuffer are 8 byte aligned, that seems to be just because we are dealing the first three 4 byte members and it starts on a 4 byte alignment.
Also of note is that the size is 20 bytes, and I would expect 28 if the last three members were 8 byte aligned.
I also did a test with two stack variables declared using no alignment attribute, and got 4 byte alignment. Then used the aligned attribute and got 8 byte alignment as I would expect.
Any insights would be appreciated.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.