Fix compilation failure for arch other than amd64/i386
This commit is contained in:
parent
d198ec031e
commit
bfa299f3ae
|
@ -113,9 +113,11 @@ func addC*(cOut: var Carry, sum: var uint32, a, b: uint32, cIn: Carry) {.inline.
|
||||||
when X86:
|
when X86:
|
||||||
cOut = addcarry_u32(cIn, a, b, sum)
|
cOut = addcarry_u32(cIn, a, b, sum)
|
||||||
else:
|
else:
|
||||||
let dblPrec = uint64(cIn) + uint64(a) + uint64(b)
|
# on arch e.g. arm: nim will complaints "Error: redefinition of 'dblPrec'"
|
||||||
sum = uint32(dblPrec)
|
# so we use dlbPrec2 here
|
||||||
cOut = Carry(dblPrec shr 32)
|
let dblPrec2 = uint64(cIn) + uint64(a) + uint64(b)
|
||||||
|
sum = uint32(dblPrec2)
|
||||||
|
cOut = Carry(dblPrec2 shr 32)
|
||||||
|
|
||||||
func subB*(bOut: var Borrow, diff: var uint32, a, b: uint32, bIn: Borrow) {.inline.} =
|
func subB*(bOut: var Borrow, diff: var uint32, a, b: uint32, bIn: Borrow) {.inline.} =
|
||||||
## Substraction with borrow
|
## Substraction with borrow
|
||||||
|
@ -129,10 +131,11 @@ func subB*(bOut: var Borrow, diff: var uint32, a, b: uint32, bIn: Borrow) {.inli
|
||||||
when X86:
|
when X86:
|
||||||
bOut = subborrow_u32(bIn, a, b, diff)
|
bOut = subborrow_u32(bIn, a, b, diff)
|
||||||
else:
|
else:
|
||||||
let dblPrec = uint64(a) - uint64(b) - uint64(bIn)
|
# ditto
|
||||||
diff = uint32(dblPrec)
|
let dblPrec2 = uint64(a) - uint64(b) - uint64(bIn)
|
||||||
|
diff = uint32(dblPrec2)
|
||||||
# On borrow the high word will be 0b1111...1111 and needs to be masked
|
# On borrow the high word will be 0b1111...1111 and needs to be masked
|
||||||
bOut = Borrow((dblPrec shr 32) and 1)
|
bOut = Borrow((dblPrec2 shr 32) and 1)
|
||||||
|
|
||||||
func addC*(cOut: var Carry, sum: var uint64, a, b: uint64, cIn: Carry) {.inline.} =
|
func addC*(cOut: var Carry, sum: var uint64, a, b: uint64, cIn: Carry) {.inline.} =
|
||||||
## Addition with carry
|
## Addition with carry
|
||||||
|
|
Loading…
Reference in New Issue