Subject: Re: Recent serial port lossage
To: Wolfgang Solfrank <ws@tools.de>
From: Bakul Shah <bakul@netcom.com>
List: port-i386
Date: 01/08/1996 09:37:09
>> volatile int foo;
...
>>       foo |= 0x80000000;

> Of course this cannot be a bug in gcc. If it was, the above C code couldn't
> be compiled at all for any RISC chip. Remember that RISC processors cannot
> do arithmetic (or logical functions) to memory at all.

There are actually very few guarantees w.r.t. volatile.

In general `foo |= bar' sort of code can misbehave when you
are dealing with memory mapped IO.  H/W designers have used
address decode & register bits for all sorts of things in
order to save a gate or an IO pin or a chip here and there.
Things like reading will clear an interrupt or mapping two
different registers at the same address (one for read, one
for write) etc.  *Not* treating memory mapped I/O like
ordinary memory is an early lesson a driver writer ends up
learning.

If foo is in normal memory, code depending on `foo |= bar'
being compiled to a single instruction is plain buggy.

-- bakul