compiler people: how likely is it that timing-safe C code is future-proof? as in, how likely is it that future compilers will e.g. take "uint8_t diff = 0; for (size_t i=0; i<len; i++) diff |= a[i]^b[i]; return diff != 0" and put a conditional bailout jump in the loop?
see https://bennthomsen.wordpress.com/arduino/peripherals/serial-communications/ …: USART_Receive() reads serial data by reading `UDR0`, which expands through several macros into a dereference of a volatile MMIO pointer. so the volatile read from an MMIO region mutates state and must therefore not be removed.
-
-
I completely agree, you cannot optimize out the reads. You could optimize away doing anything with the result of the read, however.
- 8 more replies
New conversation -
-
-
amusingly, "while (xfer_pending) { sleep_cpu_until_interrupt() }" gets optimized into "while(1) { sleep_cpu_until_interrupt() }" if "xfer_pending", cleared in an interrupt handler, is not marked volatile.
-
https://godbolt.org/g/Qa2JA3 Change line 3 to "volatile bool pending" and watch it start working as intended.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.