Rust currently offers access to many atomic intrinsics: http://doc.rust-lang.org/std/intrinsics/ . They are all based on the atomics implemented in LLVM for C11/C++11.
However, when trying to port some lock-free algorithms, I found that several operations which are supported by LLVM are not exposed by Rust. I am willing to do the work to add them in, but I would like to know first if there is a reason they have been omitted, and what the process is for contributing such a change (one issue on the bug tracker, a RFC, one per modification ?)
Here are the several categories of missing intrinsics I’ve noticed:
1) Compare and exchange with two memory orders
In C11/C++11, compare and exchange is unique in that it takes two different memory orders (the extra argument for atomics that decides which barriers should be added by the compiler): one in case it succeeds, and one in case it fails (always weaker than or equal to the other one). However, rust only allows the programmer to specify the memory order in case of success, picking the strongest possible for the failure case.
2) Weak compare and exchange
On some architectures including ARM and Power it is significantly cheaper to implement compare and exchange when it is allowed to fail spuriously. The programmer can opt in this behaviour in C/C++, it would also be useful in Rust. It could either be an extra boolean argument to compare and exchange, or more likely by duplicating the intrinsics with the “weak” prefix.
3) Different sizes
There has already been some discussion on this on the issue tracker, but it did not result in any clear decision: It seems that 128 bits atomics are controversial for portability reasons, but I would expect u8/u16/u32 at least to be easily portable.
Please note that I am talking here about the unstable atomic intrinsics, not (at least for the moment) the stable interface that mirrors them. Obviously, it would probably be easy to also modifiy AtomicPtr, AtomicBool, etc… later on.