more fixes for 32 bits architecture
This commit is contained in:
@@ -25,10 +25,10 @@
|
||||
#endif
|
||||
|
||||
/* no plan to support 32bits for now...
|
||||
* #if __WORDSIZE != 64
|
||||
* #error "Only 64 bits word size supported."
|
||||
* #endif
|
||||
*/
|
||||
#if __WORDSIZE != 64
|
||||
#error "Only 64 bits word size supported."
|
||||
#endif
|
||||
|
||||
/* fixed-size types
|
||||
*/
|
||||
@@ -73,6 +73,27 @@ static __always_inline int popcount64(u64 n)
|
||||
# endif
|
||||
}
|
||||
|
||||
static __always_inline int popcount32(u32 n)
|
||||
{
|
||||
# if __has_builtin(__builtin_popcount)
|
||||
# ifdef DEBUG_BITS
|
||||
log_f(1, "builtin.\n");
|
||||
# endif
|
||||
return __builtin_popcount(n);
|
||||
|
||||
# else
|
||||
# ifdef DEBUG_BITS
|
||||
log_f(1, "emulated.\n");
|
||||
# endif
|
||||
int count = 0;
|
||||
while (n) {
|
||||
count++;
|
||||
n &= (n - 1);
|
||||
}
|
||||
return count;
|
||||
# endif
|
||||
}
|
||||
|
||||
/* char is a special case, as it can be signed or unsigned
|
||||
*/
|
||||
typedef signed char schar;
|
||||
@@ -242,27 +263,6 @@ static __always_inline uint ffs32(u32 n)
|
||||
# endif
|
||||
}
|
||||
|
||||
static __always_inline int popcount32(u32 n)
|
||||
{
|
||||
# if __has_builtin(__builtin_popcount)
|
||||
# ifdef DEBUG_BITS
|
||||
log_f(1, "builtin.\n");
|
||||
# endif
|
||||
return __builtin_popcount(n);
|
||||
|
||||
# else
|
||||
# ifdef DEBUG_BITS
|
||||
log_f(1, "emulated.\n");
|
||||
# endif
|
||||
int count = 0;
|
||||
while (n) {
|
||||
count++;
|
||||
n &= (n - 1);
|
||||
}
|
||||
return count;
|
||||
# endif
|
||||
}
|
||||
|
||||
/* rolXX are taken from kernel's <linux/bitops.h> are are:
|
||||
* SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
Reference in New Issue
Block a user