Closed disruptek closed 4 years ago
Does this really work? I was always under the impression that nimvm
was special cased and that you would need to write
template beLoad32*[T: byte|char](src: openarray[T], srco: int): uint32 =
when nimvm:
(uint32(src[srco + 0]) shl 24) or (uint32(src[srco + 1]) shl 16) or
(uint32(src[srco + 2]) shl 8) or uint32(src[srco + 3])
else:
when defined(tcc):
(uint32(src[srco + 0]) shl 24) or (uint32(src[srco + 1]) shl 16) or
(uint32(src[srco + 2]) shl 8) or uint32(src[srco + 3])
else:
let p = cast[ptr uint32](unsafeAddr src[srco])[]
leSwap32(p)
instead of
template beLoad32*[T: byte|char](src: openarray[T], srco: int): uint32 =
when nimvm or defined(tcc):
(uint32(src[srco + 0]) shl 24) or (uint32(src[srco + 1]) shl 16) or
(uint32(src[srco + 2]) shl 8) or uint32(src[srco + 3])
else:
let p = cast[ptr uint32](unsafeAddr src[srco])[]
leSwap32(p)
otherwise Nim would throw invalid context nimvm error.
Works for me, but feel free to close; I no longer need this, myself.
@disruptek it fails test suite, if you not going to fix it i will close it.
This is how I'm doing it.