… | |
… | |
454 | /* count trailing zero bits and count # of one bits */ |
454 | /* count trailing zero bits and count # of one bits */ |
455 | #if ECB_GCC_VERSION(3,4) \ |
455 | #if ECB_GCC_VERSION(3,4) \ |
456 | || (ECB_CLANG_BUILTIN(__builtin_clz) && ECB_CLANG_BUILTIN(__builtin_clzll) \ |
456 | || (ECB_CLANG_BUILTIN(__builtin_clz) && ECB_CLANG_BUILTIN(__builtin_clzll) \ |
457 | && ECB_CLANG_BUILTIN(__builtin_ctz) && ECB_CLANG_BUILTIN(__builtin_ctzll) \ |
457 | && ECB_CLANG_BUILTIN(__builtin_ctz) && ECB_CLANG_BUILTIN(__builtin_ctzll) \ |
458 | && ECB_CLANG_BUILTIN(__builtin_popcount)) |
458 | && ECB_CLANG_BUILTIN(__builtin_popcount)) |
459 | /* we assume int == 32 bit, long == 32 or 64 bit and long long == 64 bit */ |
|
|
460 | #define ecb_ld32(x) (__builtin_clz (x) ^ 31) |
|
|
461 | #define ecb_ld64(x) (__builtin_clzll (x) ^ 63) |
|
|
462 | #define ecb_ctz32(x) __builtin_ctz (x) |
459 | #define ecb_ctz32(x) __builtin_ctz (x) |
|
|
460 | #define ecb_ctz64(x) (__SIZEOF_LONG__ == 64 ? __builtin_ctzl (x) : __builtin_ctzll (x)) |
463 | #define ecb_ctz64(x) __builtin_ctzll (x) |
461 | #define ecb_clz32(x) __builtin_clz (x) |
|
|
462 | #define ecb_clz64(x) (__SIZEOF_LONG__ == 64 ? __builtin_clzl (x) : __builtin_clzll (x)) |
|
|
463 | #define ecb_ld32(x) (ecb_clz32 (x) ^ 31) |
|
|
464 | #define ecb_ld64(x) (ecb_clz64 (x) ^ 63) |
464 | #define ecb_popcount32(x) __builtin_popcount (x) |
465 | #define ecb_popcount32(x) __builtin_popcount (x) |
465 | /* no popcountll */ |
466 | /* ecb_popcount64 is more difficult, see below */ |
466 | #else |
467 | #else |
467 | ecb_function_ ecb_const int ecb_ctz32 (uint32_t x); |
468 | ecb_function_ ecb_const int ecb_ctz32 (uint32_t x); |
468 | ecb_function_ ecb_const int |
469 | ecb_function_ ecb_const int |
469 | ecb_ctz32 (uint32_t x) |
470 | ecb_ctz32 (uint32_t x) |
470 | { |
471 | { |