diff --git a/stint/int_public.nim b/stint/int_public.nim index 684ef77..53a6a3b 100644 --- a/stint/int_public.nim +++ b/stint/int_public.nim @@ -9,7 +9,7 @@ import ./private/datatypes, macros export StInt -export IntImpl, intImpl # TODO remove the need to export these +export IntImpl, intImpl, bitsof # TODO remove the need to export these template make_unary(op, ResultTy): untyped = func `op`*(x: Stint): ResultTy {.inline.} = diff --git a/stint/private/datatypes.nim b/stint/private/datatypes.nim index f46fa8b..2d4fac9 100644 --- a/stint/private/datatypes.nim +++ b/stint/private/datatypes.nim @@ -166,32 +166,13 @@ type StInt*[bits: static[int]] = object data*: intImpl(bits) -template bitsof*(x: SomeInteger): int = sizeof(x) * 8 -# XXX: https://github.com/nim-lang/Nim/issues/9494 - the extra overloads -# can eventually be collapsed to one.. -template bitsof*(x: UintImpl[SomeInteger]): untyped = - 2 * bitsof(x.lo) -template bitsof*(x: UintImpl[UintImpl[SomeInteger]]): untyped = - 2 * bitsof(x.lo) -template bitsof*(x: UintImpl[UintImpl[UintImpl[SomeInteger]]]): untyped = - 2 * bitsof(x.lo) -template bitsof*(x: UintImpl[UintImpl[UintImpl[UintImpl[SomeInteger]]]]): untyped = - 2 * bitsof(x.lo) -template bitsof*(x: UintImpl[UintImpl[UintImpl[UintImpl[UintImpl[SomeInteger]]]]]): untyped = - 2 * bitsof(x.lo) -template bitsof*(x: UintImpl[UintImpl[UintImpl[UintImpl[UintImpl[UintImpl[SomeInteger]]]]]]): untyped = - # Uint2048 - eth-bloom - 2 * bitsof(x.lo) -template bitsof*(x: UintImpl[UintImpl[UintImpl[UintImpl[UintImpl[UintImpl[UintImpl[SomeInteger]]]]]]]): untyped = - # Uint4096 - modExp in Nimbus - 2 * bitsof(x.lo) -template bitsof*(x: UintImpl[UintImpl[UintImpl[UintImpl[UintImpl[UintImpl[UintImpl[UintImpl[SomeInteger]]]]]]]]): untyped = - # Uint8192 - modExp in Nimbus - 2 * bitsof(x.lo) - -template bitsof*(x: IntImpl): untyped = - 2 * bitsof(x.lo) +template bitsof*(x: SomeInteger): untyped = + sizeof(x) * 8 +template bitsof*(x: UintImpl|IntImpl): untyped = + # XXX: https://github.com/nim-lang/Nim/issues/9494 + mixin bitsof + bitsof(x.lo) * 2 template applyHiLo*(a: UintImpl | IntImpl, c: untyped): untyped = ## Apply `c` to each of `hi` and `lo` diff --git a/stint/uint_public.nim b/stint/uint_public.nim index 6451e47..1148649 100644 --- a/stint/uint_public.nim +++ b/stint/uint_public.nim @@ -10,7 +10,7 @@ import ./private/datatypes export StUint -export UintImpl, uintImpl # TODO: remove the need to export those +export UintImpl, uintImpl, bitsof # TODO: remove the need to export those import ./private/uint_addsub diff --git a/tests/nim.cfg b/tests/nim.cfg new file mode 100644 index 0000000..68f5cee --- /dev/null +++ b/tests/nim.cfg @@ -0,0 +1,3 @@ +# Ensure code is ready for threads.. +--threads:on +