News for hackers. Stuff that matters.
Re:John Carmack on Inlined Code (2014) by unwind on Tuesday January 22, 2019 @04:10AM (#18967048)
Of course that should be

    const uint32_t conf = read1(mgr->regs + OFF_MACHINE_ID);
and the 'mgr' argument should be const:ed, too. :) That makes it much more clear that this kind helper is just reading something out, and not poking stuff around. Always const all the things.

Have you even bothered checking if your compiler inlines this? It sure looks like a very likely candidate.

Re:John Carmack on Inlined Code (2014) by simias on Tuesday January 22, 2019 @06:48AM (#18967610)
I agree that the pointer to mgr should've been const, that's a mistake on my part. On the other hand "const"ing the local integer is a bit overkill IMO (I do think that languages like Rust are right to default to const, but doing the same thing in C adds a lot of noise IMO).
Re:John Carmack on Inlined Code (2014) by cmroanirgo on Wednesday January 23, 2019 @05:05AM (#18977036)
From the article (and follows my experience):

"Const parameters and const functions are helpful in avoiding side effect related bugs, but the functions are still susceptible to changes in the global execution environment. Trying to make more parameters and functions const is a good exercise, and often ends in casting it away in frustration at some point. That frustration is usually due to finding all sorts of places that state could be modified that weren't immediately obvious -- places for bugs to breed. "