Commit b61ba34c authored by Victor Lopez's avatar Victor Lopez

Implement CpuSet substract operation

parent 29ad06b4
......@@ -67,6 +67,8 @@ class CpuSet
// Default constructor
CpuSet(): _mask() {}
CpuSet( int cpuid ): _mask() { set(cpuid); }
// Destructor
~CpuSet() {}
......@@ -105,6 +107,7 @@ class CpuSet
friend CpuSet operator&( const CpuSet& lhs, const CpuSet& rhs );
friend CpuSet operator+( const CpuSet& lhs, const CpuSet& rhs );
friend CpuSet operator*( const CpuSet& lhs, const CpuSet& rhs );
friend CpuSet operator-( const CpuSet& lhs, const CpuSet& rhs );
friend bool operator==( const CpuSet& lhs, const CpuSet& rhs );
friend bool operator!=( const CpuSet& lhs, const CpuSet& rhs );
......@@ -235,6 +238,14 @@ inline CpuSet operator*( const CpuSet& lhs, const CpuSet& rhs )
return lhs & rhs;
}
inline CpuSet operator-( const CpuSet& lhs, const CpuSet& rhs )
{
CpuSet result;
CPU_XOR( &result._mask, &lhs._mask, &rhs._mask );
CPU_AND( &result._mask, &lhs._mask, &result._mask );
return result;
}
inline bool operator==( const CpuSet& lhs, const CpuSet& rhs )
{
return CPU_EQUAL( &lhs._mask, &rhs._mask );
......
......@@ -57,6 +57,7 @@ int main(int argc, char *argv[])
assert((set1 + set2).size()==4); /* 1111 */
assert((set1 & set2).size()==1); /* 0001 */
assert((set1 * set2).size()==1); /* 0001 */
assert((set1 - set2).size()==2); /* 0110 */
// Compound assignment operators
set2 = set1; /* 0111 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment