#pragma once
#define DECLARE_BITMAP(name,bits) \
- unsigned long name[BITS_TO_LONGS(bits)]
+ unsigned long name[BITS_TO_LONGS(bits)]
-/**
-* atomic_set_bit - Atomically set a bit in memory
-* @nr: the bit to set
-* @addr: the address to start counting from
-*
-* This function is atomic and may not be reordered. See __set_bit()
-* if you do not require the atomic guarantees.
-*
-* Note: there are no guarantees that this function will not be reordered
-* on non x86 architectures, so if you are writting portable code,
-* make sure not to rely on its reordering guarantees.
-*
-* Note that @nr may be almost arbitrarily large; this function is not
-* restricted to acting on a single-word quantity.
-*/
static inline unsigned long atomic_set_bit(int nr, volatile long * addr)
{
return InterlockedOr( addr, (1 << nr) );
}
-/**
-* atomic_clear_bit - Clears a bit in memory
-* @nr: Bit to clear
-* @addr: Address to start counting from
-*
-* clear_bit() is atomic and may not be reordered. However, it does
-* not contain a memory barrier, so if it is used for locking purposes,
-* you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
-* in order to ensure changes are visible on other processors.
-*/
static inline unsigned long atomic_clear_bit(int nr, volatile long * addr)
{
return InterlockedAnd( addr, ~(1 << nr) );
static inline int set_bit(int nr,unsigned long * addr)
{
- addr += nr >> 5;
+ addr += nr >> 5;
return atomic_set_bit( nr & 0x1f, (volatile long *)addr );
}
return ((mask & *addr) != 0);
}
-
-/**
-* bitmap_zero - clear the bitmap
-* @dst: the bitmap address
-* @nbits: the bitmap size in bits
-*
-*/
static inline void bitmap_zero(unsigned long *dst, int nbits)
{
if (nbits <= BITS_PER_LONG)
- *dst = 0UL;
+ *dst = 0UL;
else {
- int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
- RtlZeroMemory(dst, len);
+ int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
+ RtlZeroMemory(dst, len);
}
}
static inline int bitmap_empty(const unsigned long *src, int nbits)
{
- if (nbits <= BITS_PER_LONG)
- return ! (*src & BITMAP_LAST_WORD_MASK(nbits));
- else
- return __bitmap_empty(src, nbits);
+ if (nbits <= BITS_PER_LONG)
+ return ! (*src & BITMAP_LAST_WORD_MASK(nbits));
+ else
+ return __bitmap_empty(src, nbits);
}
static inline void bitmap_fill(unsigned long *dst, int nbits)
dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits);
}
-
// DECLARE_BITMAP
#define DECLARE_BITMAP(name,bits) \
- unsigned long name[BITS_TO_LONGS(bits)]
+ unsigned long name[BITS_TO_LONGS(bits)]
-/**
-* atomic_set_bit - Atomically set a bit in memory
-* @nr: the bit to set
-* @addr: the address to start counting from
-*
-* This function is atomic and may not be reordered. See __set_bit()
-* if you do not require the atomic guarantees.
-*
-* Note: there are no guarantees that this function will not be reordered
-* on non x86 architectures, so if you are writting portable code,
-* make sure not to rely on its reordering guarantees.
-*
-* Note that @nr may be almost arbitrarily large; this function is not
-* restricted to acting on a single-word quantity.
-*/
static inline unsigned long atomic_set_bit(int nr, volatile long * addr)
{
return InterlockedOr( addr, (1 << nr) );
}
-/**
-* atomic_clear_bit - Clears a bit in memory
-* @nr: Bit to clear
-* @addr: Address to start counting from
-*
-* clear_bit() is atomic and may not be reordered. However, it does
-* not contain a memory barrier, so if it is used for locking purposes,
-* you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
-* in order to ensure changes are visible on other processors.
-*/
static inline unsigned long atomic_clear_bit(int nr, volatile long * addr)
{
return InterlockedAnd( addr, ~(1 << nr) );
static inline int set_bit(int nr,long * addr)
{
- addr += nr >> 5;
+ addr += nr >> 5;
return atomic_set_bit( nr & 0x1f, (volatile long *)addr );
}
static inline int test_bit(int nr, const unsigned long * addr)
{
- int mask;
+ int mask;
- addr += nr >> 5;
- mask = 1 << (nr & 0x1f);
- return ((mask & *addr) != 0);
+ addr += nr >> 5;
+ mask = 1 << (nr & 0x1f);
+ return ((mask & *addr) != 0);
}
-
-/**
-* bitmap_zero - clear the bitmap
-* @dst: the bitmap address
-* @nbits: the bitmap size in bits
-*
-*/
static inline void bitmap_zero(unsigned long *dst, int nbits)
{
if (nbits <= BITS_PER_LONG)
- *dst = 0UL;
+ *dst = 0UL;
else {
- int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
- RtlZeroMemory(dst, len);
+ int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
+ RtlZeroMemory(dst, len);
}
}
static inline int bitmap_empty(const unsigned long *src, int nbits)
{
- if (nbits <= BITS_PER_LONG)
- return ! (*src & BITMAP_LAST_WORD_MASK(nbits));
- else
- return __bitmap_empty(src, nbits);
+ if (nbits <= BITS_PER_LONG)
+ return ! (*src & BITMAP_LAST_WORD_MASK(nbits));
+ else
+ return __bitmap_empty(src, nbits);
}
-
#endif