Add "memory" and "cc" to the clobbers of atomic instructions in ref.hh

The gcc docs say use "memory" if "your assembler instructions access memory in an unpredictable fashion". I don't know what that means, but linux adds "memory" for similar inlines. The gcc docs say use "cc" if "assembler instruction can alter the condition code register". I know what that means, but linux doesn't use it.
上级 a8b456f0
......@@ -52,7 +52,7 @@ public:
// If references is 0 (i.e. ref_.count is 0xffffffff) a 32-bit
// increment will increases ref_.count to 0, but ref_.invalid
// will remain unchanged.
asm volatile("lock; incl %0" : "+m" (ref_.count));
asm volatile("lock; incl %0" : "+m" (ref_.count) :: "memory", "cc");
}
inline bool tryinc() const {
......@@ -64,7 +64,8 @@ public:
unsigned char c;
// If references is 1 (i.e. ref_.v is 0), a 64-bit decrement will
// underflow ref_.invalid to 0xffffffff (and ref_.count to 0xffffffff).
asm volatile("lock; decq %0; sets %1" : "+m" (ref_.v), "=qm" (c));
asm volatile("lock; decq %0; sets %1" : "+m" (ref_.v), "=qm" (c)
:: "memory", "cc");
if (c)
onzero();
}
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论