forked from KolibriOS/kolibrios
ddk: 4.4
git-svn-id: svn://kolibrios.org@6082 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <linux/bitmap.h>
|
||||
#include <linux/bug.h>
|
||||
|
||||
/* Don't assign or return these: may not be this big! */
|
||||
typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
|
||||
|
||||
/**
|
||||
@@ -22,6 +23,14 @@ typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
|
||||
*/
|
||||
#define cpumask_bits(maskp) ((maskp)->bits)
|
||||
|
||||
/**
|
||||
* cpumask_pr_args - printf args to output a cpumask
|
||||
* @maskp: cpumask to be printed
|
||||
*
|
||||
* Can be used to provide arguments for '%*pb[l]' when printing a cpumask.
|
||||
*/
|
||||
#define cpumask_pr_args(maskp) nr_cpu_ids, cpumask_bits(maskp)
|
||||
|
||||
#if NR_CPUS == 1
|
||||
#define nr_cpu_ids 1
|
||||
#else
|
||||
@@ -142,10 +151,8 @@ static inline unsigned int cpumask_any_but(const struct cpumask *mask,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp)
|
||||
static inline unsigned int cpumask_local_spread(unsigned int i, int node)
|
||||
{
|
||||
set_bit(0, cpumask_bits(dstp));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -199,7 +206,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
|
||||
|
||||
int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
|
||||
int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
|
||||
int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp);
|
||||
unsigned int cpumask_local_spread(unsigned int i, int node);
|
||||
|
||||
/**
|
||||
* for_each_cpu - iterate over every cpu in a mask
|
||||
@@ -281,11 +288,11 @@ static inline void cpumask_clear_cpu(int cpu, struct cpumask *dstp)
|
||||
* @cpumask: the cpumask pointer
|
||||
*
|
||||
* Returns 1 if @cpu is set in @cpumask, else returns 0
|
||||
*
|
||||
* No static inline type checking - see Subtlety (1) above.
|
||||
*/
|
||||
#define cpumask_test_cpu(cpu, cpumask) \
|
||||
test_bit(cpumask_check(cpu), cpumask_bits((cpumask)))
|
||||
static inline int cpumask_test_cpu(int cpu, const struct cpumask *cpumask)
|
||||
{
|
||||
return test_bit(cpumask_check(cpu), cpumask_bits((cpumask)));
|
||||
}
|
||||
|
||||
/**
|
||||
* cpumask_test_and_set_cpu - atomically test and set a cpu in a cpumask
|
||||
@@ -538,21 +545,6 @@ static inline void cpumask_copy(struct cpumask *dstp,
|
||||
*/
|
||||
#define cpumask_of(cpu) (get_cpu_mask(cpu))
|
||||
|
||||
/**
|
||||
* cpumask_scnprintf - print a cpumask into a string as comma-separated hex
|
||||
* @buf: the buffer to sprintf into
|
||||
* @len: the length of the buffer
|
||||
* @srcp: the cpumask to print
|
||||
*
|
||||
* If len is zero, returns zero. Otherwise returns the length of the
|
||||
* (nul-terminated) @buf string.
|
||||
*/
|
||||
static inline int cpumask_scnprintf(char *buf, int len,
|
||||
const struct cpumask *srcp)
|
||||
{
|
||||
return bitmap_scnprintf(buf, len, cpumask_bits(srcp), nr_cpumask_bits);
|
||||
}
|
||||
|
||||
/**
|
||||
* cpumask_parse_user - extract a cpumask from a user string
|
||||
* @buf: the buffer to extract from
|
||||
@@ -564,7 +556,7 @@ static inline int cpumask_scnprintf(char *buf, int len,
|
||||
static inline int cpumask_parse_user(const char __user *buf, int len,
|
||||
struct cpumask *dstp)
|
||||
{
|
||||
return bitmap_parse_user(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
|
||||
return bitmap_parse_user(buf, len, cpumask_bits(dstp), nr_cpu_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -579,23 +571,7 @@ static inline int cpumask_parselist_user(const char __user *buf, int len,
|
||||
struct cpumask *dstp)
|
||||
{
|
||||
return bitmap_parselist_user(buf, len, cpumask_bits(dstp),
|
||||
nr_cpumask_bits);
|
||||
}
|
||||
|
||||
/**
|
||||
* cpulist_scnprintf - print a cpumask into a string as comma-separated list
|
||||
* @buf: the buffer to sprintf into
|
||||
* @len: the length of the buffer
|
||||
* @srcp: the cpumask to print
|
||||
*
|
||||
* If len is zero, returns zero. Otherwise returns the length of the
|
||||
* (nul-terminated) @buf string.
|
||||
*/
|
||||
static inline int cpulist_scnprintf(char *buf, int len,
|
||||
const struct cpumask *srcp)
|
||||
{
|
||||
return bitmap_scnlistprintf(buf, len, cpumask_bits(srcp),
|
||||
nr_cpumask_bits);
|
||||
nr_cpu_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -610,7 +586,7 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp)
|
||||
char *nl = strchr(buf, '\n');
|
||||
unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf);
|
||||
|
||||
return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
|
||||
return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpu_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -622,7 +598,7 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp)
|
||||
*/
|
||||
static inline int cpulist_parse(const char *buf, struct cpumask *dstp)
|
||||
{
|
||||
return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpumask_bits);
|
||||
return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpu_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -632,9 +608,7 @@ static inline int cpulist_parse(const char *buf, struct cpumask *dstp)
|
||||
*/
|
||||
static inline size_t cpumask_size(void)
|
||||
{
|
||||
/* FIXME: Once all cpumask assignments are eliminated, this
|
||||
* can be nr_cpumask_bits */
|
||||
return BITS_TO_LONGS(NR_CPUS) * sizeof(long);
|
||||
return BITS_TO_LONGS(nr_cpumask_bits) * sizeof(long);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -791,7 +765,7 @@ static inline const struct cpumask *get_cpu_mask(unsigned int cpu)
|
||||
#if NR_CPUS <= BITS_PER_LONG
|
||||
#define CPU_BITS_ALL \
|
||||
{ \
|
||||
[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
|
||||
[BITS_TO_LONGS(NR_CPUS)-1] = BITMAP_LAST_WORD_MASK(NR_CPUS) \
|
||||
}
|
||||
|
||||
#else /* NR_CPUS > BITS_PER_LONG */
|
||||
@@ -799,7 +773,7 @@ static inline const struct cpumask *get_cpu_mask(unsigned int cpu)
|
||||
#define CPU_BITS_ALL \
|
||||
{ \
|
||||
[0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \
|
||||
[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
|
||||
[BITS_TO_LONGS(NR_CPUS)-1] = BITMAP_LAST_WORD_MASK(NR_CPUS) \
|
||||
}
|
||||
#endif /* NR_CPUS > BITS_PER_LONG */
|
||||
|
||||
@@ -817,35 +791,21 @@ static inline ssize_t
|
||||
cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask)
|
||||
{
|
||||
return bitmap_print_to_pagebuf(list, buf, cpumask_bits(mask),
|
||||
nr_cpumask_bits);
|
||||
nr_cpu_ids);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* From here down, all obsolete. Use cpumask_ variants!
|
||||
*
|
||||
*/
|
||||
#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
|
||||
#define cpumask_of_cpu(cpu) (*get_cpu_mask(cpu))
|
||||
|
||||
#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
|
||||
|
||||
#if NR_CPUS <= BITS_PER_LONG
|
||||
|
||||
#define CPU_MASK_ALL \
|
||||
(cpumask_t) { { \
|
||||
[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
|
||||
[BITS_TO_LONGS(NR_CPUS)-1] = BITMAP_LAST_WORD_MASK(NR_CPUS) \
|
||||
} }
|
||||
|
||||
#else
|
||||
|
||||
#define CPU_MASK_ALL \
|
||||
(cpumask_t) { { \
|
||||
[0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \
|
||||
[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
|
||||
[BITS_TO_LONGS(NR_CPUS)-1] = BITMAP_LAST_WORD_MASK(NR_CPUS) \
|
||||
} }
|
||||
|
||||
#endif
|
||||
#endif /* NR_CPUS > BITS_PER_LONG */
|
||||
|
||||
#define CPU_MASK_NONE \
|
||||
(cpumask_t) { { \
|
||||
@@ -857,143 +817,4 @@ cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask)
|
||||
[0] = 1UL \
|
||||
} }
|
||||
|
||||
#if NR_CPUS == 1
|
||||
#define first_cpu(src) ({ (void)(src); 0; })
|
||||
#define next_cpu(n, src) ({ (void)(src); 1; })
|
||||
#define any_online_cpu(mask) 0
|
||||
#define for_each_cpu_mask(cpu, mask) \
|
||||
for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
|
||||
#else /* NR_CPUS > 1 */
|
||||
int __first_cpu(const cpumask_t *srcp);
|
||||
int __next_cpu(int n, const cpumask_t *srcp);
|
||||
|
||||
#define first_cpu(src) __first_cpu(&(src))
|
||||
#define next_cpu(n, src) __next_cpu((n), &(src))
|
||||
#define any_online_cpu(mask) cpumask_any_and(&mask, cpu_online_mask)
|
||||
#define for_each_cpu_mask(cpu, mask) \
|
||||
for ((cpu) = -1; \
|
||||
(cpu) = next_cpu((cpu), (mask)), \
|
||||
(cpu) < NR_CPUS; )
|
||||
#endif /* SMP */
|
||||
|
||||
#if NR_CPUS <= 64
|
||||
|
||||
#define for_each_cpu_mask_nr(cpu, mask) for_each_cpu_mask(cpu, mask)
|
||||
|
||||
#else /* NR_CPUS > 64 */
|
||||
|
||||
int __next_cpu_nr(int n, const cpumask_t *srcp);
|
||||
#define for_each_cpu_mask_nr(cpu, mask) \
|
||||
for ((cpu) = -1; \
|
||||
(cpu) = __next_cpu_nr((cpu), &(mask)), \
|
||||
(cpu) < nr_cpu_ids; )
|
||||
|
||||
#endif /* NR_CPUS > 64 */
|
||||
|
||||
#define cpus_addr(src) ((src).bits)
|
||||
|
||||
#define cpu_set(cpu, dst) __cpu_set((cpu), &(dst))
|
||||
static inline void __cpu_set(int cpu, volatile cpumask_t *dstp)
|
||||
{
|
||||
set_bit(cpu, dstp->bits);
|
||||
}
|
||||
|
||||
#define cpu_clear(cpu, dst) __cpu_clear((cpu), &(dst))
|
||||
static inline void __cpu_clear(int cpu, volatile cpumask_t *dstp)
|
||||
{
|
||||
clear_bit(cpu, dstp->bits);
|
||||
}
|
||||
|
||||
#define cpus_setall(dst) __cpus_setall(&(dst), NR_CPUS)
|
||||
static inline void __cpus_setall(cpumask_t *dstp, int nbits)
|
||||
{
|
||||
bitmap_fill(dstp->bits, nbits);
|
||||
}
|
||||
|
||||
#define cpus_clear(dst) __cpus_clear(&(dst), NR_CPUS)
|
||||
static inline void __cpus_clear(cpumask_t *dstp, int nbits)
|
||||
{
|
||||
bitmap_zero(dstp->bits, nbits);
|
||||
}
|
||||
|
||||
/* No static inline type checking - see Subtlety (1) above. */
|
||||
#define cpu_isset(cpu, cpumask) test_bit((cpu), (cpumask).bits)
|
||||
|
||||
#define cpu_test_and_set(cpu, cpumask) __cpu_test_and_set((cpu), &(cpumask))
|
||||
static inline int __cpu_test_and_set(int cpu, cpumask_t *addr)
|
||||
{
|
||||
return test_and_set_bit(cpu, addr->bits);
|
||||
}
|
||||
|
||||
#define cpus_and(dst, src1, src2) __cpus_and(&(dst), &(src1), &(src2), NR_CPUS)
|
||||
static inline int __cpus_and(cpumask_t *dstp, const cpumask_t *src1p,
|
||||
const cpumask_t *src2p, int nbits)
|
||||
{
|
||||
return bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits);
|
||||
}
|
||||
|
||||
#define cpus_or(dst, src1, src2) __cpus_or(&(dst), &(src1), &(src2), NR_CPUS)
|
||||
static inline void __cpus_or(cpumask_t *dstp, const cpumask_t *src1p,
|
||||
const cpumask_t *src2p, int nbits)
|
||||
{
|
||||
bitmap_or(dstp->bits, src1p->bits, src2p->bits, nbits);
|
||||
}
|
||||
|
||||
#define cpus_xor(dst, src1, src2) __cpus_xor(&(dst), &(src1), &(src2), NR_CPUS)
|
||||
static inline void __cpus_xor(cpumask_t *dstp, const cpumask_t *src1p,
|
||||
const cpumask_t *src2p, int nbits)
|
||||
{
|
||||
bitmap_xor(dstp->bits, src1p->bits, src2p->bits, nbits);
|
||||
}
|
||||
|
||||
#define cpus_andnot(dst, src1, src2) \
|
||||
__cpus_andnot(&(dst), &(src1), &(src2), NR_CPUS)
|
||||
static inline int __cpus_andnot(cpumask_t *dstp, const cpumask_t *src1p,
|
||||
const cpumask_t *src2p, int nbits)
|
||||
{
|
||||
return bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits);
|
||||
}
|
||||
|
||||
#define cpus_equal(src1, src2) __cpus_equal(&(src1), &(src2), NR_CPUS)
|
||||
static inline int __cpus_equal(const cpumask_t *src1p,
|
||||
const cpumask_t *src2p, int nbits)
|
||||
{
|
||||
return bitmap_equal(src1p->bits, src2p->bits, nbits);
|
||||
}
|
||||
|
||||
#define cpus_intersects(src1, src2) __cpus_intersects(&(src1), &(src2), NR_CPUS)
|
||||
static inline int __cpus_intersects(const cpumask_t *src1p,
|
||||
const cpumask_t *src2p, int nbits)
|
||||
{
|
||||
return bitmap_intersects(src1p->bits, src2p->bits, nbits);
|
||||
}
|
||||
|
||||
#define cpus_subset(src1, src2) __cpus_subset(&(src1), &(src2), NR_CPUS)
|
||||
static inline int __cpus_subset(const cpumask_t *src1p,
|
||||
const cpumask_t *src2p, int nbits)
|
||||
{
|
||||
return bitmap_subset(src1p->bits, src2p->bits, nbits);
|
||||
}
|
||||
|
||||
#define cpus_empty(src) __cpus_empty(&(src), NR_CPUS)
|
||||
static inline int __cpus_empty(const cpumask_t *srcp, int nbits)
|
||||
{
|
||||
return bitmap_empty(srcp->bits, nbits);
|
||||
}
|
||||
|
||||
#define cpus_weight(cpumask) __cpus_weight(&(cpumask), NR_CPUS)
|
||||
static inline int __cpus_weight(const cpumask_t *srcp, int nbits)
|
||||
{
|
||||
return bitmap_weight(srcp->bits, nbits);
|
||||
}
|
||||
|
||||
#define cpus_shift_left(dst, src, n) \
|
||||
__cpus_shift_left(&(dst), &(src), (n), NR_CPUS)
|
||||
static inline void __cpus_shift_left(cpumask_t *dstp,
|
||||
const cpumask_t *srcp, int n, int nbits)
|
||||
{
|
||||
bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS */
|
||||
|
||||
#endif /* __LINUX_CPUMASK_H */
|
||||
|
Reference in New Issue
Block a user