]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/spdk/lib/util/cpuset.c
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / lib / util / cpuset.c
index 1a02e59fe98ed88c99a2edb8020800b6ec0ad1cb..fdcfd71598ef71017a6da5bd3f25b5df0a17dcb3 100644 (file)
@@ -35,7 +35,7 @@
 #include "spdk/log.h"
 
 struct spdk_cpuset {
-       char str[SPDK_CPUSET_SIZE / 4];
+       char str[SPDK_CPUSET_SIZE / 4 + 1];
        uint8_t cpus[SPDK_CPUSET_SIZE / 8];
 };
 
@@ -60,32 +60,53 @@ spdk_cpuset_equal(const struct spdk_cpuset *set1, const struct spdk_cpuset *set2
 }
 
 void
-spdk_cpuset_copy(struct spdk_cpuset *set1, const struct spdk_cpuset *set2)
+spdk_cpuset_copy(struct spdk_cpuset *dst, const struct spdk_cpuset *src)
 {
-       assert(set1 != NULL);
-       assert(set2 != NULL);
-       memcpy(&set1->cpus, &set2->cpus, sizeof(set2->cpus));
+       assert(dst != NULL);
+       assert(src != NULL);
+       memcpy(&dst->cpus, &src->cpus, sizeof(src->cpus));
 }
 
 void
-spdk_cpuset_and(struct spdk_cpuset *set1, const struct spdk_cpuset *set2)
+spdk_cpuset_negate(struct spdk_cpuset *set)
 {
        unsigned int i;
-       assert(set1 != NULL);
-       assert(set2 != NULL);
-       for (i = 0; i < sizeof(set2->cpus); i++) {
-               set1->cpus[i] &= set2->cpus[i];
+       assert(set != NULL);
+       for (i = 0; i < sizeof(set->cpus); i++) {
+               set->cpus[i] = ~set->cpus[i];
        }
 }
 
 void
-spdk_cpuset_or(struct spdk_cpuset *set1, const struct spdk_cpuset *set2)
+spdk_cpuset_and(struct spdk_cpuset *dst, const struct spdk_cpuset *src)
 {
        unsigned int i;
-       assert(set1 != NULL);
-       assert(set2 != NULL);
-       for (i = 0; i < sizeof(set2->cpus); i++) {
-               set1->cpus[i] |= set2->cpus[i];
+       assert(dst != NULL);
+       assert(src != NULL);
+       for (i = 0; i < sizeof(src->cpus); i++) {
+               dst->cpus[i] &= src->cpus[i];
+       }
+}
+
+void
+spdk_cpuset_or(struct spdk_cpuset *dst, const struct spdk_cpuset *src)
+{
+       unsigned int i;
+       assert(dst != NULL);
+       assert(src != NULL);
+       for (i = 0; i < sizeof(src->cpus); i++) {
+               dst->cpus[i] |= src->cpus[i];
+       }
+}
+
+void
+spdk_cpuset_xor(struct spdk_cpuset *dst, const struct spdk_cpuset *src)
+{
+       unsigned int i;
+       assert(dst != NULL);
+       assert(src != NULL);
+       for (i = 0; i < sizeof(src->cpus); i++) {
+               dst->cpus[i] ^= src->cpus[i];
        }
 }