On Sat,  5 Mar 2005 00:24:10 -0500, [EMAIL PROTECTED] wrote:

>> static __inline__ void atomic_add(atomic_t *v, int i)
>> {
>>      __asm__ __volatile__("addl %1,%0" : "+m" (*v) : "d" (i));
>> }
>>
>> Then the compiler complains with:
>>
>> /asm/atomic.h:33: warning: read-write constraint does not allow a register
>>
>> So is the warning wrong?
>
> Yes, the warning is wrong, and the text in the manual about '+' is also
> nonsense.  Support for '+' is asms was specifically introduced to make
> it safe to have read-write memory operands.  Jason, the point of using '+'
> is that the matched parts start out as the same, and the compiler is
> supposed to keep them the same.

Well, I assumed the same thing when I started poking at that code, but then
someone pointed out that it didn't actually work that way, and as I recall
the code does in fact assume a register.  I certainly would not object to
making '+' work properly for memory operands, but simply asserting that it
already does is wrong.

Jason

Reply via email to