blob: 5f97dc25ef9c925fb68b83fecec5a7c0114ab339 [file] [log] [blame]
Andrew Mortonccb46002006-03-25 03:08:08 -08001#include <linux/kernel.h>
2#include <linux/bitops.h>
3#include <linux/cpumask.h>
4#include <linux/module.h>
5
6int __first_cpu(const cpumask_t *srcp)
7{
8 return min_t(int, NR_CPUS, find_first_bit(srcp->bits, NR_CPUS));
9}
10EXPORT_SYMBOL(__first_cpu);
11
Andrew Morton3d18bd72006-03-25 03:08:09 -080012int __next_cpu(int n, const cpumask_t *srcp)
13{
14 return min_t(int, NR_CPUS, find_next_bit(srcp->bits, NR_CPUS, n+1));
15}
16EXPORT_SYMBOL(__next_cpu);
Andrew Morton86302822006-03-25 03:08:09 -080017
Mike Travis41df0d612008-05-12 21:21:13 +020018#if NR_CPUS > 64
19int __next_cpu_nr(int n, const cpumask_t *srcp)
20{
21 return min_t(int, nr_cpu_ids,
22 find_next_bit(srcp->bits, nr_cpu_ids, n+1));
23}
24EXPORT_SYMBOL(__next_cpu_nr);
25#endif
26
Andrew Morton96a9b4d2006-03-25 03:08:10 -080027int __any_online_cpu(const cpumask_t *mask)
28{
29 int cpu;
30
31 for_each_cpu_mask(cpu, *mask) {
32 if (cpu_online(cpu))
33 break;
34 }
35 return cpu;
36}
37EXPORT_SYMBOL(__any_online_cpu);