diff options
| author | Alexander Egorenkov <Alexander.Egorenkov@ibm.com> | 2020-06-02 09:28:11 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-06-23 16:18:44 +0200 |
| commit | e5d10a43278b10875ef0a80be4af2d1b5692c1c9 (patch) | |
| tree | 5d573de44c3c373721e7f36c12170a44109f20f6 /prog/encodingexec.go | |
| parent | 54566aff1679fc74487d3efb9f7bbfbc21beed4b (diff) | |
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 <Alexander.Egorenkov@ibm.com>
Diffstat (limited to 'prog/encodingexec.go')
| -rw-r--r-- | prog/encodingexec.go | 13 |
1 files changed, 5 insertions, 8 deletions
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:] } |
