Bitfields

Paolo Bonzini bonzini@gnu.org
Sun Sep 20 14:01:00 GMT 2009


> reg.field1 = val1, reg.field2 = val2;
>
> would then turn into fetch, mask with a combined mask of field1 and
> field2, or val1, or val2, store.

You can also do the RMW yourself: declare the register volatile, but not 
the fields of it, and copy in/out of the register manually.

volatile struct reg x;

...
{
   struct reg mine = x;
   mine.field1 = true;
   mine.field2 = 0;
   mine.field3++;
   x = mine;
}

> Is it a completely brain-dead idea?

If I understood it correctly, it would not be standard compliant.

Paolo



More information about the Gcc mailing list