As shown below, I have a struct that has a few bitfields. I also have a union that contains a volatile 64-bit value and this struct. Are changes to the struct, accessed through the union, also volatile?
i.e. since the struct and the volatile int share the same memory location, do accesses to the struct also result in accessing memory for each access, or will the compiler store them in registers?
typedef struct {
uint64 my_info_1:12;
uint64 my_info_2:16;
uint64 reserved: 36;
} my_info_s;
typedef union {
my_info_s my_info_struct;
volatile unsigned long long my_info_vol; //64 bit
} my_info_u;
my_info_u my_info;
//Are these volatile accesses?
my_info.my_info_1 = 4;
my_info.my_info_2 = 8;
//This is the motivation- update a bunch of bitfields, but set them in one shot.
atomic_set(atomic_location, my_info.my_info_vol);
I cannot use locks/mutexes to achieve this because of some real-time constraints.