diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2020-01-26 14:11:07 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2020-01-26 14:11:28 -0500 |
commit | 1f5dbbbab170bc7f6dd2d47c7aface716ecb294c (patch) | |
tree | 5b956d920455036b9ae7a675b4e497a76edbb314 /rrdformat/rrdbinary/types.go | |
parent | a5cba20c1e3b0956737327ef9214fd2cbc221add (diff) |
wip
Diffstat (limited to 'rrdformat/rrdbinary/types.go')
-rw-r--r-- | rrdformat/rrdbinary/types.go | 27 |
1 files changed, 27 insertions, 0 deletions
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)) } |