Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Why does __sync_add_and_fetch work for a 64 bit variable on a 32 bit system?
- value = dest;
- While(!CAS8B(&dest,value,value + 1))
- {
- value = dest;
- }
- oldValue = *dest;
- do {
- newValue = oldValue+1;
- } while (!compare_and_swap(dest, &oldValue, newValue));
- bool compare_and_swap (int *dest, int *oldVal, int newVal)
- {
- do atomically {
- if ( *oldVal == *dest ) {
- *dest = newVal;
- return true;
- } else {
- *oldVal = *dest;
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment