fix stuint truncate on 32bit platform
This commit is contained in:
parent
140afc31ab
commit
4a3f300bd6
|
@ -152,9 +152,6 @@ jobs:
|
|||
# https://github.com/status-im/nimbus-eth2/issues/3121
|
||||
export NIMFLAGS="-d:nimRawSetjmp"
|
||||
fi
|
||||
if [[ "${{ matrix.branch }}" == "devel" ]]; then
|
||||
export NIMFLAGS="${NIMFLAGS} -d:nimDevelFixVarParam"
|
||||
fi
|
||||
nim --version
|
||||
nimble --version
|
||||
nimble install -y --depsOnly
|
||||
|
|
|
@ -64,7 +64,7 @@ func truncate*(num: StUint, T: typedesc[SomeInteger]): T {.inline.}=
|
|||
## Note that int and uint are 32-bit on 32-bit platform.
|
||||
## For unsigned result type, result is modulo 2^(sizeof T in bit)
|
||||
## For signed result type, result is undefined if input does not fit in the target type.
|
||||
when T is SomeSignedInt:
|
||||
when T is SomeSignedInt and sizeof(T) <= sizeof(Word):
|
||||
result = T(num.leastSignificantWord() and Word(T.high))
|
||||
else:
|
||||
result = T(num.leastSignificantWord())
|
||||
|
|
|
@ -16,11 +16,8 @@ import ../datatypes
|
|||
# ############################################################
|
||||
|
||||
const
|
||||
# at the time of writing June 14th 2023
|
||||
# only devel branch codegen can generate
|
||||
# ptr deref when using var param
|
||||
# while version-1-6 and version-2-0 branch cannot
|
||||
noExplicitPtrDeref = defined(cpp) or defined(nimDevelFixVarParam)
|
||||
newerNim = (NimMajor, NimMinor) > (1, 6)
|
||||
noExplicitPtrDeref = defined(cpp) or newerNim
|
||||
|
||||
static:
|
||||
doAssert GCC_Compatible
|
||||
|
|
|
@ -724,14 +724,14 @@ template testIO(chk, tst, handleErr: untyped) =
|
|||
|
||||
chkDumpHexStint(chk, "abcdef0012345678abcdef1122334455", "5544332211efcdab7856341200efcdab", 128)
|
||||
|
||||
#static:
|
||||
#testIO(ctCheck, ctTest, ctExpect)
|
||||
static:
|
||||
testIO(ctCheck, ctTest, ctExpect)
|
||||
|
||||
proc main() =
|
||||
# Nim GC protests we are using too much global variables
|
||||
# so put it in a proc
|
||||
suite "Testing input and output procedures":
|
||||
#testIO(check, test, expect)
|
||||
testIO(check, test, expect)
|
||||
|
||||
test "toByteArrayBE CT vs RT":
|
||||
chkCTvsRT(check, 0xab'u64, 64)
|
||||
|
|
Loading…
Reference in New Issue