Skip to content
Snippets Groups Projects
Commit 84dff710 authored by parcs's avatar parcs
Browse files

Fix the definition of cas() on x86 (#8219)

*p is both read and written to by the cmpxchg instruction, and therefore
should be given the '+' constraint modifier.

(In GCC's extended ASM language, '+' means that the operand is both read
and written to whereas '=' means that it is only written to.)

Otherwise, the compiler is allowed to rewrite something like

SpinLock lock;
initSpinLock(&lock);       /* sets lock = 1 */
ACQUIRE_SPIN_LOCK(&lock);

into

SpinLock lock;
ACQUIRE_SPIN_LOCK(&lock);

because according to the asm statement, the previous value of 'lock' is
not important.
parent 93a04b49
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment