diff options
author | Karel Zak | 2011-09-09 08:19:24 +0200 |
---|---|---|
committer | Karel Zak | 2011-09-09 23:27:40 +0200 |
commit | e9d659ea8578c5a7175e9200868fc5da8148fbe7 (patch) | |
tree | b92b85fa796f232fdbe0c72fc251893c35b92a65 /include/cpuset.h | |
parent | lscpu: cleanup output modes (diff) | |
download | kernel-qcow2-util-linux-e9d659ea8578c5a7175e9200868fc5da8148fbe7.tar.gz kernel-qcow2-util-linux-e9d659ea8578c5a7175e9200868fc5da8148fbe7.tar.xz kernel-qcow2-util-linux-e9d659ea8578c5a7175e9200868fc5da8148fbe7.zip |
lscpu: use function to search in cpu masks arrays
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/cpuset.h')
-rw-r--r-- | include/cpuset.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/cpuset.h b/include/cpuset.h index f65c0cad7..47ddfe2ef 100644 --- a/include/cpuset.h +++ b/include/cpuset.h @@ -61,6 +61,26 @@ extern int __cpuset_count_s(size_t setsize, const cpu_set_t *set); #define cpuset_nbits(setsize) (8 * (setsize)) +/* + * The @idx parametr returns an index of the first mask from @ary array where + * the @cpu is set. + * + * Returns: 0 if found, otherwise 1. + */ +static inline int cpuset_ary_isset(size_t cpu, cpu_set_t **ary, size_t nmemb, + size_t setsize, size_t *idx) +{ + size_t i; + + for (i = 0; i < nmemb; i++) { + if (CPU_ISSET_S(cpu, setsize, ary[i])) { + *idx = i; + return 0; + } + } + return 1; +} + extern int get_max_number_of_cpus(void); extern cpu_set_t *cpuset_alloc(int ncpus, size_t *setsize, size_t *nbits); |