mirror of
https://github.com/status-im/nim-stew.git
synced 2025-01-09 11:45:42 +00:00
Merge pull request #43 from status-im/fix_vcc_bitops2
fix bitops2 checkedScan and bitScan for vcc
This commit is contained in:
commit
188230a368
@ -34,6 +34,10 @@ build_script:
|
|||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- nimble test
|
- nimble test
|
||||||
|
- IF "%PLATFORM%" == "x86" CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
|
||||||
|
- IF "%PLATFORM%" == "x64" CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
|
||||||
|
- IF "%PLATFORM%" == "x64" CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
|
||||||
|
- nimble testvcc
|
||||||
|
|
||||||
deploy: off
|
deploy: off
|
||||||
|
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
nimcache
|
nimcache
|
||||||
|
*.exe
|
||||||
|
@ -12,3 +12,7 @@ requires "nim >= 1.2.0"
|
|||||||
task test, "Run all tests":
|
task test, "Run all tests":
|
||||||
exec "nim c -r --threads:off tests/all_tests"
|
exec "nim c -r --threads:off tests/all_tests"
|
||||||
exec "nim c -r --threads:on -d:nimTypeNames tests/all_tests"
|
exec "nim c -r --threads:on -d:nimTypeNames tests/all_tests"
|
||||||
|
|
||||||
|
task testvcc, "Run all tests with vcc compiler":
|
||||||
|
exec "nim c -r --cc:vcc --threads:off tests/all_tests"
|
||||||
|
exec "nim c -r --cc:vcc --threads:on -d:nimTypeNames tests/all_tests"
|
||||||
|
@ -253,12 +253,12 @@ elif defined(vcc) and useBuiltins:
|
|||||||
|
|
||||||
template checkedScan(fnc: untyped, x: typed, def: typed): int =
|
template checkedScan(fnc: untyped, x: typed, def: typed): int =
|
||||||
var index{.noinit.}: culong
|
var index{.noinit.}: culong
|
||||||
if fnc(index.addr, v) == 0: def
|
if fnc(index.addr, v).int == 0: def
|
||||||
else: index.int
|
else: index.int
|
||||||
|
|
||||||
template bitScan(fnc: untyped, x: typed): int =
|
template bitScan(fnc: untyped, x: typed): int =
|
||||||
var index{.noinit.}: culong
|
var index{.noinit.}: culong
|
||||||
if fnc(index.addr, v) == 0: 0
|
if fnc(index.addr, v).int == 0: 0
|
||||||
else: index.int
|
else: index.int
|
||||||
|
|
||||||
func countOnesBuiltin(v: uint8|uint16|uint32): int = builtin_popcnt32(v.uint32).int
|
func countOnesBuiltin(v: uint8|uint16|uint32): int = builtin_popcnt32(v.uint32).int
|
||||||
@ -266,8 +266,8 @@ elif defined(vcc) and useBuiltins:
|
|||||||
when arch64:
|
when arch64:
|
||||||
builtin_popcnt64(v).int
|
builtin_popcnt64(v).int
|
||||||
else:
|
else:
|
||||||
builtin_popcnt32((v and 0xFFFFFFFF'u64).uint32).int +
|
builtin_popcnt32((v and 0xFFFFFFFF'u64).cint).int +
|
||||||
builtin_popcnt32((v shr 32'u64).uint32).int
|
builtin_popcnt32((v shr 32'u64).cint).int
|
||||||
|
|
||||||
func firstOneBuiltin(v: uint8|uint16|uint32): int =
|
func firstOneBuiltin(v: uint8|uint16|uint32): int =
|
||||||
1 + checkedScan(bitScanForward, v.culong, -1)
|
1 + checkedScan(bitScanForward, v.culong, -1)
|
||||||
|
4
tests/nim.cfg
Normal file
4
tests/nim.cfg
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
vcc.exe = "cl.exe"
|
||||||
|
vcc.cpp.exe = "cl.exe"
|
||||||
|
vcc.linkerexe = "cl.exe"
|
||||||
|
vcc.cpp.linkerexe = "cl.exe"
|
Loading…
x
Reference in New Issue
Block a user