Also the update of the write pointer could be reordered to occur before storage of the actual data flushed to the buffer.
e.g.
buf[volatile_write_ptr] = c
volatile_write_ptr++;
might occur the other way 'round for the code that is reading from buf[].
For typical "simple" single processor controllers this will not be an issue, though, and "volatile"+spinlocks/disenable-enable-interrupts will work just fine.
For typical "simple" single processor controllers this will not be an issue, though, and "volatile"+spinlocks/disenable-enable-interrupts will work just fine.