3 ms·
It's about accessing memory plus an extra conversion step vs. accessing memory in the right order in one step. As an extra, platform-dependent implementations o
by pajko 5y ago
It's about accessing memory plus an extra conversion step vs. accessing memory in the right order in one step. As an extra, platform-dependent implementations of the accessors could be done, like using the LWL+LWR instruction pair on MIPS.
For reference, check how Linux does it.
https://elixir.bootlin.com/linux/latest/source/include/linux/unaligned/le_byteshift.h https://elixir.bootlin.com/linux/latest/source/include/linux...
- matheusmoreira 5y agoDoesn't this run into the same issue described by the author? > Because unsigned char in C expressions gets type promoted to the signed type int. > So if we say 0x80<<24 it overwrites the sign bit, which is an undefined behavior Does the u8 type protect against this?