I am using a binary semaphore in a struct like so:
struct Header {uint64_t otherfields...binary_semaphore sem;[hidden padding of 4 bytes if sem is 4 bytes]uint64_t post_otherfields..};int main() {cout << sizeof(Header) << endl;return 0;}
I tried on godbolt https://godbolt.org/z/8rPs56Y7x to see if different x86_64 compilers gave the same results of size 4 for the semaphore.
I set up u64 values in the struct on purpose to correct any hiccup.
Since this struct is in a mmap region:
I would like to get the guarantee that the size won't suddenly change in the future, using Linux GCC on x86_64 arch.
(more than 8 bytes will be problematic, taking into account the alignment occuring between sem and post_otherfields and that would mess up the layout)
Thanks