[PATCH 6/6] [POWERPC] make struct property's value a void *

Segher Boessenkool segher at kernel.crashing.org
Tue Apr 10 08:11:58 EST 2007


>> Pointers never alias anything.  It's the data accesses
>> that matter.  You cannot access one type as another type
>> and expect it to work (unless one of those types is a
>> character type); that's the one simple rule.
>
> This is true according to the standard (as I understand it), and also
> a classic example of the C standards committee stuffing up the C
> language by trying to turn it into a "high-level" language.  From the
> earliest days of C on the PDP-11 it was understood that memory was an
> array of bytes which could be addressed and interpreted in any way the
> programmer chose.  For systems programming tasks that is a very useful
> facility, and one which the kernel code generally assumes.  It's a
> pity IMHO that the committee chose to throw that away (and yes I
> understand that throwing it away makes more optimization opportunities
> available).

You can still access an array of character type as any type
you want.  What you *cannot* validly do is store one type, and
read it back as another type, without going through a character
type (or, in the case of GCC, a union).

I don't see there are so many places in the kernel where
it would be useful to do this, and the few places where it
actually is useful or needed should stick out like a sore
thumb and can be easily coded "around" using GCC-specific
compiler facilities.


Segher




More information about the Linuxppc-dev mailing list