broken Atomic.cpp on Darwin

There is no __sync_synchronize or __sync_val_compare_and_swap on Mac
OS X. One might use OSMemoryBarrier or OSAtomicCompareAndSwap32
instead. The patch is attached.

- xi

patch (1.22 KB)

Actually, __sync_synchronize and __sync_val_compare_and_swap DO exist on Darwin, but only if you use Apple’s GCC 4.2 (or later), just as it is on Linux. We always want to use these intrinsic versions if possible, because they’re much lower overhead.

The policy Chris has proposed is that we simply do not support multithreaded LLVM with a host compiler pre-GCC 4.2. If you need multithreaded LLVM on an unsupported platform, you can build a single threaded LLVM and LLVM-GCC, and then use that to build a multithreaded LLVM.


Thanks. I think I am using Apple GCC 4.2.

i686-apple-darwin9-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5566)

Should I use something else for LLVM?

- xi

No, that should work fine, and is exactly what I use to compile atomics on Darwin.


sorry, i checked my installation again. the symbolic link of g++
pointed to g++-4.0 (weird) while that of gcc pointed to gcc-4.2. my
bad. sorry again & thanks!