Skip to content

Instantly share code, notes, and snippets.

@topecongiro
Created November 28, 2016 10:59
Show Gist options
  • Save topecongiro/0776bb6b2fada7854af62209953b6f90 to your computer and use it in GitHub Desktop.
Save topecongiro/0776bb6b2fada7854af62209953b6f90 to your computer and use it in GitHub Desktop.
Double-width compare-and-swap implementation without asm such as CMPXCHG16B.
using u128_t = usigned __int128;
bool dwcas(u128_t* ptr, u128_t oldval, u128_t newval) {
return __sync_bool_compare_and_swap(ptr, oldval, newval);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment