summaryrefslogtreecommitdiff
path: root/rrdformat/rrdbinary/types.go
diff options
context:
space:
mode:
Diffstat (limited to 'rrdformat/rrdbinary/types.go')
-rw-r--r--rrdformat/rrdbinary/types.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/rrdformat/rrdbinary/types.go b/rrdformat/rrdbinary/types.go
index e3011d5..b8001af 100644
--- a/rrdformat/rrdbinary/types.go
+++ b/rrdformat/rrdbinary/types.go
@@ -12,6 +12,9 @@ type Architecture struct {
// C `double`
DoubleWidth int // always 8 -- we assume IEEE 754 doubles
DoubleAlign int
+ // C `short`
+ ShortWidth int
+ ShortAlign int
// C `long` or `unsigned long`
LongWidth int
LongAlign int
@@ -27,15 +30,21 @@ type String string // \0-terminated
type Double float64 // 8 bytes
type ULong uint64 // 4 or 8 bytes
type Long int64 // 4 or 8 bytes
-type Unival uint64 // 8 bytes
type Time int64 // 4 or 8 bytes, only has second-precision
type EOF struct{} // 0 bytes
-func (u Unival) AsULong() ULong { return ULong(u) }
-func (u Unival) AsDouble() Double { return Double(math.Float64frombits(uint64(u))) }
+type Unival struct {
+ arch Architecture
+ data []byte // 8 bytes
+}
+
+func (u Unival) AsULong() ULong { return ULong(u.arch.ByteOrder.Uint64(u.data)) }
+func (u Unival) AsDouble() Double {
+ return Double(math.Float64frombits(u.arch.ByteOrder.Uint64(u.data)))
+}
func (u Unival) String() string {
- return fmt.Sprintf("{ .ulong=%d; .double=%s }", u.AsULong(), u.AsDouble().String())
+ return fmt.Sprintf("enum{ .ulong=%d; .double=%s; .cdefds=%v }", u.AsULong(), u.AsDouble(), u.AsRPNTokens())
}
func (u Unival) MarshalText() ([]byte, error) {