}
EXPORT_SYMBOL(__bitmap_complement);
-/*
- * __bitmap_shift_right - logical right shift of the bits in a bitmap
- * @dst - destination bitmap
- * @src - source bitmap
- * @nbits - shift by this many bits
- * @bits - bitmap size, in bits
- *
- * Shifting right (dividing) means moving bits in the MS -> LS bit
- * direction. Zeros are fed into the vacated MS positions and the
- * LS bits shifted off the bottom are lost.
- */
-void __bitmap_shift_right(unsigned long *dst,
- const unsigned long *src, int shift, int bits)
-{
- int k, lim = BITS_TO_LONGS(bits), left = bits % BITS_PER_LONG;
- int off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG;
- unsigned long mask = (1UL << left) - 1;
- for (k = 0; off + k < lim; ++k) {
- unsigned long upper, lower;
-
- /*
- * If shift is not word aligned, take lower rem bits of
- * word above and make them the top rem bits of result.
- */
- if (!rem || off + k + 1 >= lim)
- upper = 0;
- else {
- upper = src[off + k + 1];
- if (off + k + 1 == lim - 1 && left)
- upper &= mask;
- }
- lower = src[off + k];
- if (left && off + k == lim - 1)
- lower &= mask;
- dst[k] = rem
- ? (upper << (BITS_PER_LONG - rem)) | (lower >> rem)
- : lower;
- if (left && k == lim - 1)
- dst[k] &= mask;
- }
- if (off)
- memset(&dst[lim - off], 0, off*sizeof(unsigned long));
-}
-EXPORT_SYMBOL(__bitmap_shift_right);
-
-
-/*
- * __bitmap_shift_left - logical left shift of the bits in a bitmap
- * @dst - destination bitmap
- * @src - source bitmap
- * @nbits - shift by this many bits
- * @bits - bitmap size, in bits
- *
- * Shifting left (multiplying) means moving bits in the LS -> MS
- * direction. Zeros are fed into the vacated LS bit positions
- * and those MS bits shifted off the top are lost.
- */
-
-void __bitmap_shift_left(unsigned long *dst,
- const unsigned long *src, int shift, int bits)
-{
- int k, lim = BITS_TO_LONGS(bits), left = bits % BITS_PER_LONG;
- int off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG;
- for (k = lim - off - 1; k >= 0; --k) {
- unsigned long upper, lower;
-
- /*
- * If shift is not word aligned, take upper rem bits of
- * word below and make them the bottom rem bits of result.
- */
- if (rem && k > 0)
- lower = src[k - 1];
- else
- lower = 0;
- upper = src[k];
- if (left && k == lim - 1)
- upper &= (1UL << left) - 1;
- dst[k + off] = rem ? (lower >> (BITS_PER_LONG - rem))
- | (upper << rem)
- : upper;
- if (left && k + off == lim - 1)
- dst[k + off] &= (1UL << left) - 1;
- }
- if (off)
- memset(dst, 0, off*sizeof(unsigned long));
-}
-EXPORT_SYMBOL(__bitmap_shift_left);
-
void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
const unsigned long *bitmap2, int bits)
{
* bitmap_empty(src, nbits) Are all bits zero in *src?
* bitmap_full(src, nbits) Are all bits set in *src?
* bitmap_weight(src, nbits) Hamming Weight: number set bits
- * bitmap_shift_right(dst, src, n, nbits) *dst = *src >> n
- * bitmap_shift_left(dst, src, n, nbits) *dst = *src << n
*/
/*
const unsigned long *bitmap2, int bits);
extern void __bitmap_complement(unsigned long *dst, const unsigned long *src,
int bits);
-extern void __bitmap_shift_right(unsigned long *dst,
- const unsigned long *src, int shift, int bits);
-extern void __bitmap_shift_left(unsigned long *dst,
- const unsigned long *src, int shift, int bits);
extern void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
const unsigned long *bitmap2, int bits);
extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
return __bitmap_weight(src, nbits);
}
-static inline void bitmap_shift_right(unsigned long *dst,
- const unsigned long *src, int n, int nbits)
-{
- bitmap_switch(nbits,,
- *dst = *src >> n,
- __bitmap_shift_right(dst, src, n, nbits));
-}
-
-static inline void bitmap_shift_left(unsigned long *dst,
- const unsigned long *src, int n, int nbits)
-{
- bitmap_switch(nbits,,
- *dst = (*src << n) & BITMAP_LAST_WORD_MASK(nbits),
- __bitmap_shift_left(dst, src, n, nbits));
-}
-
#undef bitmap_switch
#undef bitmap_bytes
* int cpumask_full(mask) Is mask full (all bits sets)?
* int cpumask_weight(mask) Hamming weigh - number of set bits
*
- * void cpumask_shift_right(dst, src, n) Shift right
- * void cpumask_shift_left(dst, src, n) Shift left
- *
* int cpumask_first(mask) Number lowest set bit, or NR_CPUS
* int cpumask_next(cpu, mask) Next cpu past 'cpu', or NR_CPUS
* int cpumask_last(mask) Number highest set bit, or NR_CPUS
bitmap_copy(dstp->bits, srcp->bits, nr_cpumask_bits);
}
-static inline void cpumask_shift_right(cpumask_t *dstp,
- const cpumask_t *srcp, int n)
-{
- bitmap_shift_right(dstp->bits, srcp->bits, n, nr_cpumask_bits);
-}
-
-static inline void cpumask_shift_left(cpumask_t *dstp,
- const cpumask_t *srcp, int n)
-{
- bitmap_shift_left(dstp->bits, srcp->bits, n, nr_cpumask_bits);
-}
-
static inline int cpumask_first(const cpumask_t *srcp)
{
return min_t(int, nr_cpu_ids, find_first_bit(srcp->bits, nr_cpu_ids));
* int nodes_full(mask) Is mask full (all bits sets)?
* int nodes_weight(mask) Hamming weight - number of set bits
*
- * void nodes_shift_right(dst, src, n) Shift right
- * void nodes_shift_left(dst, src, n) Shift left
- *
* int first_node(mask) Number lowest set bit, or MAX_NUMNODES
* int next_node(node, mask) Next node past 'node', or MAX_NUMNODES
* int last_node(mask) Number highest set bit, or MAX_NUMNODES
return bitmap_weight(srcp->bits, nbits);
}
-#define nodes_shift_right(dst, src, n) \
- __nodes_shift_right(&(dst), &(src), (n), MAX_NUMNODES)
-static inline void __nodes_shift_right(nodemask_t *dstp,
- const nodemask_t *srcp, int n, int nbits)
-{
- bitmap_shift_right(dstp->bits, srcp->bits, n, nbits);
-}
-
-#define nodes_shift_left(dst, src, n) \
- __nodes_shift_left(&(dst), &(src), (n), MAX_NUMNODES)
-static inline void __nodes_shift_left(nodemask_t *dstp,
- const nodemask_t *srcp, int n, int nbits)
-{
- bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
-}
-
/* FIXME: better would be to fix all architectures to never return
> MAX_NUMNODES, then the silly min_ts could be dropped. */