Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 1 | #ifndef __LINUX_CPUMASK_H |
2 | #define __LINUX_CPUMASK_H |
||
3 | |||
4 | #include <linux/config.h> |
||
5 | #include <linux/kernel.h> |
||
6 | #include <linux/threads.h> |
||
7 | #include <linux/types.h> |
||
8 | #include <linux/bitmap.h> |
||
9 | |||
10 | #if NR_CPUS > BITS_PER_LONG && NR_CPUS != 1 |
||
11 | #define CPU_ARRAY_SIZE BITS_TO_LONGS(NR_CPUS) |
||
12 | |||
13 | struct cpumask |
||
14 | { |
||
15 | unsigned long mask[CPU_ARRAY_SIZE]; |
||
16 | }; |
||
17 | |||
18 | typedef struct cpumask cpumask_t; |
||
19 | |||
20 | #else |
||
21 | typedef unsigned long cpumask_t; |
||
22 | #endif |
||
23 | |||
24 | #ifdef CONFIG_SMP |
||
25 | #if NR_CPUS > BITS_PER_LONG |
||
26 | #include <asm-generic/cpumask_array.h> |
||
27 | #else |
||
28 | #include <asm-generic/cpumask_arith.h> |
||
29 | #endif |
||
30 | #else |
||
31 | #include <asm-generic/cpumask_up.h> |
||
32 | #endif |
||
33 | |||
34 | #if NR_CPUS <= 4*BITS_PER_LONG |
||
35 | #include <asm-generic/cpumask_const_value.h> |
||
36 | #else |
||
37 | #include <asm-generic/cpumask_const_reference.h> |
||
38 | #endif |
||
39 | |||
40 | |||
41 | #ifdef CONFIG_SMP |
||
42 | |||
43 | extern cpumask_t cpu_online_map; |
||
44 | |||
45 | #define num_online_cpus() cpus_weight(cpu_online_map) |
||
46 | #define cpu_online(cpu) cpu_isset(cpu, cpu_online_map) |
||
47 | #else |
||
48 | #define cpu_online_map cpumask_of_cpu(0) |
||
49 | #define num_online_cpus() 1 |
||
50 | #define cpu_online(cpu) ({ BUG_ON((cpu) != 0); 1; }) |
||
51 | #endif |
||
52 | |||
53 | static inline int next_online_cpu(int cpu, cpumask_t map) |
||
54 | { |
||
55 | do |
||
56 | cpu = next_cpu_const(cpu, map); |
||
57 | while (cpu < NR_CPUS && !cpu_online(cpu)); |
||
58 | return cpu; |
||
59 | } |
||
60 | |||
61 | #define for_each_cpu(cpu, map) \ |
||
62 | for (cpu = first_cpu_const(map); \ |
||
63 | cpu < NR_CPUS; \ |
||
64 | cpu = next_cpu_const(cpu,map)) |
||
65 | |||
66 | #define for_each_online_cpu(cpu, map) \ |
||
67 | for (cpu = first_cpu_const(map); \ |
||
68 | cpu < NR_CPUS; \ |
||
69 | cpu = next_online_cpu(cpu,map)) |
||
70 | |||
71 | #endif /* __LINUX_CPUMASK_H */ |