From e5d10a43278b10875ef0a80be4af2d1b5692c1c9 Mon Sep 17 00:00:00 2001 From: Alexander Egorenkov Date: Tue, 2 Jun 2020 09:28:11 +0200 Subject: ipc: fix endianness issues Use native byte-order for IPC and program serialization. This way we will be able to support both little- and big-endian architectures. Signed-off-by: Alexander Egorenkov --- prog/encodingexec.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'prog/encodingexec.go') diff --git a/prog/encodingexec.go b/prog/encodingexec.go index 78eae81ae..2295bb72e 100644 --- a/prog/encodingexec.go +++ b/prog/encodingexec.go @@ -20,6 +20,8 @@ package prog import ( + "bytes" + "encoding/binary" "fmt" "sort" ) @@ -221,14 +223,9 @@ func (w *execContext) write(v uint64) { w.eof = true return } - w.buf[0] = byte(v >> 0) - w.buf[1] = byte(v >> 8) - w.buf[2] = byte(v >> 16) - w.buf[3] = byte(v >> 24) - w.buf[4] = byte(v >> 32) - w.buf[5] = byte(v >> 40) - w.buf[6] = byte(v >> 48) - w.buf[7] = byte(v >> 56) + buf := new(bytes.Buffer) + binary.Write(buf, HostEndian, v) + copy(w.buf, buf.Bytes()) w.buf = w.buf[8:] } -- cgit mrf-deployment