sparc wants this. include/asm-generic/cpumask_arith.h | 61 ++++++++++++++++++++++++++++++++++++ include/linux/cpumask.h | 9 +++++ 2 files changed, 70 insertions(+) diff -puN /dev/null include/asm-generic/cpumask_arith.h --- /dev/null 2002-08-30 16:31:37.000000000 -0700 +++ 25-akpm/include/asm-generic/cpumask_arith.h 2003-08-02 19:29:40.000000000 -0700 @@ -0,0 +1,61 @@ +#ifndef __ASM_GENERIC_CPUMASK_ARITH_H +#define __ASM_GENERIC_CPUMASK_ARITH_H + +#define cpu_set(cpu, map) \ + do { \ + map |= ((cpumask_t)1) << (cpu); \ + } while (0) +#define cpu_clear(cpu, map) \ + do { \ + map &= ~(((cpumask_t)1) << (cpu)); \ + } while (0) +#define cpu_isset(cpu, map) \ + ((map) & (((cpumask_t)1) << (cpu))) +#define cpu_test_and_set(cpu, map) \ + test_and_set_bit(cpu, (unsigned long *)(&(map))) + +#define cpus_and(dst,src1,src2) do { dst = (src1) & (src2); } while (0) +#define cpus_or(dst,src1,src2) do { dst = (src1) | (src2); } while (0) +#define cpus_clear(map) do { map = 0; } while (0) +#define cpus_complement(map) do { map = ~(map); } while (0) +#define cpus_equal(map1, map2) ((map1) == (map2)) +#define cpus_empty(map) ((map) == 0) + +#if BITS_PER_LONG == 32 +#if NR_CPUS <= 32 +#define cpus_weight(map) hweight32(map) +#else +#define cpus_weight(map) \ +({ \ + u32 *__map = (u32 *)(&(map)); \ + hweight32(__map[0]) + hweight32(__map[1]); \ +}) +#endif +#elif BITS_PER_LONG == 64 +#define cpus_weight(map) hweight64(map) +#endif + +#define cpus_shift_right(dst, src, n) do { dst = (src) >> (n); } while (0) +#define cpus_shift_left(dst, src, n) do { dst = (src) >> (n); } while (0) + +#define any_online_cpu(map) (!cpus_empty(map)) + + +#define CPU_MASK_ALL (~((cpumask_t)0) >> (8*sizeof(cpumask_t) - NR_CPUS)) +#define CPU_MASK_NONE ((cpumask_t)0) + +/* only ever use this for things that are _never_ used on large boxen */ +#define cpus_coerce(map) ((unsigned long)(map)) +#define cpus_promote(map) ({ map; }) +#define cpumask_of_cpu(cpu) ({ ((cpumask_t)1) << (cpu); }) + +#ifdef CONFIG_SMP +#define first_cpu(map) __ffs(map) +#define next_cpu(cpu, map) \ + __ffs((map) & ~(((cpumask_t)1 << (cpu)) - 1)) +#else +#define first_cpu(map) 0 +#define next_cpu(cpu, map) 1 +#endif /* CONFIG_SMP */ + +#endif /* __ASM_GENERIC_CPUMASK_ARITH_H */ diff -puN include/linux/cpumask.h~cpumask-arith-fix include/linux/cpumask.h --- 25/include/linux/cpumask.h~cpumask-arith-fix 2003-08-02 19:29:40.000000000 -0700 +++ 25-akpm/include/linux/cpumask.h 2003-08-02 19:29:40.000000000 -0700 @@ -7,6 +7,7 @@ #include #include +#if NR_CPUS > BITS_PER_LONG && NR_CPUS != 1 #define CPU_ARRAY_SIZE BITS_TO_LONGS(NR_CPUS) struct cpumask @@ -16,9 +17,17 @@ struct cpumask typedef struct cpumask cpumask_t; +#else +typedef unsigned long cpumask_t; +#endif + #ifdef CONFIG_SMP +#if NR_CPUS > BITS_PER_LONG #include #else +#include +#endif +#else #include #endif _