blob: bb569e7f878d13bde2eb926dd04178d864c27cb4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#
#
# Nimrod's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
## This module contains helpers that deal with different byte orders
## (`endian`:idx:).
proc swapEndian64*(outp, inp: pointer) =
## copies `inp` to `outp` swapping bytes. Both buffers are supposed to
## contain at least 8 bytes.
var i = cast[cstring](inp)
var o = cast[cstring](outp)
o[0] = i[7]
o[1] = i[6]
o[2] = i[5]
o[3] = i[4]
o[4] = i[3]
o[5] = i[2]
o[6] = i[1]
o
|