Subversion Repositories Kolibri OS

Rev

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

Rev 3031 Rev 5056
Line 2... Line 2...
2
#define _LINUX_BITOPS_H
2
#define _LINUX_BITOPS_H
3
#include 
3
#include 
Line 4... Line 4...
4
 
4
 
5
#ifdef	__KERNEL__
5
#ifdef	__KERNEL__
-
 
6
#define BIT(nr)         (1UL << (nr))
6
#define BIT(nr)         (1UL << (nr))
7
#define BIT_ULL(nr)		(1ULL << (nr))
7
#define BIT_MASK(nr)		(1UL << ((nr) % BITS_PER_LONG))
8
#define BIT_MASK(nr)		(1UL << ((nr) % BITS_PER_LONG))
-
 
9
#define BIT_WORD(nr)		((nr) / BITS_PER_LONG)
-
 
10
#define BIT_ULL_MASK(nr)	(1ULL << ((nr) % BITS_PER_LONG_LONG))
8
#define BIT_WORD(nr)		((nr) / BITS_PER_LONG)
11
#define BIT_ULL_WORD(nr)	((nr) / BITS_PER_LONG_LONG)
9
#define BITS_PER_BYTE		8
12
#define BITS_PER_BYTE		8
10
#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
13
#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
Line -... Line 14...
-
 
14
#endif
-
 
15
 
-
 
16
/*
-
 
17
 * Create a contiguous bitmask starting at bit position @l and ending at
-
 
18
 * position @h. For example
-
 
19
 * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
-
 
20
 */
-
 
21
#define GENMASK(h, l)		(((U32_C(1) << ((h) - (l) + 1)) - 1) << (l))
11
#endif
22
#define GENMASK_ULL(h, l)	(((U64_C(1) << ((h) - (l) + 1)) - 1) << (l))
12
 
23
 
13
extern unsigned int __sw_hweight8(unsigned int w);
24
extern unsigned int __sw_hweight8(unsigned int w);
14
extern unsigned int __sw_hweight16(unsigned int w);
25
extern unsigned int __sw_hweight16(unsigned int w);
Line 183... Line 194...
183
	return __ffs((unsigned long)word);
194
	return __ffs((unsigned long)word);
184
}
195
}
Line 185... Line 196...
185
 
196
 
Line -... Line 197...
-
 
197
#ifdef __KERNEL__
-
 
198
 
-
 
199
#ifndef set_mask_bits
-
 
200
#define set_mask_bits(ptr, _mask, _bits)	\
-
 
201
({								\
-
 
202
	const typeof(*ptr) mask = (_mask), bits = (_bits);	\
-
 
203
	typeof(*ptr) old, new;					\
-
 
204
								\
-
 
205
	do {							\
-
 
206
		old = ACCESS_ONCE(*ptr);			\
-
 
207
		new = (old & ~mask) | bits;			\
-
 
208
	} while (cmpxchg(ptr, old, new) != old);		\
-
 
209
								\
-
 
210
	new;							\
-
 
211
})
186
#ifdef __KERNEL__
212
#endif
187
 
213
 
188
#ifndef find_last_bit
214
#ifndef find_last_bit
189
/**
215
/**
190
 * find_last_bit - find the last set bit in a memory region
216
 * find_last_bit - find the last set bit in a memory region