From 34cfe3a3f2bdf13994a2a166e970e6b255368afb Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 26 Jan 2020 17:33:43 -0500 Subject: add timestamp type --- rrdformat/rrdbinary/types.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'rrdformat/rrdbinary/types.go') diff --git a/rrdformat/rrdbinary/types.go b/rrdformat/rrdbinary/types.go index cbe3e2d..892bb25 100644 --- a/rrdformat/rrdbinary/types.go +++ b/rrdformat/rrdbinary/types.go @@ -8,20 +8,24 @@ import ( type Architecture struct { ByteOrder binary.ByteOrder // C `double` - FloatWidth int // always 8 + FloatWidth int // always 8 -- we assume IEEE 754 doubles FloatAlign int - // C `unsigned long` - UintWidth int - UintAlign int + // C `long` or `unsigned long` + IntWidth int + IntAlign int // C `union { unsigned long; double; }` UnivalWidth int // max(FloatWidth, IntWidth) UnivalAlign int // max(FloatAlign, IntAlign) + // C `time_t` + TimeWidth int + TimeAlign int } -type String string // \0-terminatd -type Float float64 // 8 bytes -type Uint uint64 // 4 or 8 bytes -type Unival uint64 // 8 bytes +type String string // \0-terminatd +type Float float64 // 8 bytes +type Uint uint64 // 4 or 8 bytes +type Unival uint64 // 8 bytes +type Timestamp time.time // 8, 12, or 16 bytes func (u Unival) AsUint64() uint64 { return uint64(u) } func (u Unival) AsFloat64() float64 { return math.Float64frombits(uint64(u)) } -- cgit v1.2.3