forked from KolibriOS/kolibrios
ddk: 4.4
git-svn-id: svn://kolibrios.org@6082 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
#include <asm/types.h>
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#define BIT(nr) (1UL << (nr))
|
||||
#define BIT(nr) (1UL << (nr))
|
||||
#define BIT_ULL(nr) (1ULL << (nr))
|
||||
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
|
||||
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
|
||||
@@ -36,8 +36,8 @@ extern unsigned long __sw_hweight64(__u64 w);
|
||||
#include <asm/bitops.h>
|
||||
|
||||
#define for_each_set_bit(bit, addr, size) \
|
||||
for ((bit) = find_first_bit((addr), (size)); \
|
||||
(bit) < (size); \
|
||||
for ((bit) = find_first_bit((addr), (size)); \
|
||||
(bit) < (size); \
|
||||
(bit) = find_next_bit((addr), (size), (bit) + 1))
|
||||
|
||||
/* same as for_each_set_bit() but use bit as value to start with */
|
||||
@@ -57,7 +57,7 @@ extern unsigned long __sw_hweight64(__u64 w);
|
||||
(bit) < (size); \
|
||||
(bit) = find_next_zero_bit((addr), (size), (bit) + 1))
|
||||
|
||||
static __inline__ int get_bitmask_order(unsigned int count)
|
||||
static inline int get_bitmask_order(unsigned int count)
|
||||
{
|
||||
int order;
|
||||
|
||||
@@ -65,7 +65,7 @@ static __inline__ int get_bitmask_order(unsigned int count)
|
||||
return order; /* We could be slightly more clever with -1 here... */
|
||||
}
|
||||
|
||||
static __inline__ int get_count_order(unsigned int count)
|
||||
static inline int get_count_order(unsigned int count)
|
||||
{
|
||||
int order;
|
||||
|
||||
@@ -75,7 +75,7 @@ static __inline__ int get_count_order(unsigned int count)
|
||||
return order;
|
||||
}
|
||||
|
||||
static inline unsigned long hweight_long(unsigned long w)
|
||||
static __always_inline unsigned long hweight_long(unsigned long w)
|
||||
{
|
||||
return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
|
||||
}
|
||||
@@ -164,6 +164,8 @@ static inline __u8 ror8(__u8 word, unsigned int shift)
|
||||
* sign_extend32 - sign extend a 32-bit value using specified bit as sign-bit
|
||||
* @value: value to sign extend
|
||||
* @index: 0 based bit index (0<=index<32) to sign bit
|
||||
*
|
||||
* This is safe to use for 16- and 8-bit types as well.
|
||||
*/
|
||||
static inline __s32 sign_extend32(__u32 value, int index)
|
||||
{
|
||||
@@ -171,6 +173,17 @@ static inline __s32 sign_extend32(__u32 value, int index)
|
||||
return (__s32)(value << shift) >> shift;
|
||||
}
|
||||
|
||||
/**
|
||||
* sign_extend64 - sign extend a 64-bit value using specified bit as sign-bit
|
||||
* @value: value to sign extend
|
||||
* @index: 0 based bit index (0<=index<64) to sign bit
|
||||
*/
|
||||
static inline __s64 sign_extend64(__u64 value, int index)
|
||||
{
|
||||
__u8 shift = 63 - index;
|
||||
return (__s64)(value << shift) >> shift;
|
||||
}
|
||||
|
||||
static inline unsigned fls_long(unsigned long l)
|
||||
{
|
||||
if (sizeof(l) == 4)
|
||||
@@ -218,9 +231,9 @@ static inline unsigned long __ffs64(u64 word)
|
||||
/**
|
||||
* find_last_bit - find the last set bit in a memory region
|
||||
* @addr: The address to start the search at
|
||||
* @size: The maximum size to search
|
||||
* @size: The number of bits to search
|
||||
*
|
||||
* Returns the bit number of the first set bit, or size.
|
||||
* Returns the bit number of the last set bit, or size.
|
||||
*/
|
||||
extern unsigned long find_last_bit(const unsigned long *addr,
|
||||
unsigned long size);
|
||||
|
Reference in New Issue
Block a user