Re:Hobby x86 kernel written with Zig
by AndyKelley on Monday January 06, 2020 @04:40PM
(#21973670)
The builtin functions for atomic operations provided by the language do not allow unaligned pointers, so it would be a compile error.
This is the main risk with bitfields in C, it makes reads and writes that appear to be independent actually access the same memory cell behind the scenes. I'm not convinced by the idea of adding even more magic on top of it to be honest, it is true that packing and unpacking bitfields is annoying and requires some boilerplate but in the end that is how it the hardware does it anyway.