Subversion Repositories Kolibri OS

Rev

Rev 5270 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5270 Rev 6082
Line 55... Line 55...
55
#define for_each_clear_bit_from(bit, addr, size) \
55
#define for_each_clear_bit_from(bit, addr, size) \
56
	for ((bit) = find_next_zero_bit((addr), (size), (bit));	\
56
	for ((bit) = find_next_zero_bit((addr), (size), (bit));	\
57
	     (bit) < (size);					\
57
	     (bit) < (size);					\
58
	     (bit) = find_next_zero_bit((addr), (size), (bit) + 1))
58
	     (bit) = find_next_zero_bit((addr), (size), (bit) + 1))
Line 59... Line 59...
59
 
59
 
60
static __inline__ int get_bitmask_order(unsigned int count)
60
static inline int get_bitmask_order(unsigned int count)
61
{
61
{
Line 62... Line 62...
62
	int order;
62
	int order;
63
 
63
 
64
	order = fls(count);
64
	order = fls(count);
Line 65... Line 65...
65
	return order;	/* We could be slightly more clever with -1 here... */
65
	return order;	/* We could be slightly more clever with -1 here... */
66
}
66
}
67
 
67
 
Line 68... Line 68...
68
static __inline__ int get_count_order(unsigned int count)
68
static inline int get_count_order(unsigned int count)
69
{
69
{
70
	int order;
70
	int order;
71
 
71
 
72
	order = fls(count) - 1;
72
	order = fls(count) - 1;
Line 73... Line 73...
73
	if (count & (count - 1))
73
	if (count & (count - 1))
74
		order++;
74
		order++;
75
	return order;
75
	return order;
76
}
76
}
Line 77... Line 77...
77
 
77
 
Line 162... Line 162...
162
 
162
 
163
/**
163
/**
164
 * sign_extend32 - sign extend a 32-bit value using specified bit as sign-bit
164
 * sign_extend32 - sign extend a 32-bit value using specified bit as sign-bit
165
 * @value: value to sign extend
165
 * @value: value to sign extend
-
 
166
 * @index: 0 based bit index (0<=index<32) to sign bit
-
 
167
 *
166
 * @index: 0 based bit index (0<=index<32) to sign bit
168
 * This is safe to use for 16- and 8-bit types as well.
167
 */
169
 */
168
static inline __s32 sign_extend32(__u32 value, int index)
170
static inline __s32 sign_extend32(__u32 value, int index)
169
{
171
{
170
	__u8 shift = 31 - index;
172
	__u8 shift = 31 - index;
171
	return (__s32)(value << shift) >> shift;
173
	return (__s32)(value << shift) >> shift;
Line -... Line 174...
-
 
174
}
-
 
175
 
-
 
176
/**
-
 
177
 * sign_extend64 - sign extend a 64-bit value using specified bit as sign-bit
-
 
178
 * @value: value to sign extend
-
 
179
 * @index: 0 based bit index (0<=index<64) to sign bit
-
 
180
 */
-
 
181
static inline __s64 sign_extend64(__u64 value, int index)
-
 
182
{
-
 
183
	__u8 shift = 63 - index;
-
 
184
	return (__s64)(value << shift) >> shift;
172
}
185
}
173
 
186
 
174
static inline unsigned fls_long(unsigned long l)
187
static inline unsigned fls_long(unsigned long l)
175
{
188
{
176
	if (sizeof(l) == 4)
189
	if (sizeof(l) == 4)
Line 216... Line 229...
216
 
229
 
217
#ifndef find_last_bit
230
#ifndef find_last_bit
218
/**
231
/**
219
 * find_last_bit - find the last set bit in a memory region
232
 * find_last_bit - find the last set bit in a memory region
220
 * @addr: The address to start the search at
233
 * @addr: The address to start the search at
221
 * @size: The maximum size to search
234
 * @size: The number of bits to search
222
 *
235
 *
223
 * Returns the bit number of the first set bit, or size.
236
 * Returns the bit number of the last set bit, or size.
224
 */
237
 */
225
extern unsigned long find_last_bit(const unsigned long *addr,
238
extern unsigned long find_last_bit(const unsigned long *addr,
226
				   unsigned long size);
239
				   unsigned long size);