mirror of
https://github.com/logos-storage/constantine.git
synced 2026-01-10 09:03:08 +00:00
Allow constant time booleans init from constant time uints
This commit is contained in:
parent
cadd81b978
commit
c4b3d49e69
@ -15,11 +15,17 @@ type
|
|||||||
## by conditional branches, we don't use booleans.
|
## by conditional branches, we don't use booleans.
|
||||||
## We use an int to prevent compiler "optimization" and introduction of branches
|
## We use an int to prevent compiler "optimization" and introduction of branches
|
||||||
|
|
||||||
func ctrue*(T: typedesc[BaseUint]): auto {.inline.}=
|
func ctrue*(T: typedesc[Ct or BaseUint]): auto {.inline.}=
|
||||||
(CTBool[Ct[T]])(true)
|
when T is Ct:
|
||||||
|
(CTBool[T])(true)
|
||||||
|
else:
|
||||||
|
(CTBool[Ct[T]])(true)
|
||||||
|
|
||||||
func cfalse*(T: typedesc[BaseUint]): auto {.inline.}=
|
func cfalse*(T: typedesc[Ct or BaseUint]): auto {.inline.}=
|
||||||
(CTBool[Ct[T]])(false)
|
when T is Ct:
|
||||||
|
(CTBool[T])(false)
|
||||||
|
else:
|
||||||
|
(CTBool[Ct[T]])(false)
|
||||||
|
|
||||||
func ct*[T: BaseUint](x: T): Ct[T] {.inline.}=
|
func ct*[T: BaseUint](x: T): Ct[T] {.inline.}=
|
||||||
(Ct[T])(x)
|
(Ct[T])(x)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user