Properly handle 32 bits

This commit is contained in:
Mamy André-Ratsimbazafy 2020-03-01 16:18:45 +01:00
parent 3fdd457b52
commit c8e482f6d2
No known key found for this signature in database
GPG Key ID: 7B88AD1FE79492E1
1 changed files with 141 additions and 140 deletions

View File

@ -75,9 +75,10 @@ func unsafeFMA2_hi*(hi: var Ct[uint32], a1, b1, a2, b2, c1: Ct[uint32]) {.inline
#
# ############################################################
const GccCompatible = defined(gcc) or defined(clang) or defined(llvm_gcc)
when sizeof(int) == 8:
const GccCompatible = defined(gcc) or defined(clang) or defined(llvm_gcc)
when sizeof(int) == 8 and GccCompatible:
when GccCompatible:
type
uint128*{.importc: "unsigned __int128".} = object
@ -159,7 +160,7 @@ when sizeof(int) == 8 and GccCompatible:
# Don't forget to dereference the var param
{.emit:["*",hi, " = (NU64)(", dblPrec," >> ", 63'u64, ");"].}
elif sizeof(int) == 8 and defined(vcc):
elif defined(vcc):
func udiv128(highDividend, lowDividend, divisor: uint64, remainder: var uint64): uint64 {.importc:"_udiv128", header: "<immintrin.h>", nodecl.}
## Division 128 by 64, Microsoft only, 64-bit only,
## returns quotient as return value remainder as var parameter
@ -238,5 +239,5 @@ elif sizeof(int) == 8 and defined(vcc):
carry = addcarry_u64(cuchar(0), f1_lo, f2_lo, lo)
discard addcarry_u64(carry, f1_hi, f2_hi, hi)
else:
else:
{.error: "Compiler not implemented".}