
On Thu, Jul 17, 2014 at 12:23 AM, Páli Gábor János
2014-07-16 23:56 GMT+02:00 Johan Tibell
: My reading of the docs was that if the platform doesn't support the needed instructions then GCC will generated a call to e.g. __sync_fetch_and_add_1, where that function *is provided by GCC* as a fallback.
I guess GCC would expect that somebody else will implement the given functionality by an external function.
Now I'm wondering if I'm supposed to supply that fallback.
I was told that you cannot reliably emulate those operations in user mode, without loss in performance.
I think loss on performance is OK on i386, but not loss of correctness. In my mind we have 3 options: 1. Raise a compile time error saying that these operations aren't supported on your platform (somewhat hard to detect as it depends on GCC). 2. Raise a runtime error saying the same (easy to detect, just raise from the fallback functions). 3. Provide some fallback. I don't know how to do (3), but it seems like the best option if possible.