The compiler is not free to do only one load there if v is declared
volatile.
The relevant part of the C standard would be the following paragraph:
[6.7.3]
[#6] An object that has volatile-qualified type may be
modified in ways unknown to the implementation or have other
unknown side effects. Therefore any expression referring to
such an object shall be evaluated strictly according to the
rules of the abstract machine, as described in 5.1.2.3.
Furthermore, at every sequence point the value last stored
in the object shall agree with that prescribed by the
abstract machine, except as modified by the unknown factors
mentioned previously.105) What constitutes an access to an
object that has volatile-qualified type is implementation-
defined.
footnote 105:
105A volatile declaration may be used to describe an object
corresponding to a memory-mapped input/output port or an
object accessed by an asynchronously interrupting
function. Actions on objects so declared shall not be
`optimized out'' by an implementation or reordered
except as permitted by the rules for evaluating
expressions.
[Quotes taken from a draft of the final standard, so it is possible,
but unlikely, that this was changed for the final standard.]
-- <Insert your favourite quote here.> Erik Trulsson ertr1013@student.uu.se - 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/