Closed enaess closed 6 months ago
@rfc1036
I think that the purpose is to prevent reordering by the compiler.
The buffer is volatile because other programs could potentially mmap it and access it concurrently, and so we want to limit reordering of accesses by the compiler. Volatile is not a complete fix, though, because the CPU can still reorder accesses, and to fix it properly we would need barrier instructions, which tends to get machine-dependent.
It is possible to make the accesses volatile,rather than the data, i.e. use casts to volatile where the buffer entries are read or written rather than making the data structure itself volatile.
@enaess: This bug always exists?
Fixed by fafbfdf
Compiling the latest mainline on Solaris adds additional warning messages, we should address these. And why use the keyword "volatile" in these circumstances?