Re: [PATCH] unexpected IO-APIC update

Linus Torvalds (torvalds@transmeta.com)
Tue, 24 Jun 2003 18:31:12 -0700 (PDT)


On Tue, 24 Jun 2003, Randy.Dunlap wrote:
>
> + if (reg_01.version >= 0x20)
> + *(int *)&reg_03 = io_apic_read(apic, 3);

There's a lot of these

*(int *)&reg_03

kinds of things there, and the fact is, gcc's alias analysis doesn't like
them, _and_ they are ugly.

The alias analysis I could care less about, since a good alias analysis
would take static address information into account, and gcc at least last
time I looked wasn't. So we don't even bother using it for now.

We may want to reconsider that eventually, though, since more recent
versions of gcc at least try to make their alias analysis useful with
things like "attribute((may_alias))" or whatever the syntax was.

But the ugliness part I care about, and I wonder if it wouldn't be better
in this case to just make the register definition a "union", and have
something like

union reg_03 {
u32 value;
struct {
u32 boot_DT:1,
reserved:31;
} bits;
};

and then you can avoid the ugly dereference/cast/address-of thing, and
just say

reg_03.value

or

reg_03.bits.boot_DT

which looks a lot cleaner.

This is what unions are _designed_ for.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/