- Move assigment operators to top

- Added function to compare and exchage
This commit is contained in:
Jan Stoess 2007-12-07 19:02:42 +01:00
parent 530c77a309
commit 0ab0c02d81
1 changed files with 20 additions and 6 deletions

View File

@ -34,6 +34,12 @@ public:
return val;
}
int operator = (word_t val)
{ return this->val = val; }
int operator = (int val)
{ return this->val = val; }
bool operator == (word_t val)
{ return (this->val == val); }
@ -46,16 +52,24 @@ public:
bool operator != (int val)
{ return (this->val != (word_t) val); }
int operator = (word_t val)
{ return this->val = val; }
int operator = (int val)
{ return this->val = (word_t) val; }
operator word_t (void)
{ return val; }
bool cmpxchg( word_t old_val, word_t new_val )
{
bool result;
__asm__ __volatile__ (
X86_LOCK "cmpxchg %1, %2 \n\t"
"setz %0 \n\t"
: "=a" (result)
: "r" (new_val), "m"(val), "0" (old_val)
: "memory"
);
return (result);
}
private:
word_t val;
};