Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 1 | #ifndef __ASM_GENERIC_CPUMASK_ARRAY_H |
2 | #define __ASM_GENERIC_CPUMASK_ARRAY_H |
||
3 | |||
4 | /* |
||
5 | * Array-based cpu bitmaps. An array of unsigned longs is used to contain |
||
6 | * the bitmap, and then contained in a structure so it may be passed by |
||
7 | * value. |
||
8 | */ |
||
9 | |||
10 | #define CPU_ARRAY_SIZE BITS_TO_LONGS(NR_CPUS) |
||
11 | |||
12 | #define cpu_set(cpu, map) set_bit(cpu, (map).mask) |
||
13 | #define cpu_clear(cpu, map) clear_bit(cpu, (map).mask) |
||
14 | #define cpu_isset(cpu, map) test_bit(cpu, (map).mask) |
||
15 | #define cpu_test_and_set(cpu, map) test_and_set_bit(cpu, (map).mask) |
||
16 | |||
17 | #define cpus_and(dst,src1,src2) bitmap_and((dst).mask,(src1).mask, (src2).mask, NR_CPUS) |
||
18 | #define cpus_or(dst,src1,src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, NR_CPUS) |
||
19 | #define cpus_clear(map) bitmap_clear((map).mask, NR_CPUS) |
||
20 | #define cpus_complement(map) bitmap_complement((map).mask, NR_CPUS) |
||
21 | #define cpus_equal(map1, map2) bitmap_equal((map1).mask, (map2).mask, NR_CPUS) |
||
22 | #define cpus_empty(map) bitmap_empty(map.mask, NR_CPUS) |
||
23 | #define cpus_weight(map) bitmap_weight((map).mask, NR_CPUS) |
||
24 | #define cpus_shift_right(d, s, n) bitmap_shift_right((d).mask, (s).mask, n, NR_CPUS) |
||
25 | #define cpus_shift_left(d, s, n) bitmap_shift_left((d).mask, (s).mask, n, NR_CPUS) |
||
26 | #define first_cpu(map) find_first_bit((map).mask, NR_CPUS) |
||
27 | #define next_cpu(cpu, map) find_next_bit((map).mask, NR_CPUS, cpu + 1) |
||
28 | |||
29 | /* only ever use this for things that are _never_ used on large boxen */ |
||
30 | #define cpus_coerce(map) ((map).mask[0]) |
||
31 | #define cpus_promote(map) ({ cpumask_t __cpu_mask = CPU_MASK_NONE;\ |
||
32 | __cpu_mask.mask[0] = map; \ |
||
33 | __cpu_mask; \ |
||
34 | }) |
||
35 | #define cpumask_of_cpu(cpu) ({ cpumask_t __cpu_mask = CPU_MASK_NONE;\ |
||
36 | cpu_set(cpu, __cpu_mask); \ |
||
37 | __cpu_mask; \ |
||
38 | }) |
||
39 | #define any_online_cpu(map) \ |
||
40 | ({ \ |
||
41 | cpumask_t __tmp__; \ |
||
42 | cpus_and(__tmp__, map, cpu_online_map); \ |
||
43 | find_first_bit(__tmp__.mask, NR_CPUS); \ |
||
44 | }) |
||
45 | |||
46 | |||
47 | /* |
||
48 | * um, these need to be usable as static initializers |
||
49 | */ |
||
50 | #define CPU_MASK_ALL { {[0 ... CPU_ARRAY_SIZE-1] = ~0UL} } |
||
51 | #define CPU_MASK_NONE { {[0 ... CPU_ARRAY_SIZE-1] = 0UL} } |
||
52 | |||
53 | #endif /* __ASM_GENERIC_CPUMASK_ARRAY_H */ |