Subversion Repositories Kolibri OS

Rev

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

Rev 5270 Rev 6082
Line 19... Line 19...
19
 * __sw_hweightXX are called from within the alternatives below
19
 * __sw_hweightXX are called from within the alternatives below
20
 * and callee-clobbered registers need to be taken care of. See
20
 * and callee-clobbered registers need to be taken care of. See
21
 * ARCH_HWEIGHT_CFLAGS in  for the respective
21
 * ARCH_HWEIGHT_CFLAGS in  for the respective
22
 * compiler switches.
22
 * compiler switches.
23
 */
23
 */
24
static inline unsigned int __arch_hweight32(unsigned int w)
24
static __always_inline unsigned int __arch_hweight32(unsigned int w)
25
{
25
{
26
	unsigned int res = 0;
26
    unsigned int res = w - ((w >> 1) & 0x55555555);
27
 
-
 
28
    asm ("call __sw_hweight32"
27
    res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
29
		     : "="REG_OUT (res)
28
    res = (res + (res >> 4)) & 0x0F0F0F0F;
30
		     : REG_IN (w));
29
    res = res + (res >> 8);
31
 
-
 
32
	return res;
30
    return (res + (res >> 16)) & 0x000000FF;
33
}
31
}
Line 34... Line 32...
34
 
32
 
35
static inline unsigned int __arch_hweight16(unsigned int w)
33
static inline unsigned int __arch_hweight16(unsigned int w)
36
{
34
{
Line 40... Line 38...
40
static inline unsigned int __arch_hweight8(unsigned int w)
38
static inline unsigned int __arch_hweight8(unsigned int w)
41
{
39
{
42
	return __arch_hweight32(w & 0xff);
40
	return __arch_hweight32(w & 0xff);
43
}
41
}
Line -... Line 42...
-
 
42
 
44
 
43
#ifdef CONFIG_X86_32
45
static inline unsigned long __arch_hweight64(__u64 w)
44
static inline unsigned long __arch_hweight64(__u64 w)
46
{
-
 
47
	unsigned long res = 0;
-
 
48
 
-
 
49
#ifdef CONFIG_X86_32
45
{
50
	return  __arch_hweight32((u32)w) +
46
	return  __arch_hweight32((u32)w) +
-
 
47
		__arch_hweight32((u32)(w >> 32));
51
		__arch_hweight32((u32)(w >> 32));
48
}
-
 
49
#else
-
 
50
static __always_inline unsigned long __arch_hweight64(__u64 w)
-
 
51
{
-
 
52
	unsigned long res = 0;
52
#else
53
 
53
	asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)
54
	asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)
54
		     : "="REG_OUT (res)
55
		     : "="REG_OUT (res)
55
		     : REG_IN (w));
-
 
Line 56... Line 56...
56
#endif /* CONFIG_X86_32 */
56
		     : REG_IN (w));
57
 
57
 
-
 
58
	return res;
Line 58... Line 59...
58
	return res;
59
}