aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/api/odp/cpumask.h
diff options
context:
space:
mode:
Diffstat (limited to 'platform/linux-generic/include/api/odp/cpumask.h')
-rw-r--r--platform/linux-generic/include/api/odp/cpumask.h179
1 files changed, 179 insertions, 0 deletions
diff --git a/platform/linux-generic/include/api/odp/cpumask.h b/platform/linux-generic/include/api/odp/cpumask.h
new file mode 100644
index 000000000..9e970b666
--- /dev/null
+++ b/platform/linux-generic/include/api/odp/cpumask.h
@@ -0,0 +1,179 @@
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP CPU masks and enumeration
+ */
+
+#ifndef ODP_CPUMASK_H_
+#define ODP_CPUMASK_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+#include <sched.h>
+
+#include <odp/std_types.h>
+
+/** @addtogroup odp_scheduler
+ * CPU mask operations.
+ * @{
+ */
+
+/**
+ * CPU mask
+ *
+ * Don't access directly, use access functions.
+ */
+typedef struct odp_cpumask_t {
+ cpu_set_t set; /**< @private Mask*/
+} odp_cpumask_t;
+
+/**
+ * Add CPU mask bits from a string
+ *
+ * @param mask CPU mask to modify
+ * @param str Hexadecimal digits in a string. CPU #0 is located
+ * at the least significant bit (0x1).
+ */
+void odp_cpumask_from_str(odp_cpumask_t *mask, const char *str);
+
+/**
+ * Write CPU mask as a string of hexadecimal digits
+ *
+ * @param mask CPU mask
+ * @param str String for output
+ * @param len Size of string length (incl. ending zero)
+ */
+void odp_cpumask_to_str(const odp_cpumask_t *mask, char *str, int len);
+
+/**
+ * Clear entire mask
+ * @param mask CPU mask to flush with zero value
+ */
+void odp_cpumask_zero(odp_cpumask_t *mask);
+
+/**
+ * Add cpu to mask
+ * @param mask add cpu number in CPU mask
+ * @param cpu CPU number
+ */
+void odp_cpumask_set(odp_cpumask_t *mask, int cpu);
+
+/**
+ * Remove cpu from mask
+ * @param mask clear cpu number from CPU mask
+ * @param cpu CPU number
+ */
+void odp_cpumask_clr(odp_cpumask_t *mask, int cpu);
+
+/**
+ * Test if cpu is a member of mask
+ * @param mask CPU mask to check if cpu num set or not
+ * @param cpu CPU number
+ * @return non-zero if set otherwise 0
+ */
+int odp_cpumask_isset(const odp_cpumask_t *mask, int cpu);
+
+/**
+ * Count number of cpus in mask
+ * @param mask CPU mask
+ * @return cpumask count
+ */
+int odp_cpumask_count(const odp_cpumask_t *mask);
+
+/**
+ * Logical AND over two source masks.
+ *
+ * @param dest Destination mask, can be one of the source masks
+ * @param src1 Source mask 1
+ * @param src2 Source mask 2
+ */
+void odp_cpumask_and(odp_cpumask_t *dest, odp_cpumask_t *src1,
+ odp_cpumask_t *src2);
+
+/**
+ * Logical OR over two source masks.
+ *
+ * @param dest Destination mask, can be one of the source masks
+ * @param src1 Source mask 1
+ * @param src2 Source mask 2
+ */
+void odp_cpumask_or(odp_cpumask_t *dest, odp_cpumask_t *src1,
+ odp_cpumask_t *src2);
+
+/**
+ * Logical XOR over two source masks.
+ *
+ * @param dest Destination mask, can be one of the source masks
+ * @param src1 Source mask 1
+ * @param src2 Source mask 2
+ */
+void odp_cpumask_xor(odp_cpumask_t *dest, odp_cpumask_t *src1,
+ odp_cpumask_t *src2);
+
+/**
+ * Test if two masks contain the same cpus
+ */
+int odp_cpumask_equal(const odp_cpumask_t *mask1,
+ const odp_cpumask_t *mask2);
+
+/**
+ * Copy a CPU mask
+ */
+void odp_cpumask_copy(odp_cpumask_t *dest, const odp_cpumask_t *src);
+
+/**
+ * Find first CPU that is set in the mask
+ *
+ * @param mask is the mask to be searched
+ * @return cpu else -1 if no bits set in cpumask
+ */
+int odp_cpumask_first(const odp_cpumask_t *mask);
+
+/**
+ * Find last CPU that is set in the mask
+ *
+ * @param mask is the mask to be searched
+ * @return cpu else -1 if no bits set in cpumask
+ */
+int odp_cpumask_last(const odp_cpumask_t *mask);
+
+/**
+ * Find next cpu in mask
+ *
+ * Finds the next cpu in the CPU mask, starting at the cpu passed.
+ * Use with odp_cpumask_first to traverse a CPU mask, i.e.
+ *
+ * int cpu = odp_cpumask_first(&mask);
+ * while (0 <= cpu) {
+ * ...
+ * ...
+ * cpu = odp_cpumask_next(&mask, cpu);
+ * }
+ *
+ * @param mask CPU mask to find next cpu in
+ * @param cpu CPU to start from
+ * @return cpu found else -1
+ *
+ * @see odp_cpumask_first()
+ */
+int odp_cpumask_next(const odp_cpumask_t *mask, int cpu);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif