1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/bitarithm_timings
Marian Buschsieweke 8854255d7a
tests/bitarithm_timings: Fix use of volatile
The tests used the volatile qualifier for two this:

1.  Prevent the compiler to optimize out calls to the inline-able functions
    bitarithm_msb, bitarithm_lsb, bitarithm_bits_set
2.  Communication between IRQ context and thread context

While the first use is valid, the second is dangerous, see [1], [2], [3], [4].
This commit replaces the second use with C11 atomics, which were explicitly
added to the C standard to address this use case.

[1]: https://www.kernel.org/doc/html/latest/process/volatile-considered-harmful.html
[2]: http://c.isvolatileusefulwiththreads.com/
[3]: https://web.archive.org/web/20181124154026/http://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/
[4]: https://blog.regehr.org/archives/28
2019-11-15 09:22:18 +01:00
..
tests
main.c tests/bitarithm_timings: Fix use of volatile 2019-11-15 09:22:18 +01:00
Makefile