-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run unit tests in 64 and 32 bit mode. Fix #41 and should prevent 32-b…
…it bugs in the future
- Loading branch information
1 parent
e5c21fc
commit 84692a5
Showing
5 changed files
with
73 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module containers.internal.backwards; | ||
|
||
static if (__VERSION__ < 2071) | ||
{ | ||
/// 64-bit popcnt | ||
int popcnt(ulong v) pure nothrow @nogc @safe | ||
{ | ||
import core.bitop : popcnt; | ||
|
||
return popcnt(cast(uint) v) + popcnt(cast(uint)(v >>> 32)); | ||
} | ||
|
||
version (X86_64) | ||
public import core.bitop : bsf; | ||
else | ||
{ | ||
/// Allow 64-bit bsf on old compilers | ||
int bsf(ulong v) pure nothrow @nogc @safe | ||
{ | ||
import core.bitop : bsf; | ||
|
||
immutable uint lower = cast(uint) v; | ||
immutable uint upper = cast(uint)(v >>> 32); | ||
return lower == 0 ? bsf(upper) + 32 : bsf(lower); | ||
} | ||
} | ||
} | ||
else | ||
public import core.bitop : bsf, popcnt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters