Fix pointer deref issue on Macos and Nim >= 2.0 (#152)
This commit is contained in:
parent
3c238df6cd
commit
379901ad36
|
@ -168,6 +168,6 @@ jobs:
|
|||
env TEST_LANG="c" nimble test
|
||||
# run test against intx
|
||||
env TEST_LANG="cpp" nimble test
|
||||
# test conditional compilation for arm654 arch
|
||||
# test conditional compilation for arm64 arch
|
||||
# without running the binary
|
||||
nim c -c --cpu:arm64 --os:linux tests/all_tests
|
||||
|
|
|
@ -6,3 +6,4 @@
|
|||
|
||||
nimcache/
|
||||
build/
|
||||
nimble.paths
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# begin Nimble config (version 1)
|
||||
when fileExists("nimble.paths"):
|
||||
include "nimble.paths"
|
||||
# end Nimble config
|
|
@ -88,6 +88,10 @@ const
|
|||
useIntrinsics = X86 and not stintNoIntrinsics
|
||||
useInt128 = GCC_Compatible and sizeof(int) == 8 and not stintNoIntrinsics
|
||||
|
||||
const
|
||||
newerNim = (NimMajor, NimMinor) > (1, 6)
|
||||
noExplicitPtrDeref = defined(cpp) or newerNim
|
||||
|
||||
when useIntrinsics:
|
||||
when defined(windows):
|
||||
{.pragma: intrinsics, header:"<intrin.h>", nodecl.}
|
||||
|
@ -152,7 +156,7 @@ func addC*(cOut: var Carry, sum: var uint64, a, b: uint64, cIn: Carry) {.inline.
|
|||
{.emit:[dblPrec, " = (unsigned __int128)", a," + (unsigned __int128)", b, " + (unsigned __int128)",cIn,";"].}
|
||||
|
||||
# Don't forget to dereference the var param in C mode
|
||||
when defined(cpp):
|
||||
when noExplicitPtrDeref:
|
||||
{.emit:[cOut, " = (NU64)(", dblPrec," >> ", 64'u64, ");"].}
|
||||
{.emit:[sum, " = (NU64)", dblPrec,";"].}
|
||||
else:
|
||||
|
@ -175,7 +179,7 @@ func subB*(bOut: var Borrow, diff: var uint64, a, b: uint64, bIn: Borrow) {.inli
|
|||
|
||||
# Don't forget to dereference the var param in C mode
|
||||
# On borrow the high word will be 0b1111...1111 and needs to be masked
|
||||
when defined(cpp):
|
||||
when noExplicitPtrDeref:
|
||||
{.emit:[bOut, " = (NU64)(", dblPrec," >> ", 64'u64, ") & 1;"].}
|
||||
{.emit:[diff, " = (NU64)", dblPrec,";"].}
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue