On 16 Mar 2012, at 16:28, Paolo Bonzini wrote: > Il 16/03/2012 14:46, Lee Essen ha scritto: >> It does indeed … this came from the original Joyent code, I must >> admit I did wonder whether gcc would optimise it away. I did consider >> adding something to stop gcc complaining, but I don't fully >> understand why this is necessary given the mlock() bit, so I thought >> it best to leave it alone. > > "(void) *(volatile char *)p" should work, but a comment would be nice. > > Paolo
This is interesting … just did a little testing … With no-optimisation that original code is ok, although obviously comes with a compiler warning. With any optimisation at all the whole thing gets optimised away -- the existing illumos/smartos build looks like it's built with debug set, so no optimisation. Using volatile as above seems to do the trick nicely. Thanks, Lee.