File: cpumask.h

package info (click to toggle)
linux-kernel-headers 2.5.999-test7-bk-17
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 28,268 kB
  • ctags: 214,024
  • sloc: ansic: 324,929; cpp: 783; makefile: 79; asm: 61; sh: 61
file content (71 lines) | stat: -rw-r--r-- 1,515 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef __LINUX_CPUMASK_H
#define __LINUX_CPUMASK_H

#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/threads.h>
#include <linux/types.h>
#include <linux/bitmap.h>

#if NR_CPUS > BITS_PER_LONG && NR_CPUS != 1
#define CPU_ARRAY_SIZE		BITS_TO_LONGS(NR_CPUS)

struct cpumask
{
	unsigned long mask[CPU_ARRAY_SIZE];
};

typedef struct cpumask cpumask_t;

#else
typedef unsigned long cpumask_t;
#endif

#ifdef CONFIG_SMP
#if NR_CPUS > BITS_PER_LONG
#include <asm-generic/cpumask_array.h>
#else
#include <asm-generic/cpumask_arith.h>
#endif
#else
#include <asm-generic/cpumask_up.h>
#endif

#if NR_CPUS <= 4*BITS_PER_LONG
#include <asm-generic/cpumask_const_value.h>
#else
#include <asm-generic/cpumask_const_reference.h>
#endif


#ifdef CONFIG_SMP

extern cpumask_t cpu_online_map;

#define num_online_cpus()		cpus_weight(cpu_online_map)
#define cpu_online(cpu)			cpu_isset(cpu, cpu_online_map)
#else
#define	cpu_online_map			cpumask_of_cpu(0)
#define num_online_cpus()		1
#define cpu_online(cpu)			({ BUG_ON((cpu) != 0); 1; })
#endif

static inline int next_online_cpu(int cpu, cpumask_t map)
{
	do
		cpu = next_cpu_const(cpu, map);
	while (cpu < NR_CPUS && !cpu_online(cpu));
	return cpu;
}

#define for_each_cpu(cpu, map)						\
	for (cpu = first_cpu_const(map);				\
		cpu < NR_CPUS;						\
		cpu = next_cpu_const(cpu,map))

#define for_each_online_cpu(cpu, map)					\
	for (cpu = first_cpu_const(map);				\
		cpu < NR_CPUS;						\
		cpu = next_online_cpu(cpu,map))

#endif /* __LINUX_CPUMASK_H */