… | |
… | |
44 | |
44 | |
45 | e = w.u; |
45 | e = w.u; |
46 | } |
46 | } |
47 | |
47 | |
48 | #if !HAVE_GCC_BUILTINS |
48 | #if !HAVE_GCC_BUILTINS |
49 | int ctz (unsigned int x) CONST |
49 | int rxvt_ctz (unsigned int x) CONST |
50 | { |
50 | { |
51 | int r = 0; |
51 | int r = 0; |
52 | |
52 | |
53 | x &= -x; // this isolates the lowest bit |
53 | x &= -x; // this isolates the lowest bit |
54 | |
54 | |
… | |
… | |
59 | if (x & 0xffff0000) r += 16; |
59 | if (x & 0xffff0000) r += 16; |
60 | |
60 | |
61 | return r; |
61 | return r; |
62 | } |
62 | } |
63 | |
63 | |
64 | int popcount (unsigned int x) CONST |
64 | int rxvt_popcount (unsigned int x) CONST |
65 | { |
65 | { |
66 | x -= (x >> 1) & 0x55555555; |
66 | x -= (x >> 1) & 0x55555555; |
67 | x = ((x >> 2) & 0x33333333) + (x & 0x33333333); |
67 | x = ((x >> 2) & 0x33333333) + (x & 0x33333333); |
68 | x = ((x >> 4) + x) & 0x0f0f0f0f; |
68 | x = ((x >> 4) + x) & 0x0f0f0f0f; |
69 | x *= 0x01010101; |
69 | x *= 0x01010101; |