We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'm using the GCC compiler to load packed 16-bit data (i.e. two 16-bit words in a 32-bit value). My pointer is to a 32-bit type because I want to load two 16-bit values in a single cycle but the pointer is not necessarily aligned to a 4 byte boundary. GNU GCC generates LDRD to load two 32-bit values. This results in an alignment fault a run-time. Is there a compile option to prevent the compiler from using LDRD ? or an option to control alignment assumptions? Otherwise what's the best way to get the compiler to load packed data efficiently.
I use that in GCC.
struct __attribute__((packed)) unaligned_struct { uint64_t Value; } uint8_t byte_buffer[100] uint64_t data;; data = *((unligned_struct *) &byte_buffer[55]);
Hi Robert, Yes a modified version of the above works, thanks. I note that for GCC it appears that the packed attribute is only accepted when dealing with structures. I thought normally this refers to padding between the elements rather than packed in the SIMD sense.