Blergh. Volatile keywords again. This is a mistake in C, a mistake inherited (and of course doubled down on) by C++ but not one Zig needs to repeat.
What you need is volatile read/write or load/store intrinsics. When you have those, you can express what's actually possible on a hardware platform, and not inadvertently enable people to write nonsense in your language - no need to even have a footgun here, let alone leave it loaded on the table for a newbie to pick it up and blow their whole leg off.
Although it was eventually un-deprecated in C++ 23, one of the smaller useful accomplishments in C++ 20 was to deprecate the inappropriate use of composite operators on volatile, which is the sort of nonsense entertained by having a keyword instead of intrinsics. When the newbie in your team writes irq_flags |= new they think they're performing a single operation, after all |= isn't two operations, it's just one. You, hopefully, know that's untrue - the irq_flags were marked volatile, so that's decomposed into a separate load and store -- but are you sure you'll notice they screwed this up? Or will you only realise when customers report sometimes IRQ flags "go missing" under load?
Blergh. Volatile keywords again. This is a mistake in C, a mistake inherited (and of course doubled down on) by C++ but not one Zig needs to repeat.
What you need is volatile read/write or load/store intrinsics. When you have those, you can express what's actually possible on a hardware platform, and not inadvertently enable people to write nonsense in your language - no need to even have a footgun here, let alone leave it loaded on the table for a newbie to pick it up and blow their whole leg off.
Although it was eventually un-deprecated in C++ 23, one of the smaller useful accomplishments in C++ 20 was to deprecate the inappropriate use of composite operators on volatile, which is the sort of nonsense entertained by having a keyword instead of intrinsics. When the newbie in your team writes irq_flags |= new they think they're performing a single operation, after all |= isn't two operations, it's just one. You, hopefully, know that's untrue - the irq_flags were marked volatile, so that's decomposed into a separate load and store -- but are you sure you'll notice they screwed this up? Or will you only realise when customers report sometimes IRQ flags "go missing" under load?