Debian Codegraph @

src/containers/internal/backwards.d

raw
1 module containers.internal.backwards;
2
3 static if (__VERSION__ < 2071)
4 {
5 /// 64-bit popcnt
6 int popcnt(ulong v) pure nothrow @nogc @safe
7 {
8 import core.bitop : popcnt;
9
10 return popcnt(cast(uint) v) + popcnt(cast(uint)(v >>> 32));
11 }
12
13 version (X86_64)
14 public import core.bitop : bsf;
15 else
16 {
17 /// Allow 64-bit bsf on old compilers
18 int bsf(ulong v) pure nothrow @nogc @safe
19 {
20 import core.bitop : bsf;
21
22 immutable uint lower = cast(uint) v;
23 immutable uint upper = cast(uint)(v >>> 32);
24 return lower == 0 ? bsf(upper) + 32 : bsf(lower);
25 }
26 }
27 }
28 else
29 public import core.bitop : bsf, popcnt;