Re:The byte order fallacy
by alexchamberlain on Wednesday April 04, 2012 @06:39AM
(#3796939)
adrianmsmith is suggesting that everytime the variable is read, the compiler inserts byte-swapping code. I disagree with that.
Re:The byte order fallacy
by adrianmsmith on Wednesday April 04, 2012 @09:43AM
(#3797509)
It would, in the worst case, not be worse than what the original poster is suggesting.
And at least in that case, the code would be more readable.
But, as the compiler knows more about what's going on (it's not just parsing and compiling a general expression with ORs and shifts) then it could well be faster (e.g. if there were a CPU instruction to do this, then it could be used, etc.).
I don't necessarily see a problem with that: it would avoid the messy cpu_to_le64 calls.
Re:The byte order fallacy
by alexchamberlain on Wednesday April 04, 2012 @06:39AM
(#3796940)
DSL?
(I also have static assertions for the expected size following each ondisk struct)
It'd be nicer to codify this as a DSL or something, but C's macro system really isn't up to the job.