AT&T &r作用

:"=&r"(val)

:"r"(1),"r"(lock):

"&" : Means that this operand is an earlyclobber operand, which is modified before the instruction is finished using the input operands. Therefore, this operand may not lie in a register that is used as an input operand or as part of any memory address.

可以理解为:'&'表示该输出操作('&'只用于修饰输出)完成于其他输入操作完成之前。因此需要确保对应寄存器中的值不能被其他的输入操作篡改。(怎样确保呢?输入输出使用不同的寄存器就行了。实际上'&'约束就是这个意思。)

http://hi.baidu.com/_kouu/blog/item/d4430a81516d16de9123d9f9.html

原文地址:https://www.cnblogs.com/moonflow/p/2461634.html