Commit ebce385d authored by Tomasz Kulasek's avatar Tomasz Kulasek Committed by Ben Walker
Browse files

lib/util/cpuset: add negate and xor



Change-Id: I8d2fc9d0fcc6cb8b088c307d1520f0b1051c3ef6
Signed-off-by: default avatarTomasz Kulasek <tomaszx.kulasek@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/443518


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 7b0579df
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -100,6 +100,21 @@ void spdk_cpuset_and(struct spdk_cpuset *dst, const struct spdk_cpuset *src);
 */
void spdk_cpuset_or(struct spdk_cpuset *dst, const struct spdk_cpuset *src);

/**
 * Perform XOR operation on two CPU sets. The result is stored in dst.
 *
 * \param dst First argument of operation. This value also stores the result of operation.
 * \param src Second argument of operation.
 */
void spdk_cpuset_xor(struct spdk_cpuset *dst, const struct spdk_cpuset *src);

/**
 * Negate all CPUs in CPU set.
 *
 * \param set CPU set to be negated. This value also stores the result of operation.
 */
void spdk_cpuset_negate(struct spdk_cpuset *set);

/**
 * Clear all CPUs in CPU set.
 *
+21 −0
Original line number Diff line number Diff line
@@ -67,6 +67,16 @@ spdk_cpuset_copy(struct spdk_cpuset *set1, const struct spdk_cpuset *set2)
	memcpy(&set1->cpus, &set2->cpus, sizeof(set2->cpus));
}

void
spdk_cpuset_negate(struct spdk_cpuset *set)
{
	unsigned int i;
	assert(set != NULL);
	for (i = 0; i < sizeof(set->cpus); i++) {
		set->cpus[i] = ~set->cpus[i];
	}
}

void
spdk_cpuset_and(struct spdk_cpuset *set1, const struct spdk_cpuset *set2)
{
@@ -89,6 +99,17 @@ spdk_cpuset_or(struct spdk_cpuset *set1, const struct spdk_cpuset *set2)
	}
}

void
spdk_cpuset_xor(struct spdk_cpuset *set1, const struct spdk_cpuset *set2)
{
	unsigned int i;
	assert(set1 != NULL);
	assert(set2 != NULL);
	for (i = 0; i < sizeof(set2->cpus); i++) {
		set1->cpus[i] ^= set2->cpus[i];
	}
}

void
spdk_cpuset_zero(struct spdk_cpuset *set)
{