But it is. That's the whole point, to not bother with weird endian conversion macros.
But it is. That's the whole point, to not bother with weird endian conversion macros.
You're telling me that what the linux kernel guys do is "weird endian conversion macros?" I don't believe you.
It doesn't always swap. Look at the assembly I posted above comparing mips64le to mips64be.
The code takes the byte at b[n] and shifts it (8.n)-bits. These are the same bytes on both little endian and big endian machines. They read the bytes in the same order (little endian), and convert them to the native order.
You can also see very clearly that it doesn't always swap by looking at the simple x86_64 assembly output that the was posted where no shifts or swaps are performed. Just a mov instruction.
Read the assembly. Or better yet, try the code out for yourself.
Assuming LE ordering on the writer side, you would need to swap again on a BE machine. Usually, however, you want to store in your target byte order, though. One could argue this is irrelevant as long as the memory doesn't leave your application, of course. Yet, by explicitly having macros _to_cpu, _to_be, _to_le and so on you make all of this explicit.