c++ - Ambiguous operand size -
what's wrong code? compiler returns ambiguous operand size dec in unlock function. but, there qword keyword (size specifier). and, finally, stupid system wants more details, haven't more details... (red box "it looks post code ... blah blah"). than, wrote more text ...
class spinlock { qword locked; public: spinlock() : locked(-1) { } void lock() __attribute__((noinline)); void unlock() __attribute__((noinline)); }; void spinlock::lock() { asm( ".intel_syntax noprefix;" "xor rcx, rcx;" "loop:;" "lock xchg qword [%0], rcx;" "test rcx, rcx;" "jz loop;" ".att_syntax noprefix;" : : "r"(&locked) : "rcx" ); } void spinlock::unlock() { asm( ".intel_syntax noprefix;" "lock dec qword [%0];" ".att_syntax noprefix;" : : "r"(&locked) : ); }
Comments
Post a Comment