src/bitcount.c
/**
 * Use the builtin compiler function __builtin_popcountll if available.
 * builtin.h from Portable Snippets is used to ensure portable code,
 * see https://github.com/nemequ/portable-snippets/tree/master/builtin.
 */
Use the builtin compiler function __builtin_popcountll if available.
Use the builtin compiler function __builtin_popcountll if available .
inline int32 bitcount_popcountll(uint8 *data, uint8 *end) {
    int32 count = 0;
    uint8 *p = data;
    uint64 word;
    uint8 i;
    while (p < end) {
        word = 0;
        for (i=0; i < 8 && p < end; i++) {
            word &= (*p) << i*8;
            ++p;
        }
        count += psnip_builtin_popcountll(word);
    }
    return count;
}
inline int32 bitcount_popcountll ( uint8 * data , uint8 * end ) { int32 count = 0 ; uint8 * p = data ; uint64 word ; uint8 i ; while ( p < end ) { word = 0 ; for ( i = 0 ; i < 8 && p < end ; i ++ ) { word &= ( * p ) << i * 8 ; ++ p ; } count += psnip_builtin_popcountll ( word ) ; } return count ; }
Use the builtin compiler function __builtin_popcountll if available.
Use the builtin compiler function __builtin_popcountll if available .