From 1f5dbbbab170bc7f6dd2d47c7aface716ecb294c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 26 Jan 2020 14:11:07 -0500 Subject: wip --- rrdformat/rrdbinary/types.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 rrdformat/rrdbinary/types.go (limited to 'rrdformat/rrdbinary/types.go') diff --git a/rrdformat/rrdbinary/types.go b/rrdformat/rrdbinary/types.go new file mode 100644 index 0000000..cbe3e2d --- /dev/null +++ b/rrdformat/rrdbinary/types.go @@ -0,0 +1,27 @@ +package rrdbinary + +import ( + "encoding/binary" + "math" +) + +type Architecture struct { + ByteOrder binary.ByteOrder + // C `double` + FloatWidth int // always 8 + FloatAlign int + // C `unsigned long` + UintWidth int + UintAlign int + // C `union { unsigned long; double; }` + UnivalWidth int // max(FloatWidth, IntWidth) + UnivalAlign int // max(FloatAlign, IntAlign) +} + +type String string // \0-terminatd +type Float float64 // 8 bytes +type Uint uint64 // 4 or 8 bytes +type Unival uint64 // 8 bytes + +func (u Unival) AsUint64() uint64 { return uint64(u) } +func (u Unival) AsFloat64() float64 { return math.Float64frombits(uint64(u)) } -- cgit v1.2.3