What's the best way to get atomic/CAS instructions in C/C++, while keeping
your code as portable as possible?

Unfortunately, the best looking solution so far looks like depending on
GCC's intrinsics, (since it's so widespread), but it doesn't sound right.
There's also a project from HP,
http://www.hpl.hp.com/research/linux/atomic_ops/, but it seems too
heavyweight.

I can use C++11, but (1) not good for C (2) still not as widespread as C++
is.

A way which is also compatible with windows, is a big plus.

PS,
The natural place for this looks like the pthread standard. Probably this
sort of thing weren't that popular back then when the standard was written.
_______________________________________________
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il

Reply via email to