mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-13 02:25:28 +00:00
include std/private/bitops_utils
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
import std/macros
|
||||
import std/private/since
|
||||
from std/private/bitops_utils import forwardImpl, castToUnsigned
|
||||
include std/private/bitops_utils
|
||||
|
||||
func bitnot*[T: SomeInteger](x: T): T {.magic: "BitnotI".}
|
||||
## Computes the `bitwise complement` of the integer `x`.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
template forwardImpl*(impl, arg) {.dirty.} =
|
||||
template forwardImpl(impl, arg) {.dirty.} =
|
||||
when sizeof(x) <= 4:
|
||||
when x is SomeSignedInt:
|
||||
impl(cast[uint32](x.int32))
|
||||
@@ -14,9 +14,9 @@ template forwardImpl*(impl, arg) {.dirty.} =
|
||||
# import std/typetraits
|
||||
# template castToUnsigned*(x: SomeInteger): auto = cast[toUnsigned(typeof(x))](x)
|
||||
|
||||
template castToUnsigned*(x: int8): uint8 = cast[uint8](x)
|
||||
template castToUnsigned*(x: int16): uint16 = cast[uint16](x)
|
||||
template castToUnsigned*(x: int32): uint32 = cast[uint32](x)
|
||||
template castToUnsigned*(x: int64): uint64 = cast[uint64](x)
|
||||
template castToUnsigned*(x: int): uint = cast[uint](x)
|
||||
template castToUnsigned*[T: SomeUnsignedInt](x: T): T = x
|
||||
template castToUnsigned(x: int8): uint8 = cast[uint8](x)
|
||||
template castToUnsigned(x: int16): uint16 = cast[uint16](x)
|
||||
template castToUnsigned(x: int32): uint32 = cast[uint32](x)
|
||||
template castToUnsigned(x: int64): uint64 = cast[uint64](x)
|
||||
template castToUnsigned(x: int): uint = cast[uint](x)
|
||||
template castToUnsigned[T: SomeUnsignedInt](x: T): T = x
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
## Contains the used algorithms for counting bits.
|
||||
|
||||
from std/private/bitops_utils import forwardImpl, castToUnsigned
|
||||
include std/private/bitops_utils
|
||||
|
||||
const useBuiltins* = not defined(noIntrinsicsBitOpts)
|
||||
const noUndefined* = defined(noUndefinedBitOpts)
|
||||
|
||||
Reference in New Issue
Block a user