3 ms·
> "semi-portable C" camp Do you mean the "every CPU is an x86" camp?
by pif 6y ago
> "semi-portable C" camp
Do you mean the "every CPU is an x86" camp?
- jcranmer 6y agoThe concept is closer to the idea that C is portable assembler, and that by writing very specific constructions in C you can reliably control the exact assembly that is emitted.
- raphlinus 6y agoNo, that's the unportable camp, which doesn't have much following these days. Semi-portable basically means that you use #ifdef and similar techniques to control the code that gets generated for the particular CPU and platform. To give one example, a lock-free ring buffer may have memory barriers that are #ifdef'ed out on x86 because you can rely on total store order. Similarly, `volatile` on MSVC can be expected to provide memory ordering guarantees (see https://docs.microsoft.com/en-us/cpp/cpp/volatile-cpp?view=msvc-160 https://docs.microsoft.com/en-us/cpp/cpp/volatile-cpp?view=m...).