Stop this stupid argument.
A C compiler is "allowed" to do just about anything. The introduction of
"volatile" does not change that in any really meaningful way. It doesn't
change the fact that gcc is "allowed" to do a really shitty job on _any_
code it is given.
int i = *int_ptr;
into the equivalent of (assuming a little-endian machine with only byte
load/store instructions)
unsigned char *tmp = (unsigned char *)int_ptr + 3;
int j = 4;
int i = 0;
do {
i <<= 8;
i += *tmp;
tmp--;
} while (--j);
The fact that a C compiler is _allowed_ to create code like just about
anything is not an argument at all.
The above, btw, is NOT as ridiculous as it sounds. We've had the exact
opposite problem on alpha: byte stores are not "atomic", and would
"corrupt" the bytes around it due to the non-atomic nature of having to do
load word
mask value
insert byte
store word
Did it help to mark things "volatile" there? No. We had to change the code
to (a) either use locking so that nobody would ever touch adjacent bytes
concurrently or (b) stop using byte values.
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/