I have a header file containing a structure definition used by the PRU and shared with ARM. The PRU does not have alignment constraints. As a result I would expect the compiler to generate a packed struct by default. The ARM core however does have alignment constraints. So I give ARM a hint by adding __attribute__((packed)) to my struct definition.
Doing this results in the PRU pulling data byte by byte to reassemble individual values. I understand why this can happen and on certain architectures it absolutely makes sense. However given the PRU could care less about alignment shouldn't the compiler just ignore the directive?
I feel like a shared header file is a fairly common scenario. If someone isn't paying attention they are going to take a pretty significant performance hit on memory access. Granted I can #ifdef __KERNEL__ my way out of this issue quite easily. I am just curious if this is really the desired compiler behavior when specifying __attribute__((packed))?